Subversion Repositories Games.Carmageddon

Rev

Rev 20 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 pmbaty 1
#include "netgame.h"
20 pmbaty 2
#include "brender/brender.h"
1 pmbaty 3
#include "car.h"
4
#include "displays.h"
5
#include "errors.h"
6
#include "globvars.h"
7
#include "globvrpb.h"
8
#include "grafdata.h"
9
#include "graphics.h"
10
#include "harness/trace.h"
11
#include "loading.h"
12
#include "network.h"
13
#include "newgame.h"
14
#include "opponent.h"
15
#include "pd/sys.h"
16
#include "pedestrn.h"
17
#include "powerup.h"
18
#include "racestrt.h"
19
#include "structur.h"
20
#include "utility.h"
21
#include <stdlib.h>
22
#include <string.h>
23
 
24
int gPowerup_cost[4] = { 1500, 2500, 4000, 6000 };
20 pmbaty 25
int gGame_scores[6];
1 pmbaty 26
int gPed_target;
27
int gNot_shown_race_type_headup;
28
tU32 gLast_it_change;
29
tU32 gTime_for_punishment;
30
tNet_game_player_info* gLast_lepper;
31
int gInitialised_grid;
32
int gIt_or_fox;
33
 
34
// IDA: void __usercall SendCarData(tU32 pNext_frame_time@<EAX>)
35
void SendCarData(tU32 pNext_frame_time) {
20 pmbaty 36
    //tNet_contents* contents; // Pierre-Marie Baty -- unused variable
37
    //tCar_spec* car; // Pierre-Marie Baty -- unused variable
38
    //tCollision_info* ncar; // Pierre-Marie Baty -- unused variable
39
    //int i; // Pierre-Marie Baty -- unused variable
40
    //int j; // Pierre-Marie Baty -- unused variable
41
    //static tU32 last_time; // Pierre-Marie Baty -- unused variable
42
    //tU32 time; // Pierre-Marie Baty -- unused variable
43
    //int damaged_wheels; // Pierre-Marie Baty -- unused variable
1 pmbaty 44
    LOG_TRACE("(%d)", pNext_frame_time);
45
 
20 pmbaty 46
    if (gNet_mode) {
47
        TELL_ME_IF_WE_PASS_THIS_WAY();
1 pmbaty 48
    }
49
}
50
 
51
// IDA: void __usercall ReceivedRecover(tNet_contents *pContents@<EAX>)
52
void ReceivedRecover(tNet_contents* pContents) {
20 pmbaty 53
    //int i; // Pierre-Marie Baty -- unused variable
1 pmbaty 54
    LOG_TRACE("(%p)", pContents);
20 pmbaty 55
    NOT_IMPLEMENTED();
1 pmbaty 56
}
57
 
58
// IDA: void __usercall CopyMechanics(tCar_spec *pCar@<EAX>, tNet_contents *pContents@<EDX>)
59
void CopyMechanics(tCar_spec* pCar, tNet_contents* pContents) {
20 pmbaty 60
    //int j; // Pierre-Marie Baty -- unused variable
1 pmbaty 61
    LOG_TRACE("(%p, %p)", pCar, pContents);
20 pmbaty 62
    NOT_IMPLEMENTED();
1 pmbaty 63
}
64
 
65
// IDA: void __usercall ReceivedMechanics(tNet_contents *pContents@<EAX>)
66
void ReceivedMechanics(tNet_contents* pContents) {
20 pmbaty 67
    //int i; // Pierre-Marie Baty -- unused variable
68
    //tCar_spec* car; // Pierre-Marie Baty -- unused variable
1 pmbaty 69
    LOG_TRACE("(%p)", pContents);
20 pmbaty 70
    NOT_IMPLEMENTED();
1 pmbaty 71
}
72
 
73
// IDA: void __usercall ReceivedCopInfo(tNet_contents *pContents@<EAX>)
74
void ReceivedCopInfo(tNet_contents* pContents) {
20 pmbaty 75
    //tCar_spec* c; // Pierre-Marie Baty -- unused variable
76
    //int i; // Pierre-Marie Baty -- unused variable
1 pmbaty 77
    LOG_TRACE("(%p)", pContents);
20 pmbaty 78
    NOT_IMPLEMENTED();
1 pmbaty 79
}
80
 
81
// IDA: void __cdecl SendAllNonCarPositions()
82
void SendAllNonCarPositions(void) {
83
    int i;
84
    br_actor** list;
85
    tNon_car_spec* non_car;
86
    tNet_contents* contents;
87
    LOG_TRACE("()");
88
 
89
    list = gProgram_state.track_spec.non_car_list;
90
    for (i = 0; i < gProgram_state.track_spec.ampersand_digits; ++i) {
91
        if (list[i]->type_data != NULL) {
92
            non_car = (tNon_car_spec*)list[i]->type_data;
93
            if (non_car->collision_info.driver == eDriver_non_car_unused_slot || non_car->collision_info.car_ID != i) {
94
                contents = NetGetBroadcastContents(NETMSGID_NONCARPOSITION, 0);
95
                BrMatrix34Copy(&contents->data.non_car_position.mat, &list[i]->t.t.mat);
96
                contents->data.non_car_position.ID = i;
97
                contents->data.non_car_position.flags = list[i]->identifier[3] == '!';
98
            }
99
        }
100
    }
101
    NetSendMessageStacks();
102
}
103
 
104
// IDA: void __usercall ReceivedNonCarPosition(tNet_contents *pContents@<EAX>)
105
void ReceivedNonCarPosition(tNet_contents* pContents) {
20 pmbaty 106
    //br_actor* actor; // Pierre-Marie Baty -- unused variable
1 pmbaty 107
    LOG_TRACE("(%p)", pContents);
20 pmbaty 108
    NOT_IMPLEMENTED();
1 pmbaty 109
}
110
 
111
// IDA: void __usercall ReceivedNonCar(tNet_contents *pContents@<EAX>)
112
void ReceivedNonCar(tNet_contents* pContents) {
20 pmbaty 113
    //br_actor* actor; // Pierre-Marie Baty -- unused variable
114
    //br_vector3 tv; // Pierre-Marie Baty -- unused variable
115
    //tU8 cx; // Pierre-Marie Baty -- unused variable
116
    //tU8 cz; // Pierre-Marie Baty -- unused variable
117
    //tTrack_spec* track_spec; // Pierre-Marie Baty -- unused variable
118
    //tNon_car_spec* ncar; // Pierre-Marie Baty -- unused variable
119
    //tCollision_info* c; // Pierre-Marie Baty -- unused variable
1 pmbaty 120
    LOG_TRACE("(%p)", pContents);
20 pmbaty 121
    NOT_IMPLEMENTED();
1 pmbaty 122
}
123
 
124
// IDA: void __usercall SignalToStartRace2(int pIndex@<EAX>)
125
void SignalToStartRace2(int pIndex) {
126
    tNet_message* the_message;
127
    int i;
128
    int j;
129
    LOG_TRACE("(%d)", pIndex);
130
 
131
    if (gCurrent_race.number_of_racers > 6) {
132
        FadePaletteUp();
133
        dr_dprintf("AAAARRRGGGHHH!!!! More than 6 racers!!!!");
134
        PDFatalError("AAAARRRGGGHHH!!!! More than 6 racers!!!!");
135
    }
136
    gNeed_to_send_start_race = 0;
137
    gStart_race_sent = 1;
138
    the_message = NetBuildMessage(NETMSGID_STARTRACE, 0);
139
    the_message->contents.data.start_race.racing = gProgram_state.racing;
140
    if (pIndex >= 0) {
141
        gNet_players[pIndex].last_waste_message = 0;
142
        gNet_players[pIndex].wasteage_attributed = 0;
143
        the_message->contents.data.start_race.car_count = -1;
144
        the_message->contents.data.start_race.car_list[0].index = pIndex;
145
        BrMatrix34Copy(&the_message->contents.data.start_race.car_list[0].mat,
146
            &gCurrent_race.opponent_list[gNet_players[pIndex].opponent_list_index].car_spec->car_master_actor->t.t.mat);
147
    } else {
148
        the_message->contents.data.start_race.car_count = gCurrent_race.number_of_racers;
149
        for (i = 0; i < gCurrent_race.number_of_racers; i++) {
150
            BrMatrix34Copy(&the_message->contents.data.start_race.car_list[i].mat,
151
                &gCurrent_race.opponent_list[i].car_spec->car_master_actor->t.t.mat);
152
            for (j = 0; j < gNumber_of_net_players; j++) {
153
                if (gCurrent_race.opponent_list[i].car_spec == gNet_players[j].car) {
154
                    the_message->contents.data.start_race.car_list[i].index = j;
155
                    break;
156
                }
157
            }
158
            if (gCurrent_net_game->options.random_car_choice && (gCurrent_net_game->options.car_choice == eNet_car_all || gCurrent_net_game->options.car_choice == eNet_car_both)) {
159
                if (gNet_players[the_message->contents.data.start_race.car_list[i].index].next_car_index < 0) {
160
                    gNet_players[the_message->contents.data.start_race.car_list[i].index].next_car_index = PickARandomCar();
161
                    gCar_details[gNet_players[the_message->contents.data.start_race.car_list[i].index].next_car_index].ownership = eCar_owner_someone;
162
                }
163
                the_message->contents.data.start_race.car_list[i].next_car_index = gNet_players[the_message->contents.data.start_race.car_list[i].index].next_car_index;
164
            }
165
        }
166
        if (gPending_race < 0) {
167
            gPending_race = PickNetRace(gProgram_state.current_race_index,
168
                gCurrent_net_game->options.race_sequence_type);
169
        }
170
        the_message->contents.data.start_race.next_race = gPending_race;
171
    }
172
    NetGuaranteedSendMessageToAllPlayers(gCurrent_net_game, the_message, NULL);
173
    if (gProgram_state.racing) {
174
        SendCurrentPowerups();
175
    }
176
}
177
 
178
// IDA: void __cdecl SignalToStartRace()
179
void SignalToStartRace(void) {
180
    LOG_TRACE("()");
181
 
182
    gCurrent_net_game->no_races_yet = 0;
183
    SignalToStartRace2(-1);
184
}
185
 
186
// IDA: void __cdecl SetUpNetCarPositions()
187
void SetUpNetCarPositions(void) {
188
    int i;
189
    //int j; // Pierre-Marie Baty -- unused variable
190
    int k;
191
    int grid_index;
192
    int racer_count;
193
    LOG_TRACE("()");
194
 
195
    DisableNetService();
196
    if (!gInitialised_grid) {
197
        for (i = 0; i < gNumber_of_net_players; i++) {
198
            gNet_players[i].grid_position_set = 0;
199
            gNet_players[i].last_waste_message = 0;
200
            gNet_players[i].wasteage_attributed = 0;
201
        }
202
    }
203
    for (i = 0; i < gNumber_of_net_players; i++) {
204
        gCurrent_race.opponent_list[i].index = -1;
205
        gCurrent_race.opponent_list[i].ranking = IRandomBetween(0, 99);
206
        gCurrent_race.opponent_list[i].car_spec = gNet_players[i].car;
207
        gCurrent_race.opponent_list[i].net_player_index = i;
208
        gNet_players[i].opponent_list_index = i;
209
    }
210
    if (!gInitialised_grid && gCurrent_net_game->options.grid_start) {
211
        qsort(gCurrent_race.opponent_list, gNumber_of_net_players, sizeof(tOpp_spec), SortGridFunction);
212
    }
213
    gCurrent_race.number_of_racers = 0;
214
    for (i = 0; i < gNumber_of_net_players; i++) {
215
        gNet_players[gCurrent_race.opponent_list[i].net_player_index].opponent_list_index = i;
216
    }
217
    for (i = 0; i < gNumber_of_net_players; i++) {
218
        if ((gCurrent_race.opponent_list[i].car_spec->driver == eDriver_oppo && !gInitialised_grid)
219
            || (gCurrent_race.opponent_list[i].car_spec->driver >= eDriver_net_human && !gNet_players[gCurrent_race.opponent_list[i].net_player_index].grid_position_set)) {
220
            grid_index = -1;
221
            racer_count = 0;
222
            while (racer_count < 6 && grid_index < 0) {
223
                grid_index = racer_count;
224
                for (k = 0; k < gNumber_of_net_players; k++) {
225
                    if (k != i
226
                        && gNet_players[gCurrent_race.opponent_list[k].net_player_index].grid_position_set
227
                        && gNet_players[gCurrent_race.opponent_list[k].net_player_index].grid_index == racer_count) {
228
                        grid_index = -1;
229
                        break;
230
                    }
231
                }
232
                racer_count++;
233
            }
234
            if (grid_index < 0) {
235
                FatalError(kFatalError_NetworkCodeSelfCheck);
236
            }
237
            SetInitialPosition(&gCurrent_race, i, grid_index);
238
            gNet_players[gCurrent_race.opponent_list[i].net_player_index].grid_index = grid_index;
239
            if (gInitialised_grid) {
240
                InitialiseCar2(gCurrent_race.opponent_list[i].car_spec, 0);
241
            } else {
242
                gCurrent_race.number_of_racers = i + 1;
243
            }
244
            gNet_players[gCurrent_race.opponent_list[i].net_player_index].grid_position_set = 1;
245
        }
246
    }
247
    gCurrent_race.number_of_racers = gNumber_of_net_players;
248
    gInitialised_grid = 1;
249
    ReenableNetService();
250
}
251
 
252
// IDA: void __usercall ReinitialiseCar(tCar_spec *pCar@<EAX>)
253
void ReinitialiseCar(tCar_spec* pCar) {
20 pmbaty 254
    //int i; // Pierre-Marie Baty -- unused variable
1 pmbaty 255
    LOG_TRACE("(%p)", pCar);
20 pmbaty 256
    NOT_IMPLEMENTED();
1 pmbaty 257
}
258
 
259
// IDA: void __usercall RepositionPlayer(int pIndex@<EAX>)
260
void RepositionPlayer(int pIndex) {
20 pmbaty 261
    //tNet_message* the_message; // Pierre-Marie Baty -- unused variable
262
    //tCar_spec* car;            // Pierre-Marie Baty -- unused variable
1 pmbaty 263
    LOG_TRACE("(%d)", pIndex);
20 pmbaty 264
    NOT_IMPLEMENTED();
1 pmbaty 265
}
266
 
267
// IDA: void __usercall DisableCar(tCar_spec *pCar@<EAX>)
268
void DisableCar(tCar_spec* pCar) {
269
    LOG_TRACE("(%p)", pCar);
270
 
271
    if (pCar->driver_name[0] != '\0') {
272
        if (!pCar->disabled) {
273
            pCar->disabled = 1;
274
            ForceRebuildActiveCarList();
275
        }
276
        if (pCar->car_master_actor->t.t.mat.m[3][0] < 500.0f) {
277
            pCar->car_master_actor->t.t.mat.m[3][0] = pCar->car_master_actor->t.t.mat.m[3][0] + 1000.0f;
278
            pCar->car_master_actor->t.t.mat.m[3][1] = pCar->car_master_actor->t.t.mat.m[3][1] + 1000.0f;
279
            pCar->car_master_actor->t.t.mat.m[3][2] = pCar->car_master_actor->t.t.mat.m[3][2] + 1000.0f;
280
            pCar->old_frame_mat.m[3][0] = pCar->car_master_actor->t.t.mat.m[3][0];
281
            pCar->old_frame_mat.m[3][1] = pCar->car_master_actor->t.t.mat.m[3][1];
282
            pCar->old_frame_mat.m[3][2] = pCar->car_master_actor->t.t.mat.m[3][2];
283
        }
284
    }
285
}
286
 
287
// IDA: void __usercall EnableCar(tCar_spec *pCar@<EAX>)
288
void EnableCar(tCar_spec* pCar) {
289
    LOG_TRACE("(%p)", pCar);
290
 
291
    if (pCar->driver_name[0] != '\0') {
292
        if (pCar->disabled) {
293
            pCar->disabled = 0;
294
            ForceRebuildActiveCarList();
295
        }
296
        if (pCar->car_master_actor->t.t.mat.m[3][0] > 500.0f) {
297
            pCar->car_master_actor->t.t.mat.m[3][0] = pCar->car_master_actor->t.t.mat.m[3][0] - 1000.0f;
298
            pCar->car_master_actor->t.t.mat.m[3][1] = pCar->car_master_actor->t.t.mat.m[3][1] - 1000.0f;
299
            pCar->car_master_actor->t.t.mat.m[3][2] = pCar->car_master_actor->t.t.mat.m[3][2] - 1000.0f;
300
            pCar->old_frame_mat.m[3][0] = pCar->car_master_actor->t.t.mat.m[3][0];
301
            pCar->old_frame_mat.m[3][1] = pCar->car_master_actor->t.t.mat.m[3][1];
302
            pCar->old_frame_mat.m[3][2] = pCar->car_master_actor->t.t.mat.m[3][2];
303
        }
304
    }
305
}
306
 
307
// IDA: void __usercall DoNetworkHeadups(int pCredits@<EAX>)
308
void DoNetworkHeadups(int pCredits) {
309
    char s[256];
310
    char s2[256];
311
    static tU32 last_flash;
312
    static int flash_state;
313
    LOG_TRACE("(%d)", pCredits);
314
 
315
    if (gNot_shown_race_type_headup) {
316
        gNot_shown_race_type_headup = 0;
21 pmbaty 317
        NewTextHeadupSlot(eHeadupSlot_misc, 0, 2000, -4, GetMiscString(kMiscString_NetworkGameTypeNames_START + gCurrent_net_game->type));
1 pmbaty 318
    }
319
    if (gTime_for_punishment && gTime_for_punishment <= (tU32) PDGetTotalTime()) { // Pierre-Marie Baty -- added type cast
320
        gTime_for_punishment = 0;
321
        switch (gCurrent_net_game->type) {
322
        case eNet_game_type_carnage:
21 pmbaty 323
            NewTextHeadupSlot(eHeadupSlot_misc, 0, 2000, -4, GetMiscString(kMiscString_THAT_HALVED_YOUR_KILL_COUNT));
1 pmbaty 324
            break;
325
        case eNet_game_type_checkpoint:
21 pmbaty 326
            NewTextHeadupSlot(eHeadupSlot_misc, 0, 2000, -4, GetMiscString(kMiscString_THAT_LOST_YOU_A_CHECKPOINT));
1 pmbaty 327
            break;
328
        case eNet_game_type_sudden_death:
21 pmbaty 329
            NewTextHeadupSlot(eHeadupSlot_misc, 0, 2000, -4, GetMiscString(kMiscString_BACK_TO_THE_START));
1 pmbaty 330
            break;
331
        case eNet_game_type_foxy:
21 pmbaty 332
            NewTextHeadupSlot(eHeadupSlot_misc, 0, 2000, -4, GetMiscString(kMiscString_THAT_HALVED_YOUR_TIME));
1 pmbaty 333
            break;
334
        default:
335
            break;
336
        }
337
    }
338
    if (gNet_mode == eNet_mode_none || gNet_recovery_cost[gCurrent_net_game->type] <= gProgram_state.credits_earned - gProgram_state.credits_lost || Flash(200, &last_flash, &flash_state)) {
339
        sprintf(s, "\xf8%d\xfa %s", pCredits, GetMiscString(kMiscString_CREDITS));
340
        ChangeHeadupText(gNet_cash_headup, s);
341
    } else {
342
        ChangeHeadupText(gNet_cash_headup, "");
343
    }
344
    switch (gCurrent_net_game->type) {
345
    case eNet_game_type_carnage:
346
        sprintf(s, "%s \xf8%d\xfa", GetMiscString(kMiscString_TARGET_180), gPed_target);
347
        break;
348
    case eNet_game_type_car_crusher:
349
        sprintf(s, "%s \xf8%d\xfa", GetMiscString(kMiscString_TARGET_181), gCurrent_net_game->options.race_end_target);
350
        break;
351
    case eNet_game_type_foxy:
352
        TimerString(gCurrent_net_game->options.race_end_target, s2, 1, 1);
353
        sprintf(s, "%s \xf8%s\xfa", GetMiscString(kMiscString_TARGET_182), s2);
354
        break;
355
    case eNet_game_type_tag:
356
        TimerString(gCurrent_net_game->options.race_end_target, s2, 1, 1);
357
        sprintf(s, "%s \xf8%s\xfa", GetMiscString(kMiscString_LIMIT), s2);
358
        break;
359
    default:
360
        s[0] = '\0';
361
        break;
362
    }
363
    ChangeHeadupText(gNet_ped_headup, s);
364
}
365
 
366
// IDA: int __usercall SortNetHeadAscending@<EAX>(void *pFirst_one@<EAX>, void *pSecond_one@<EDX>)
367
int SortNetHeadAscending(void* pFirst_one, void* pSecond_one) {
368
    LOG_TRACE("(%p, %p)", pFirst_one, pSecond_one);
20 pmbaty 369
    NOT_IMPLEMENTED();
1 pmbaty 370
}
371
 
372
// IDA: int __usercall SortNetHeadDescending@<EAX>(void *pFirst_one@<EAX>, void *pSecond_one@<EDX>)
373
int SortNetHeadDescending(void* pFirst_one, void* pSecond_one) {
374
    LOG_TRACE("(%p, %p)", pFirst_one, pSecond_one);
20 pmbaty 375
    NOT_IMPLEMENTED();
1 pmbaty 376
}
377
 
378
// IDA: void __usercall ClipName(char *pName@<EAX>, tDR_font *pFont@<EDX>, int pMax_width@<EBX>)
379
void ClipName(char* pName, tDR_font* pFont, int pMax_width) {
380
    LOG_TRACE("(\"%s\", %p, %d)", pName, pFont, pMax_width);
20 pmbaty 381
    NOT_IMPLEMENTED();
1 pmbaty 382
}
383
 
384
// IDA: void __usercall DoNetScores2(int pOnly_sort_scores@<EAX>)
385
void DoNetScores2(int pOnly_sort_scores) {
20 pmbaty 386
    //int i; // Pierre-Marie Baty -- unused variable
387
    //int j; // Pierre-Marie Baty -- unused variable
388
    //int score; // Pierre-Marie Baty -- unused variable
389
    //int flags; // Pierre-Marie Baty -- unused variable
390
    //int index; // Pierre-Marie Baty -- unused variable
391
    //int right_edge; // Pierre-Marie Baty -- unused variable
392
    //int x; // Pierre-Marie Baty -- unused variable
393
    //int len; // Pierre-Marie Baty -- unused variable
394
    //int ascending_order; // Pierre-Marie Baty -- unused variable
395
    //char s[256]; // Pierre-Marie Baty -- unused variable
396
    //static tU32 last_flash; // Pierre-Marie Baty -- unused variable
397
    //static int flash_state; // Pierre-Marie Baty -- unused variable
398
    //tHeadup_pair headup_pairs[6]; // Pierre-Marie Baty -- unused variable
1 pmbaty 399
    LOG_TRACE("(%d)", pOnly_sort_scores);
20 pmbaty 400
    NOT_IMPLEMENTED();
1 pmbaty 401
}
402
 
403
// IDA: void __cdecl DoNetScores()
404
void DoNetScores(void) {
405
    LOG_TRACE("()");
20 pmbaty 406
    NOT_IMPLEMENTED();
1 pmbaty 407
}
408
 
409
// IDA: void __cdecl InitNetHeadups()
410
void InitNetHeadups(void) {
411
    LOG_TRACE("()");
412
 
413
    gIcons_pix = LoadPixelmap("CARICONS.PIX");
414
    if (gIcons_pix != NULL) {
415
        BrMapAdd(gIcons_pix);
416
    }
417
    gDigits_pix = LoadPixelmap("HDIGITS.PIX");
418
    if (gDigits_pix != NULL) {
419
        BrMapAdd(gDigits_pix);
420
    }
421
    /* The Windows version does not use gIcons_pix_low_res. */
422
    if (gGraf_data_index != 0) {
423
        SwitchToLoresMode();
424
        gIcons_pix_low_res = LoadPixelmap("CARICONS.PIX");
425
        SwitchToRealResolution();
426
    } else {
427
        gIcons_pix_low_res = gIcons_pix;
428
    }
429
}
430
 
431
// IDA: void __cdecl DisposeNetHeadups()
432
void DisposeNetHeadups(void) {
433
    LOG_TRACE("()");
434
 
435
    /* Windows version does not use gIcons_pix_low_res. */
436
    if (gIcons_pix_low_res != NULL && gIcons_pix_low_res != gIcons_pix) {
437
        BrPixelmapFree(gIcons_pix_low_res);
438
    }
439
 
440
    if (gIcons_pix != NULL) {
441
        BrMapRemove(gIcons_pix);
442
        BrPixelmapFree(gIcons_pix);
443
    }
444
    if (gDigits_pix != NULL) {
445
        BrMapRemove(gDigits_pix);
446
        BrPixelmapFree(gDigits_pix);
447
    }
448
}
449
 
450
// IDA: void __cdecl EverybodysLost()
451
void EverybodysLost(void) {
20 pmbaty 452
    //tNet_message* the_message; // Pierre-Marie Baty -- unused variable
453
    //int i; // Pierre-Marie Baty -- unused variable
1 pmbaty 454
    LOG_TRACE("()");
20 pmbaty 455
    NOT_IMPLEMENTED();
1 pmbaty 456
}
457
 
458
// IDA: void __usercall DeclareWinner(int pWinner_index@<EAX>)
459
void DeclareWinner(int pWinner_index) {
20 pmbaty 460
    //tNet_message* the_message; // Pierre-Marie Baty -- unused variable
461
    //int i; // Pierre-Marie Baty -- unused variable
462
    //int j; // Pierre-Marie Baty -- unused variable
463
    //int best_score_index; // Pierre-Marie Baty -- unused variable
464
    //char s[256]; // Pierre-Marie Baty -- unused variable
1 pmbaty 465
    LOG_TRACE("(%d)", pWinner_index);
20 pmbaty 466
    NOT_IMPLEMENTED();
1 pmbaty 467
}
468
 
469
// IDA: void __usercall PlayerIsIt(tNet_game_player_info *pPlayer@<EAX>)
470
void PlayerIsIt(tNet_game_player_info* pPlayer) {
20 pmbaty 471
    //int i; // Pierre-Marie Baty -- unused variable
472
    //char s[256]; // Pierre-Marie Baty -- unused variable
1 pmbaty 473
    LOG_TRACE("(%p)", pPlayer);
20 pmbaty 474
    NOT_IMPLEMENTED();
1 pmbaty 475
}
476
 
477
// IDA: int __usercall FarEnoughAway@<EAX>(tNet_game_player_info *pPlayer_1@<EAX>, tNet_game_player_info *pPlayer_2@<EDX>)
478
int FarEnoughAway(tNet_game_player_info* pPlayer_1, tNet_game_player_info* pPlayer_2) {
20 pmbaty 479
    //br_vector3 difference; // Pierre-Marie Baty -- unused variable
1 pmbaty 480
    LOG_TRACE("(%p, %p)", pPlayer_1, pPlayer_2);
20 pmbaty 481
    NOT_IMPLEMENTED();
1 pmbaty 482
}
483
 
484
// IDA: void __usercall CarInContactWithItOrFox(tNet_game_player_info *pPlayer@<EAX>)
485
void CarInContactWithItOrFox(tNet_game_player_info* pPlayer) {
486
    LOG_TRACE("(%p)", pPlayer);
20 pmbaty 487
    NOT_IMPLEMENTED();
1 pmbaty 488
}
489
 
490
// IDA: void __usercall SelectRandomItOrFox(int pNot_this_one@<EAX>)
491
void SelectRandomItOrFox(int pNot_this_one) {
20 pmbaty 492
    //int i; // Pierre-Marie Baty -- unused variable
493
    //int new_choice; // Pierre-Marie Baty -- unused variable
1 pmbaty 494
    LOG_TRACE("(%d)", pNot_this_one);
20 pmbaty 495
    NOT_IMPLEMENTED();
1 pmbaty 496
}
497
 
498
// IDA: void __cdecl CalcPlayerScores()
499
void CalcPlayerScores(void) {
20 pmbaty 500
    //int i; // Pierre-Marie Baty -- unused variable
501
    //int j; // Pierre-Marie Baty -- unused variable
502
    //int knock_out_bit; // Pierre-Marie Baty -- unused variable
503
    //int e_dam; // Pierre-Marie Baty -- unused variable
504
    //int t_dam; // Pierre-Marie Baty -- unused variable
505
    //int d_dam; // Pierre-Marie Baty -- unused variable
506
    //int w_dam; // Pierre-Marie Baty -- unused variable
507
    //int cars_left; // Pierre-Marie Baty -- unused variable
508
    //int car_left; // Pierre-Marie Baty -- unused variable
509
    //int flags; // Pierre-Marie Baty -- unused variable
510
    //int score; // Pierre-Marie Baty -- unused variable
511
    //int highest; // Pierre-Marie Baty -- unused variable
512
    //int next_highest; // Pierre-Marie Baty -- unused variable
513
    //int lowest_score; // Pierre-Marie Baty -- unused variable
514
    //int player_left; // Pierre-Marie Baty -- unused variable
515
    //int new_choice; // Pierre-Marie Baty -- unused variable
516
    //tCar_spec* car; // Pierre-Marie Baty -- unused variable
517
    //tNet_message* message; // Pierre-Marie Baty -- unused variable
518
    //tS32 time; // Pierre-Marie Baty -- unused variable
519
    //char s[256]; // Pierre-Marie Baty -- unused variable
520
    //tNet_game_player_info* lowest_score_player; // Pierre-Marie Baty -- unused variable
1 pmbaty 521
    LOG_TRACE("()");
20 pmbaty 522
    NOT_IMPLEMENTED();
1 pmbaty 523
}
524
 
525
// IDA: void __cdecl SendPlayerScores()
526
void SendPlayerScores(void) {
527
    tNet_contents* the_contents;
528
    int i;
529
    LOG_TRACE("()");
530
 
531
    the_contents = NetGetBroadcastContents(NETMSGID_SCORES, 0);
532
    if (gCurrent_net_game->type == eNet_game_type_carnage) {
533
        the_contents->data.scores.general_score = gPed_target;
534
    } else if (gCurrent_net_game->type == eNet_game_type_tag || gCurrent_net_game->type == eNet_game_type_foxy) {
535
        the_contents->data.scores.general_score = gNet_players[gIt_or_fox].ID;
536
    }
537
    for (i = 0; i < gNumber_of_net_players; i++) {
538
        the_contents->data.scores.scores[i] = gNet_players[i].score;
539
    }
540
}
541
 
542
// IDA: void __cdecl DoNetGameManagement()
543
void DoNetGameManagement(void) {
544
    LOG_TRACE("()");
545
 
546
    if (gNet_mode == eNet_mode_host) {
547
        CalcPlayerScores();
548
        SendPlayerScores();
549
    }
550
}
551
 
552
// IDA: void __usercall InitialisePlayerScore(tNet_game_player_info *pPlayer@<EAX>)
553
void InitialisePlayerScore(tNet_game_player_info* pPlayer) {
554
    LOG_TRACE("(%p)", pPlayer);
555
 
556
    PossibleService();
557
    switch (gCurrent_net_game->type) {
558
    case eNet_game_type_fight_to_death:
559
        pPlayer->score = 100;
560
        break;
561
    case eNet_game_type_car_crusher:
562
    case eNet_game_type_carnage:
563
        pPlayer->score = 0;
564
        break;
565
    case eNet_game_type_checkpoint:
566
        pPlayer->score = 0xffff;
567
        break;
568
    case eNet_game_type_sudden_death:
569
        pPlayer->score = 0;
570
        break;
571
    case eNet_game_type_tag:
572
        pPlayer->score = 0;
573
        break;
574
    case eNet_game_type_foxy:
575
        pPlayer->score = 0;
576
        break;
577
    default:
578
        TELL_ME_IF_WE_PASS_THIS_WAY();
579
    }
580
    pPlayer->credits = gInitial_net_credits[gCurrent_net_game->options.starting_money_index];
581
    pPlayer->wasted = 0;
582
    pPlayer->reposition_time = 0;
583
}
584
 
585
// IDA: void __cdecl InitPlayers()
586
void InitPlayers(void) {
587
    int i;
588
    LOG_TRACE("()");
589
 
590
    for (i = 0; i < gNumber_of_net_players; i++) {
591
        InitialisePlayerScore(&gNet_players[i]);
592
    }
593
    if (gNet_mode == eNet_mode_host) {
594
        gLast_it_change = 0;
595
        gLast_lepper = NULL;
596
    }
597
    gTime_for_punishment = 0;
598
    gNot_shown_race_type_headup = 1;
599
    gIt_or_fox = -1;
600
}
601
 
602
// IDA: void __usercall BuyPSPowerup(int pIndex@<EAX>)
603
void BuyPSPowerup(int pIndex) {
604
    char s[256];
605
    char s2[256];
606
    LOG_TRACE("(%d)", pIndex);
607
 
608
    if (gNet_mode == eNet_mode_none) {
21 pmbaty 609
        NewTextHeadupSlot(eHeadupSlot_misc, 0, 3000, -4, GetMiscString(kMiscString_ONLY_AVAILABLE_IN_NET_GAMES));
1 pmbaty 610
    } else if (gProgram_state.current_car.power_up_levels[pIndex] < 4) {
611
        if (gNet_mode == eNet_mode_none || gPowerup_cost[gProgram_state.current_car.power_up_levels[pIndex]] <= (gProgram_state.credits_earned - gProgram_state.credits_lost)) {
612
            SpendCredits(gPowerup_cost[gProgram_state.current_car.power_up_levels[pIndex]]);
613
            ImprovePSPowerup(&gProgram_state.current_car, pIndex);
614
        } else {
615
            strcpy(s, GetMiscString(kMiscString_CANNOT_AFFORD_IT));
616
            sprintf(s2, "%d", gPowerup_cost[gProgram_state.current_car.power_up_levels[pIndex]]);
617
            SubsStringJob(s, s2);
21 pmbaty 618
            NewTextHeadupSlot(eHeadupSlot_misc, 0, 3008, -4, s);
1 pmbaty 619
        }
620
    } else {
21 pmbaty 621
        NewTextHeadupSlot(eHeadupSlot_misc, 0, 3000, -4, GetMiscString(kMiscString_YOU_ARE_ALREADY_AT_MAX));
1 pmbaty 622
    }
623
}
624
 
625
// IDA: void __cdecl BuyArmour()
626
void BuyArmour(void) {
627
    LOG_TRACE("()");
628
 
629
    BuyPSPowerup(0);
630
}
631
 
632
// IDA: void __cdecl BuyPower()
633
void BuyPower(void) {
634
    LOG_TRACE("()");
635
 
636
    if (gNet_mode != eNet_mode_none && gCurrent_net_game->type == eNet_game_type_foxy && gThis_net_player_index == gIt_or_fox) {
21 pmbaty 637
        NewTextHeadupSlot(eHeadupSlot_misc, 0, 1000, -4, GetMiscString(kMiscString_THE_FOX_CANNOT_DO_THAT));
1 pmbaty 638
    } else if (gNet_mode != eNet_mode_none && gCurrent_net_game->type == eNet_game_type_tag && gThis_net_player_index != gIt_or_fox) {
21 pmbaty 639
        NewTextHeadupSlot(eHeadupSlot_misc, 0, 1000, -4, GetMiscString(kMiscString_ONLY_IT_CAN_DO_THAT));
1 pmbaty 640
    } else {
641
        BuyPSPowerup(1);
642
    }
643
}
644
 
645
// IDA: void __cdecl BuyOffense()
646
void BuyOffense(void) {
647
    LOG_TRACE("()");
648
 
649
    BuyPSPowerup(2);
650
}
651
 
652
// IDA: void __usercall UseGeneralScore(int pScore@<EAX>)
653
void UseGeneralScore(int pScore) {
20 pmbaty 654
    //int i; // Pierre-Marie Baty -- unused variable
1 pmbaty 655
    LOG_TRACE("(%d)", pScore);
20 pmbaty 656
    NOT_IMPLEMENTED();
1 pmbaty 657
}
658
 
659
// IDA: void __usercall NetSendEnvironmentChanges(tNet_game_player_info *pPlayer@<EAX>)
660
void NetSendEnvironmentChanges(tNet_game_player_info* pPlayer) {
661
    LOG_TRACE("(%p)", pPlayer);
662
 
663
    SendAllPedestrianPositions(pPlayer->ID);
664
    SendAllNonCarPositions();
665
}
666
 
667
// IDA: void __cdecl UpdateEnvironments()
668
void UpdateEnvironments(void) {
669
    int i;
670
    LOG_TRACE("()");
671
 
672
    for (i = 1; i < gNumber_of_net_players; i++) {
673
        if (!gNet_players[i].race_stuff_initialised) {
674
            NetSendEnvironmentChanges(&gNet_players[i]);
675
            gNet_players[i].race_stuff_initialised = 1;
676
        }
677
        NetSendMessageStacks();
678
        SendGameplay(gNet_players[i].ID, eNet_gameplay_go_for_it, 0, 0, 0, 0);
679
    }
680
}
681
 
682
// IDA: void __usercall ReceivedGameplay(tNet_contents *pContents@<EAX>, tNet_message *pMessage@<EDX>, tU32 pReceive_time@<EBX>)
683
void ReceivedGameplay(tNet_contents* pContents, tNet_message* pMessage, tU32 pReceive_time) {
20 pmbaty 684
    //int must_revert_reentrancy; // Pierre-Marie Baty -- unused variable
685
    //int gPixel_buffer_size; // Pierre-Marie Baty -- unused variable
686
    //char* gPixels_copy; // Pierre-Marie Baty -- unused variable
687
    //char* gPalette_copy; // Pierre-Marie Baty -- unused variable
688
    //static int pause_semaphore; // Pierre-Marie Baty -- unused variable
1 pmbaty 689
    LOG_TRACE("(%p, %p, %d)", pContents, pMessage, pReceive_time);
20 pmbaty 690
    NOT_IMPLEMENTED();
1 pmbaty 691
}
692
 
693
// IDA: void __usercall SendGameplay(tPlayer_ID pPlayer@<EAX>, tNet_gameplay_mess pMess@<EDX>, int pParam_1@<EBX>, int pParam_2@<ECX>, int pParam_3, int pParam_4)
694
void SendGameplay(tPlayer_ID pPlayer, tNet_gameplay_mess pMess, int pParam_1, int pParam_2, int pParam_3, int pParam_4) {
695
    tNet_message* the_message;
696
    LOG_TRACE("(%d, %d, %d, %d, %d, %d)", pPlayer, pMess, pParam_1, pParam_2, pParam_3, pParam_4);
697
 
698
    the_message = NetBuildMessage(NETMSGID_GAMEPLAY, 0);
699
    the_message->contents.data.gameplay.mess = pMess;
700
    the_message->contents.data.gameplay.param_1 = pParam_1;
701
    the_message->contents.data.gameplay.param_2 = pParam_2;
702
    the_message->contents.data.gameplay.param_3 = pParam_3;
703
    the_message->contents.data.gameplay.param_4 = pParam_4;
704
    NetGuaranteedSendMessageToPlayer(gCurrent_net_game, the_message, pPlayer, 0);
705
}
706
 
707
// IDA: void __usercall SendGameplayToAllPlayers(tNet_gameplay_mess pMess@<EAX>, int pParam_1@<EDX>, int pParam_2@<EBX>, int pParam_3@<ECX>, int pParam_4)
708
void SendGameplayToAllPlayers(tNet_gameplay_mess pMess, int pParam_1, int pParam_2, int pParam_3, int pParam_4) {
709
    tNet_message* the_message;
710
    LOG_TRACE("(%d, %d, %d, %d, %d)", pMess, pParam_1, pParam_2, pParam_3, pParam_4);
711
 
712
    the_message = NetBuildMessage(NETMSGID_GAMEPLAY, 0);
713
    the_message->contents.data.gameplay.mess = pMess;
714
    the_message->contents.data.gameplay.param_1 = pParam_1;
715
    the_message->contents.data.gameplay.param_2 = pParam_2;
716
    the_message->contents.data.gameplay.param_3 = pParam_3;
717
    the_message->contents.data.gameplay.param_4 = pParam_4;
718
    NetGuaranteedSendMessageToAllPlayers(gCurrent_net_game, the_message, NULL);
719
}
720
 
721
// IDA: void __usercall SendGameplayToHost(tNet_gameplay_mess pMess@<EAX>, int pParam_1@<EDX>, int pParam_2@<EBX>, int pParam_3@<ECX>, int pParam_4)
722
void SendGameplayToHost(tNet_gameplay_mess pMess, int pParam_1, int pParam_2, int pParam_3, int pParam_4) {
20 pmbaty 723
    //tNet_message* the_message; // Pierre-Marie Baty -- unused variable
1 pmbaty 724
    LOG_TRACE("(%d, %d, %d, %d, %d)", pMess, pParam_1, pParam_2, pParam_3, pParam_4);
20 pmbaty 725
    NOT_IMPLEMENTED();
1 pmbaty 726
}
727
 
728
// IDA: void __cdecl InitNetGameplayStuff()
729
void InitNetGameplayStuff(void) {
730
    LOG_TRACE("()");
731
}
732
 
733
// IDA: void __cdecl DefaultNetName()
734
void DefaultNetName(void) {
735
    NetObtainSystemUserName(gNet_player_name, 32);
736
}
737
 
738
// IDA: void __usercall NetSendPointCrush(tCar_spec *pCar@<EAX>, tU16 pCrush_point_index@<EDX>, br_vector3 *pEnergy_vector@<EBX>)
739
void NetSendPointCrush(tCar_spec* pCar, tU16 pCrush_point_index, br_vector3* pEnergy_vector) {
20 pmbaty 740
    //tNet_contents* contents; // Pierre-Marie Baty -- unused variable
1 pmbaty 741
    LOG_TRACE("(%p, %d, %p)", pCar, pCrush_point_index, pEnergy_vector);
742
 
20 pmbaty 743
    STUB_ONCE();
1 pmbaty 744
}
745
 
746
// IDA: void __usercall RecievedCrushPoint(tNet_contents *pContents@<EAX>)
747
void RecievedCrushPoint(tNet_contents* pContents) {
20 pmbaty 748
    //tCar_spec* car; // Pierre-Marie Baty -- unused variable
1 pmbaty 749
    LOG_TRACE("(%p)", pContents);
20 pmbaty 750
    NOT_IMPLEMENTED();
1 pmbaty 751
}
752
 
753
// IDA: void __usercall GetReducedMatrix(tReduced_matrix *m1@<EAX>, br_matrix34 *m2@<EDX>)
754
void GetReducedMatrix(tReduced_matrix* m1, br_matrix34* m2) {
755
    LOG_TRACE("(%p, %p)", m1, m2);
20 pmbaty 756
    NOT_IMPLEMENTED();
1 pmbaty 757
}
758
 
759
// IDA: void __usercall GetExpandedMatrix(br_matrix34 *m1@<EAX>, tReduced_matrix *m2@<EDX>)
760
void GetExpandedMatrix(br_matrix34* m1, tReduced_matrix* m2) {
761
    LOG_TRACE("(%p, %p)", m1, m2);
20 pmbaty 762
    NOT_IMPLEMENTED();
1 pmbaty 763
}
764
 
765
// IDA: void __usercall NetEarnCredits(tNet_game_player_info *pPlayer@<EAX>, tS32 pCredits@<EDX>)
766
void NetEarnCredits(tNet_game_player_info* pPlayer, tS32 pCredits) {
767
    LOG_TRACE("(%p, %d)", pPlayer, pCredits);
20 pmbaty 768
    NOT_IMPLEMENTED();
1 pmbaty 769
}