Complete.Org: Mailing Lists: Archives: freeciv-dev: September 2004:
[Freeciv-Dev] (PR#9942) planned unit movement
Home

[Freeciv-Dev] (PR#9942) planned unit movement

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: lakatoszoltan@xxxxxxxxxx
Subject: [Freeciv-Dev] (PR#9942) planned unit movement
From: "Guest" <rt-guest@xxxxxxxxxxx>
Date: Sun, 26 Sep 2004 02:16:23 -0700
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=9942 >

 
 
In this version of patch I made movement point clearing in unithand.c 
and there is a function to change move-packets. It seems much better. 
 
But the server option and fair order come later. 
 
(Somehow some redundant rows appeared in patch. As I remember, I have 
never changed that lines.) 
 
Zoli 
diff -r -u freeciv-1.14.1/server/srv_main.c freeciv-1.14.1-mod/server/srv_main.c
--- freeciv-1.14.1/server/srv_main.c    2003-11-30 20:22:48.000000000 +0100
+++ freeciv-1.14.1-mod/server/srv_main.c        2004-09-26 06:53:30.000000000 
+0200
@@ -763,7 +763,8 @@
     break;
 
   case PACKET_MOVE_UNIT:
-    handle_move_unit(pplayer, (struct packet_move_unit *)packet);
+  /*  handle_move_unit(pplayer, (struct packet_move_unit *)packet); */
+    handle_move_unit_as_goto_route(pplayer, (struct packet_move_unit *)packet);
     break;
  
   case PACKET_CHAT_MSG:
diff -r -u freeciv-1.14.1/server/unithand.c freeciv-1.14.1-mod/server/unithand.c
--- freeciv-1.14.1/server/unithand.c    2003-11-30 20:22:48.000000000 +0100
+++ freeciv-1.14.1-mod/server/unithand.c        2004-09-27 10:40:19.000000000 
+0200
@@ -1,4 +1,4 @@
-/********************************************************************** 
+/**********************************************************************
  Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -716,7 +716,7 @@
     punit->moves_left = 0;
   pwinner = (punit->hp > 0) ? punit : pdefender;
   plooser = (pdefender->hp > 0) ? punit : pdefender;
-    
+
   combat.attacker_unit_id=punit->id;
   combat.defender_unit_id=pdefender->id;
   combat.attacker_hp=punit->hp / game.firepower_factor;
@@ -1314,7 +1314,7 @@
 /**************************************************************************
 Explode nuclear at a tile without enemy units
 **************************************************************************/
-void handle_unit_nuke(struct player *pplayer, 
+void handle_unit_nuke(struct player *pplayer,
                      struct packet_unit_request *req)
 {
   struct unit *punit = player_find_unit_by_id(pplayer, req->unit_id);
@@ -1328,11 +1328,11 @@
 /**************************************************************************
 ...
 **************************************************************************/
-void handle_unit_paradrop_to(struct player *pplayer, 
+void handle_unit_paradrop_to(struct player *pplayer,
                             struct packet_unit_request *req)
 {
   struct unit *punit = player_find_unit_by_id(pplayer, req->unit_id);
-  
+
   if (!punit) {
     return;
   }
@@ -1414,6 +1414,8 @@
   if (!check_route(pplayer, packet))
     return;
 
+  punit->moves_left = 0;
+
   handle_unit_activity_request(punit, ACTIVITY_GOTO);
   handle_route(pplayer, packet);
 }
@@ -1434,3 +1436,37 @@
   handle_unit_activity_request(punit, ACTIVITY_PATROL);
   handle_route(pplayer, packet);
 }
+
+/**************************************************************************
+Creates a packet_goto_route according to packet_move_unit
+**************************************************************************/
+struct packet_goto_route *create_packet_goto_route(struct packet_move_unit 
*pmove)
+{
+  int num_valid = 1;
+  struct packet_goto_route *packet;
+
+  packet = fc_malloc(sizeof(struct packet_goto_route));
+  packet->unit_id = pmove->unid;
+  packet->pos = fc_malloc((num_valid+1) * sizeof(struct map_position));
+  packet->length = num_valid + 1;
+  packet->first_index = 0;
+  packet->last_index = num_valid;
+
+  packet->pos[0].x = pmove->x;
+  packet->pos[0].y = pmove->y;
+
+  return packet;
+}
+
+/**************************************************************************
+Treats unit move as GOTO
+**************************************************************************/
+void handle_move_unit_as_goto_route(struct player *pplayer, struct 
packet_move_unit *pmove)
+{
+  struct packet_goto_route *packet = create_packet_goto_route(pmove);
+
+  handle_goto_route(pplayer,packet);
+
+  free(packet);
+}
+
diff -r -u freeciv-1.14.1/server/unithand.h freeciv-1.14.1-mod/server/unithand.h
--- freeciv-1.14.1/server/unithand.h    2003-11-30 20:22:48.000000000 +0100
+++ freeciv-1.14.1-mod/server/unithand.h        2004-09-25 20:47:49.000000000 
+0200
@@ -1,4 +1,4 @@
-/********************************************************************** 
+/**********************************************************************
  Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -67,4 +67,6 @@
 void handle_goto_route(struct player *pplayer, struct packet_goto_route 
*packet);
 void handle_patrol_route(struct player *pplayer, struct packet_goto_route 
*packet);
 
+void handle_move_unit_as_goto_route(struct player *pplayer, struct 
packet_move_unit *pmove);
+
 #endif  /* FC__UNITHAND_H */
diff -r -u freeciv-1.14.1/server/unittools.c 
freeciv-1.14.1-mod/server/unittools.c
--- freeciv-1.14.1/server/unittools.c   2003-11-30 20:22:48.000000000 +0100
+++ freeciv-1.14.1-mod/server/unittools.c       2004-09-26 17:23:11.000000000 
+0200
@@ -1,4 +1,4 @@
-/********************************************************************** 
+/**********************************************************************
  Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -366,7 +366,7 @@
       if (punit->fuel < unit_type(punit)->fuel) { 
         if (!best_unit) 
           best_unit=punit;
-        else 
+        else
           best_unit=choose_more_important_refuel_target(best_unit, punit);
       }
     }
@@ -1002,7 +1002,12 @@
        punit->ai.passenger != 0 || !pplayer->ai.control)) {
 /* autosettlers otherwise waste time; idling them breaks assignment */
 /* Stalling infantry on GOTO so I can see where they're GOing TO. -- Syela */
-      (void) do_unit_goto(punit, GOTO_MOVE_ANY, TRUE);
+        if (do_unit_goto(punit, GOTO_MOVE_ANY, TRUE) == GR_DIED) {
+                   return;
+        }
+/* Restore unit flash and show movepoints in client --Zoli */
+        unit_restore_movepoints(pplayer, punit);
+        send_unit_info(NULL, punit);
     }
     return;
   }

[Prev in Thread] Current Thread [Next in Thread]