[Freeciv-Dev] (PR#8498) load/unload should be done by the client
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: |
undisclosed-recipients: ; |
Subject: |
[Freeciv-Dev] (PR#8498) load/unload should be done by the client |
From: |
"Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx> |
Date: |
Mon, 12 Apr 2004 11:30:21 -0700 |
Reply-to: |
rt@xxxxxxxxxxx |
<URL: http://rt.freeciv.org/Ticket/Display.html?id=8498 >
Currently when you activate a unit it is unloaded, and when you sentry
it it is loaded (sometimes).
This should be done by the client, not the server. This allows it to be
controlled by a client option and gives modified clients more flexibility.
Patch attached.
jason
Index: client/control.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/control.c,v
retrieving revision 1.133
diff -u -r1.133 control.c
--- client/control.c 12 Apr 2004 17:50:48 -0000 1.133
+++ client/control.c 12 Apr 2004 18:17:29 -0000
@@ -771,6 +771,33 @@
**************************************************************************/
void request_new_unit_activity(struct unit *punit, enum unit_activity act)
{
+ struct unit *ptrans;
+
+ if (!can_client_issue_orders()) {
+ return;
+ }
+
+ /* Load or unload the unit depending on the new activity. Don't call
+ * request_unit_load or request_unit_unload since this can give a
+ * recursive loop. */
+ switch (act) {
+ case ACTIVITY_IDLE:
+ ptrans = find_unit_by_id(punit->transported_by);
+ if (can_unit_unload(punit, ptrans)
+ && can_unit_survive_at_tile(punit, punit->x, punit->y)) {
+ dsend_packet_unit_unload(&aconnection, punit->id, ptrans->id);
+ }
+ break;
+ case ACTIVITY_SENTRY:
+ ptrans = find_transporter_for_unit(punit, punit->x, punit->y);
+ if (can_unit_load(punit, ptrans)) {
+ dsend_packet_unit_load(&aconnection, punit->id, ptrans->id);
+ }
+ break;
+ default:
+ break;
+ }
+
dsend_packet_unit_change_activity(&aconnection, punit->id, act,
S_NO_SPECIAL);
}
@@ -844,7 +871,11 @@
if (can_client_issue_orders()
&& can_unit_load(pcargo, ptrans)) {
dsend_packet_unit_load(&aconnection, pcargo->id, ptrans->id);
- request_unit_sentry(pcargo);
+
+ /* Sentry the unit. Don't request_unit_sentry since this can give a
+ * recursive loop. */
+ dsend_packet_unit_change_activity(&aconnection, pcargo->id,
+ ACTIVITY_SENTRY, S_NO_SPECIAL);
}
}
Index: server/unithand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/unithand.c,v
retrieving revision 1.293
diff -u -r1.293 unithand.c
--- server/unithand.c 1 Apr 2004 23:46:26 -0000 1.293
+++ server/unithand.c 12 Apr 2004 18:17:29 -0000
@@ -545,18 +545,6 @@
return;
}
- if (activity == ACTIVITY_IDLE && punit->transported_by != -1
- && can_unit_survive_at_tile(punit, punit->x, punit->y)) {
- unload_unit_from_transporter(punit);
- } else if (activity == ACTIVITY_SENTRY && punit->transported_by == -1) {
- struct unit *ptrans = find_transporter_for_unit(punit,
- punit->x, punit->y);
-
- if (ptrans) {
- load_unit_onto_transporter(punit, ptrans);
- }
- }
-
if (punit->activity != activity ||
punit->activity_target != activity_target ||
punit->ai.control) {
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#8498) load/unload should be done by the client,
Jason Short <=
|
|