Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement network #366

Merged
merged 44 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
cff3ca5
SendCarData, ReceivedStartRace
dethrace-labs Jul 6, 2023
60356fc
fixes heap overflow during join
dethrace-labs Jul 6, 2023
b0c21e7
fixes access on possibly-null pDetails
dethrace-labs Jul 6, 2023
e25bbd8
DoNetScores
dethrace-labs Jul 6, 2023
c3dcf53
Fix cast warning of comparefn of qsort
madebr Jul 6, 2023
af5c05c
DisplayUserMessage
dethrace-labs Jul 6, 2023
ab60510
Merge branch 'networking_start_race' of https://github.com/dethrace-l…
dethrace-labs Jul 6, 2023
1ba4066
Pack tNet_contents on 4 byte boundary so 32-bit and 64-bit Intel cpu …
madebr Jul 7, 2023
31cb9d5
Add a few static assertions to verify net message offsets
madebr Jul 7, 2023
3fcf165
Add dethrace Wireshark dissector (WIP)
madebr Jul 7, 2023
c0f87de
add dissector installation instructions
madebr Jul 7, 2023
c05de23
Set wireshark info column
madebr Jul 7, 2023
b96c012
Fix various typo's
madebr Jul 7, 2023
fc07e7d
4-byte align tNet_message_join as well + more dethrace.lua
madebr Jul 7, 2023
78919fd
Add more assertions
madebr Jul 7, 2023
11c81f4
Fix network car choose loop
madebr Jul 7, 2023
e0425d9
player scores
dethrace-labs Jul 9, 2023
032fa8d
tidy
dethrace-labs Jul 9, 2023
25f4401
mechanics
dethrace-labs Jul 9, 2023
6fcf8f0
Implement SortNetHeadAscending for 'Terminal Tag'
madebr Jul 9, 2023
a4d3a4c
Update WireShark dissector
madebr Jul 14, 2023
6867fee
start of tNet_message_pedestrian dissector
madebr Jul 14, 2023
707973a
network player cars can see each other move
dethrace-labs Jul 15, 2023
4a638c6
netmsgid tidy ups
dethrace-labs Jul 15, 2023
ca7b84d
dissector: print HOST/CLIENT in info column
madebr Jul 16, 2023
a6e859a
Don't allow hosting a game when starting dethrace with --no-bind
madebr Jul 22, 2023
7fc9924
fix oldd copy
dethrace-labs Jul 27, 2023
523ef3d
time_step is integer, fixes client car out of sync
dethrace-labs Jul 27, 2023
c85a991
wasted, recover, kick player out
dethrace-labs Jul 30, 2023
63a7180
NetSendPointCrush
dethrace-labs Aug 6, 2023
6349a45
Merge branch 'main' of https://github.com/dethrace-labs/dethrace into…
dethrace-labs Aug 9, 2023
2f8b81a
crushpoint, declarewinner
dethrace-labs Aug 21, 2023
9c43627
network race summary wip
dethrace-labs Sep 17, 2023
672f472
Merge remote-tracking branch 'origin/main' into HEAD
madebr Jun 9, 2024
c6010a2
Start and finish a game of tag/fox
madebr Jun 10, 2024
84beab3
network fixes
madebr Jun 10, 2024
f512abc
Players can now send love letters to each other
madebr Jun 10, 2024
84f7de4
Rewrite if's a bit
madebr Jun 12, 2024
e1a602f
Use enum values for GetMiscString and DoFancyHeadup
madebr Jun 12, 2024
e179309
Merge remote-tracking branch 'origin/main' into HEAD
madebr Jun 14, 2024
a498a4c
Fix fox effect
madebr Jun 13, 2024
8836cc5
Fix fox/it effect at start of race
madebr Jun 14, 2024
44ec100
Use KEYMAP_ enum values
madebr Jun 19, 2024
7c765ae
Disable address sanitizer and dr_dprintf logging
madebr Jun 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 41 additions & 1 deletion src/DETHRACE/common/car.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "skidmark.h"
#include "sound.h"
#include "spark.h"
#include "structur.h"
#include "trig.h"
#include "utility.h"
#include "world.h"
Expand Down Expand Up @@ -4579,7 +4580,46 @@ void AmIGettingBoredWatchingCameraSpin(void) {
char s[256];
LOG_TRACE("()");

STUB_ONCE();
if (gNet_mode == eNet_mode_none
|| (gCurrent_net_game->type != eNet_game_type_sudden_death
&& gCurrent_net_game->type != eNet_game_type_tag
&& gCurrent_net_game->type != eNet_game_type_fight_to_death)) {
gOpponent_viewing_mode = 0;
} else if (!gRace_finished) {
time_of_death = 0;
gOpponent_viewing_mode = 0;
} else if (time_of_death == 0) {
time_of_death = GetRaceTime();
} else {
if (GetRaceTime() >= time_of_death + 10000) {
if (gOpponent_viewing_mode == 0) {
gOpponent_viewing_mode = 1;
gNet_player_to_view_index = -2;
ViewNetPlayer();
}
if (gNet_player_to_view_index >= gNumber_of_net_players) {
gNet_player_to_view_index = -2;
ViewNetPlayer();
}
if (gNet_player_to_view_index < 0 && gCar_to_view != GetRaceLeader()) {
gNet_player_to_view_index = -2;
ViewNetPlayer();
}
if ((GetRaceTime() > headup_timer + 1000 || headup_timer > GetRaceTime()) && gRace_over_reason == eRace_not_over_yet) {
strcpy(s, GetMiscString(kMiscString_WATCHING));
strcat(s, " ");
if (gNet_player_to_view_index >= 0) {
strcat(s, gNet_players[gNet_player_to_view_index].player_name);
} else if (gCurrent_net_game->type == eNet_game_type_tag) {
strcat(s, GetMiscString(kMiscString_QUOTE_IT_QUOTE));
} else {
strcat(s, GetMiscString(kMiscString_RACE_LEADER));
}
headup_timer = GetRaceTime();
NewTextHeadupSlot(6, 0, 500, -4, s);
}
}
}
}

// IDA: void __cdecl ViewNetPlayer()
Expand Down
116 changes: 114 additions & 2 deletions src/DETHRACE/common/controls.c
Original file line number Diff line number Diff line change
Expand Up @@ -1282,7 +1282,27 @@ void CheckHornLocal(tCar_spec* pCar) {
// IDA: void __usercall CheckHorn3D(tCar_spec *pCar@<EAX>)
void CheckHorn3D(tCar_spec* pCar) {
LOG_TRACE("(%p)", pCar);
STUB_ONCE();

if (pCar->keys.horn && pCar->horn_sound_tag == 0) {
pCar->horn_sound_tag = DRS3StartSound3D(gEffects_outlet,
5209,
&pCar->car_master_actor->t.t.translate.t,
&pCar->velocity_bu_per_sec,
0,
255,
((pCar->car_ID & 7) << 12) + 0xc000,
0x10000);
} else {
if (!pCar->keys.horn && pCar->horn_sound_tag != 0) {
while (S3SoundStillPlaying(pCar->horn_sound_tag)) {
DRS3StopSound(pCar->horn_sound_tag);
DRS3StopOutletSound(gEffects_outlet);
}
if (!S3SoundStillPlaying(pCar->horn_sound_tag)) {
pCar->horn_sound_tag = 0;
}
}
}
}

// IDA: void __cdecl CheckHorns()
Expand Down Expand Up @@ -2479,7 +2499,99 @@ void EnterUserMessage(void) {
int the_key;
int abuse_num;
LOG_TRACE("()");
STUB_ONCE();

if (!gEntering_message) {
return;
}
if (gNet_mode == eNet_mode_none) {
return;
}
if (!gCurrent_net_game->options.enable_text_messages) {
return;
}
the_key = PDAnyKeyDown();
if (gEntering_message == 1) {
if (the_key != -1) {
return;
}
gEntering_message = 2;
}
if (about_to_die) {
if (the_key != -1) {
return;
}
gEntering_message = 0;
about_to_die = 0;
return;
}
if (the_key == last_key) {
if (next_time < PDGetTotalTime()) {
next_time += 100;
} else {
the_key = -1;
}
} else {
last_key = the_key;
next_time = PDGetTotalTime() + 500;
}
switch (the_key) {
case -1:
case KEY_SHIFT_ANY:
break;
case KEY_CTRL_ANY:
case KEY_CTRL_ANY_2:
case KEY_TAB:
case KEY_ESCAPE:
about_to_die = 1;
break;
case KEY_BACKSPACE:
case KEY_DELETE:
case KEY_LEFT:
len = strlen(&gString[20]);
if (len > 0) {
gString[20 + len - 1] = '\0';
}
break;
case KEY_RETURN:
case KEY_KP_ENTER:
len = strlen(gNet_players[gThis_net_player_index].player_name);
if (len <= 18) {
the_message = gString + 18 - len;
strcpy(the_message, gNet_players[gThis_net_player_index].player_name);
the_message[len + 0] = ':';
the_message[len + 1] = ' ';
gString[COUNT_OF(gString) - 1] = '\0';
NetSendHeadupToAllPlayers(the_message);
gString[20] = '\0';
NewTextHeadupSlot(4, 0, 1000, -4, GetMiscString(kMiscString_MESSAGE_SENT));
about_to_die = 1;
}
break;
default:
if (gKey_mapping[66] == the_key) {
madebr marked this conversation as resolved.
Show resolved Hide resolved
about_to_die = 1;
} else if (the_key <= KEY_KP_NUMLOCK || the_key >= KEY_SPACE) {
len = strlen(&gString[20]);
if (len < 64 - 1) {
gString[20 + len] = PDGetASCIIFromKey(the_key);
if (gString[20 + len] < gFonts[4].offset || gString[20 + len] >= gFonts[4].offset + gFonts[4].num_entries) {
gString[20 + len] = '\0';
}
gString[20 + len + 1] = '\0';
}
} else if (the_key < KEY_KP_0 || the_key > KEY_KP_9) {
gEntering_message = 0;
} else {
if (the_key == KEY_KP_0) {
abuse_num = 9;
} else {
abuse_num = the_key - KEY_KP_1;
}
if (gAbuse_text[abuse_num] != NULL) {
strcpy(&gString[20], gAbuse_text[abuse_num]);
}
}
}
}

// IDA: void __cdecl DisplayUserMessage()
Expand Down
24 changes: 23 additions & 1 deletion src/DETHRACE/common/crush.c
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,29 @@ void DoPratcamHit(br_vector3* pHit_vector) {
br_scalar strength;
LOG_TRACE("(%p)", pHit_vector);

STUB_ONCE();
strength = BrVector3LengthSquared(pHit_vector);
if (strength > 0.2f) {
strength_modifier = 8;
} else if (strength > 0.015f) {
strength_modifier = 4;
} else if (strength >= 0.001f) {
strength_modifier = 0;
} else {
return;
}
if (fabsf(pHit_vector->v[2]) >= fabsf(pHit_vector->v[0])) {
if (pHit_vector->v[2] >= 0.f) {
PratcamEvent(14 + strength_modifier);
} else {
PratcamEvent(13 + strength_modifier);
}
} else {
if (pHit_vector->v[0] >= 0.f) {
PratcamEvent(15 + strength_modifier);
} else {
PratcamEvent(16 + strength_modifier);
}
}
}

// IDA: void __usercall DamageSystems(tCar_spec *pCar@<EAX>, br_vector3 *pImpact_point@<EDX>, br_vector3 *pEnergy_vector@<EBX>, int pWas_hitting_a_car@<ECX>)
Expand Down
6 changes: 5 additions & 1 deletion src/DETHRACE/common/depth.c
Original file line number Diff line number Diff line change
Expand Up @@ -998,7 +998,11 @@ void ChangeDepthEffect(void) {
br_scalar distance;
tSpecial_volume* special_volume;
LOG_TRACE("()");
STUB_ONCE();

gProgram_state.current_depth_effect.type = gProgram_state.default_depth_effect.type;
gProgram_state.current_depth_effect.sky_texture = gProgram_state.default_depth_effect.sky_texture;
gProgram_state.current_depth_effect.start = gProgram_state.default_depth_effect.start;
gProgram_state.current_depth_effect.end = gProgram_state.default_depth_effect.end;
}

// IDA: void __cdecl MungeForwardSky()
Expand Down
6 changes: 5 additions & 1 deletion src/DETHRACE/common/graphics.c
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,11 @@ void InitializePalettes(void) {
void SwitchToPalette(char* pPal_name) {
br_pixelmap* the_palette;
LOG_TRACE("(\"%s\")", pPal_name);
NOT_IMPLEMENTED();

the_palette = BrTableFind(pPal_name);
if (the_palette != NULL) {
DRSetPalette(the_palette);
}
}

// IDA: void __cdecl ClearEntireScreen()
Expand Down