~ubuntu-branches/ubuntu/lucid/warzone2100/lucid

« back to all changes in this revision

Viewing changes to src/multibot.c

  • Committer: Bazaar Package Importer
  • Author(s): Paul Wise
  • Date: 2008-12-04 01:13:26 UTC
  • mfrom: (1.1.7 upstream) (2.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20081204011326-be9aos1swwhq2agu
Tags: 2.1.0~1.rc2-1
* New upstream release candidate
* Remove Linas Žvirblis from uploaders since he hasn't been
  heard from for a very long time.
* Improve the cross-build support slightly

Show diffs side-by-side

added added

removed removed

Lines of Context:
130
130
        {
131
131
                uint8_t player = psDroid->player;
132
132
                uint32_t droid = psDroid->id;
 
133
                uint32_t body = psDroid->body;
 
134
                Vector3uw pos = psDroid->pos;
133
135
 
134
136
                NETuint8_t(&player);
135
137
                NETuint32_t(&droid);
136
138
                NETenum(&sec);
137
139
                NETenum(&state);
 
140
                NETuint32_t(&body);
 
141
                NETVector3uw(&pos);
138
142
        }
139
143
        return NETend();
140
144
}
145
149
        DROID*          psDroid;
146
150
        SECONDARY_ORDER sec = DSO_ATTACK_RANGE;
147
151
        SECONDARY_STATE state = DSS_NONE;
 
152
        uint32_t body;
 
153
        Vector3uw pos;
148
154
 
149
155
        NETbeginDecode(NET_SECONDARY);
150
156
        {
155
161
                NETuint32_t(&droid);
156
162
                NETenum(&sec);
157
163
                NETenum(&state);
 
164
                NETuint32_t(&body);
 
165
                NETVector3uw(&pos);
158
166
 
159
167
                // If we can not find the droid should we not ask for it?
160
168
                if (!IdToDroid(droid, player, &psDroid))
170
178
        secondarySetState(psDroid, sec, state);
171
179
        turnOffMultiMsg(false);
172
180
 
 
181
        // Set the droids body points (HP)
 
182
        psDroid->body = body;
 
183
 
 
184
        // Set the droids position if it is more than two tiles out
 
185
        if (abs(pos.x - psDroid->pos.x) > (TILE_UNITS * 2)
 
186
         || abs(pos.y - psDroid->pos.y) > (TILE_UNITS * 2))
 
187
        {
 
188
                int oldx = psDroid->pos.x;
 
189
                int oldy = psDroid->pos.y;
 
190
 
 
191
                // Jump it, even if it is on screen (may want to change this)
 
192
                psDroid->pos = pos;
 
193
 
 
194
                // Tell the grid system that the object has moved
 
195
                gridMoveDroid(psDroid, oldx, oldy);
 
196
        }
 
197
 
173
198
        return true;
174
199
}
175
200
 
652
677
                        if (psDroid->selected)
653
678
                        {
654
679
                                NETuint32_t(&psDroid->id);
 
680
                                NETuint32_t(&psDroid->body);
 
681
                                NETVector3uw(&psDroid->pos);
655
682
                                --droidCount;
656
683
                        }
657
684
                }
710
737
                for (psDroid = psGroup->psList; psDroid; psDroid = psDroid->psGrpNext)
711
738
                {
712
739
                        NETuint32_t(&psDroid->id);
 
740
                        NETuint32_t(&psDroid->body);
 
741
                        NETVector3uw(&psDroid->pos);
713
742
                }
714
743
        }
715
744
        return NETend();
727
756
 
728
757
        uint8_t droidCount, i;
729
758
        uint32_t* droidIDs;
 
759
        uint32_t *droidBodies;
 
760
        Vector3uw *droidPositions;
730
761
 
731
762
        NETbeginDecode(NET_GROUPORDER);
732
763
        {
753
784
                // Allocate some space on the stack to hold the droid IDs
754
785
                droidIDs = alloca(droidCount * sizeof(uint32_t));
755
786
 
 
787
                // Plus some more space for the body points of the droids
 
788
                droidBodies = alloca(droidCount * sizeof(uint32_t));
 
789
 
 
790
                // Finally some space for the positions of the droids
 
791
                droidPositions = alloca(droidCount * sizeof(Vector3uw));
 
792
 
756
793
                // Retrieve the droids from the message
757
794
                for (i = 0; i < droidCount; ++i)
758
795
                {
765
802
                                NETend();
766
803
                                return false;
767
804
                        }
 
805
 
 
806
                        // Get the body points of the droid
 
807
                        NETuint32_t(&droidBodies[i]);
 
808
 
 
809
                        // Get the position of the droid
 
810
                        NETVector3uw(&droidPositions[i]);
768
811
                }
769
812
        }
770
813
        NETend();
780
823
        for (i = 0; i < droidCount; ++i)
781
824
        {
782
825
                DROID* psDroid;
 
826
                uint32_t body = droidBodies[i];
 
827
                Vector3uw pos = droidPositions[i];
783
828
 
784
829
                // Retrieve the droid associated with the current ID
785
830
                if (!IdToDroid(droidIDs[i], ANYPLAYER, &psDroid))
813
858
                         */
814
859
                        ProcessDroidOrder(psDroid, order, x, y, 0, 0);
815
860
                }
 
861
 
 
862
                // Update the droids body points
 
863
                psDroid->body = body;
 
864
 
 
865
                // Set the droids position if it is more than two tiles out
 
866
                if (abs(pos.x - psDroid->pos.x) > (TILE_UNITS * 2)
 
867
                 || abs(pos.y - psDroid->pos.y) > (TILE_UNITS * 2))
 
868
                {
 
869
                        int oldx = psDroid->pos.x;
 
870
                        int oldy = psDroid->pos.y;
 
871
 
 
872
                        // Jump it, even if it is on screen (may want to change this)
 
873
                        psDroid->pos = pos;
 
874
 
 
875
                        // Tell the grid system that the object has moved
 
876
                        gridMoveDroid(psDroid, oldx, oldy);
 
877
                }
816
878
        }
817
879
 
818
880
        return true;