From 2bb322377ebbedfddad4c18b7cf8575e03e7e25b Mon Sep 17 00:00:00 2001 From: terminx Date: Tue, 15 Dec 2009 05:53:15 +0000 Subject: [PATCH] more multiplayer crap git-svn-id: https://svn.eduke32.com/eduke32@1572 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/include/polymost.h | 2 + polymer/eduke32/build/src/mdsprite.c | 2 +- polymer/eduke32/build/src/polymost.c | 4 +- polymer/eduke32/source/actors.c | 6 +- polymer/eduke32/source/duke3d.h | 25 +- .../eduke32/source/enet/include/enet/enet.h | 2 +- .../eduke32/source/enet/include/enet/win32.h | 2 + polymer/eduke32/source/game.c | 312 +++++++++--------- polymer/eduke32/source/gameexec.c | 39 ++- polymer/eduke32/source/gamestructures.c | 48 +-- polymer/eduke32/source/global.c | 2 +- polymer/eduke32/source/osdcmds.c | 31 +- polymer/eduke32/source/player.c | 108 +++--- polymer/eduke32/source/premap.c | 54 +-- polymer/eduke32/source/sector.c | 38 +-- 15 files changed, 343 insertions(+), 332 deletions(-) diff --git a/polymer/eduke32/build/include/polymost.h b/polymer/eduke32/build/include/polymost.h index 702ec2bc4..9b18209e3 100644 --- a/polymer/eduke32/build/include/polymost.h +++ b/polymer/eduke32/build/include/polymost.h @@ -78,6 +78,8 @@ struct cacheitem_t typedef struct cacheitem_t texcacheindex; +#define TEXCACHEMAGIC "QLZ1" + extern texcacheindex *firstcacheindex; extern texcacheindex *curcacheindex; extern texcacheindex *cacheptrs[MAXTILES<<1]; diff --git a/polymer/eduke32/build/src/mdsprite.c b/polymer/eduke32/build/src/mdsprite.c index 886f98053..a94109e05 100644 --- a/polymer/eduke32/build/src/mdsprite.c +++ b/polymer/eduke32/build/src/mdsprite.c @@ -565,7 +565,7 @@ int32_t mdloadskin_trytexcache(char *fn, int32_t len, int32_t pal, char effect, // initprintf("Loading cached skin: %s\n", cachefn); if (Bread(cachefilehandle, head, sizeof(texcacheheader)) < (int32_t)sizeof(texcacheheader)) goto failure; - if (memcmp(head->magic, "PMST", 4)) goto failure; + if (memcmp(head->magic, TEXCACHEMAGIC, 4)) goto failure; head->xdim = B_LITTLE32(head->xdim); head->ydim = B_LITTLE32(head->ydim); diff --git a/polymer/eduke32/build/src/polymost.c b/polymer/eduke32/build/src/polymost.c index 7831da483..e059dc51d 100644 --- a/polymer/eduke32/build/src/polymost.c +++ b/polymer/eduke32/build/src/polymost.c @@ -1294,7 +1294,7 @@ int32_t trytexcache(char *fn, int32_t len, int32_t dameth, char effect, texcache // initprintf("Loading cached tex: %s\n", cachefn); if (Bread(cachefilehandle, head, sizeof(texcacheheader)) < (int32_t)sizeof(texcacheheader)) goto failure; - if (Bmemcmp(head->magic, "PMST", 4)) goto failure; + if (Bmemcmp(head->magic, TEXCACHEMAGIC, 4)) goto failure; head->xdim = B_LITTLE32(head->xdim); head->ydim = B_LITTLE32(head->ydim); head->flags = B_LITTLE32(head->flags); @@ -1359,7 +1359,7 @@ void writexcache(char *fn, int32_t len, int32_t dameth, char effect, texcachehea offset = Blseek(cachefilehandle, 0, BSEEK_CUR); OSD_Printf("Caching %s, offset 0x%x\n", cachefn, offset); - Bmemcpy(head->magic, "PMST", 4); // sizes are set by caller + Bmemcpy(head->magic, TEXCACHEMAGIC, 4); // sizes are set by caller if (glusetexcache == 2) head->flags |= 4; diff --git a/polymer/eduke32/source/actors.c b/polymer/eduke32/source/actors.c index 889056319..41804f0ce 100644 --- a/polymer/eduke32/source/actors.c +++ b/polymer/eduke32/source/actors.c @@ -1072,7 +1072,7 @@ static void G_MovePlayers(void) { s->extra = p->max_player_health; s->cstat = 257; - p->jetpack_amount = 1599; + p->inv_amount[GET_JETPACK] = 1599; } @@ -5175,8 +5175,8 @@ static void G_MoveMisc(void) // STATNUM 5 { if (s->pal == 0 && (krand()&255) < 16 && s->picnum != PUKE) { - if (g_player[p].ps->boot_amount > 0) - g_player[p].ps->boot_amount--; + if (g_player[p].ps->inv_amount[GET_BOOTS] > 0) + g_player[p].ps->inv_amount[GET_BOOTS]--; else { if (!A_CheckSoundPlaying(g_player[p].ps->i,DUKE_LONGTERM_PAIN)) diff --git a/polymer/eduke32/source/duke3d.h b/polymer/eduke32/source/duke3d.h index b54d260dd..998ab5a82 100644 --- a/polymer/eduke32/source/duke3d.h +++ b/polymer/eduke32/source/duke3d.h @@ -238,7 +238,8 @@ enum DukeInventory_t { GET_HEATS, GET_DUMMY2, GET_FIRSTAID, - GET_BOOTS + GET_BOOTS, + GET_MAX }; enum DukeWeapon_t { @@ -429,7 +430,7 @@ extern int32_t fricxv,fricyv; typedef struct { int32_t posx, posy, posz, oposx, oposy, oposz, posxv, posyv, poszv; - int32_t bobposx, bobposy, pyoff, opyoff, horiz, ohoriz, ohorizoff, invdisptime; + int32_t bobposx, bobposy, pyoff, opyoff, invdisptime; int32_t last_pissed_time, truefz, truecz; int32_t player_par, visibility; int32_t bobcounter, weapon_sway; @@ -451,26 +452,25 @@ typedef struct { int16_t sbs, sound_pitch; int16_t ang, oang, angvel, cursectnum, look_ang, last_extra, subweapon; - int16_t ammo_amount[MAX_WEAPONS], wackedbyactor, frag, fraggedself; + int16_t ammo_amount[MAX_WEAPONS], inv_amount[GET_MAX], wackedbyactor, frag, fraggedself; - int16_t curr_weapon, last_weapon, tipincs, horizoff, wantweaponfire; - int16_t holoduke_amount, newowner, hurt_delay, hbomb_hold_delay; + int16_t curr_weapon, last_weapon, tipincs, horiz, horizoff, ohoriz, ohorizoff, wantweaponfire; + int16_t newowner, hurt_delay, hbomb_hold_delay; int16_t jumping_counter, airleft, knee_incs, access_incs; int16_t fta, ftq, access_wallnum, access_spritenum; - int16_t kickback_pic, got_access, weapon_ang, firstaid_amount; + int16_t kickback_pic, got_access, weapon_ang; int16_t somethingonplayer, on_crane, i, one_parallax_sectnum; int16_t over_shoulder_on, random_club_frame, fist_incs; int16_t one_eighty_count, cheat_phase; int16_t dummyplayersprite, extra_extra8, quick_kick, last_quick_kick; - int16_t heat_amount, actorsqu, timebeforeexit, customexitsound; + int16_t actorsqu, timebeforeexit, customexitsound; int16_t weaprecs[16], weapreccnt; int16_t orotscrnang, rotscrnang, dead_flag, show_empty_weapon; // JBF 20031220: added orotscrnang - int16_t scuba_amount, jetpack_amount, steroids_amount, shield_amount; int16_t holoduke_on, pycount, weapon_pos, frag_ps; - int16_t transporter_hold, last_full_weapon, footprintshade, boot_amount; + int16_t transporter_hold, last_full_weapon, footprintshade; char aim_mode, auto_aim, weaponswitch; @@ -663,9 +663,7 @@ extern int16_t BlimpSpawnSprites[15]; #pragma pack(pop) typedef struct { - int16_t got_access, last_extra, shield_amount, curr_weapon, holoduke_on; - int16_t firstaid_amount, steroids_amount, holoduke_amount, jetpack_amount; - int16_t heat_amount, scuba_amount, boot_amount; + int16_t got_access, last_extra, inv_amount[GET_MAX], curr_weapon, holoduke_on; int16_t last_weapon, weapon_pos, kickback_pic; int16_t ammo_amount[MAX_WEAPONS], frag[MAXPLAYERS]; char inven_icon, jetpack_on, heat_on, gotweapon[MAX_WEAPONS]; @@ -1062,7 +1060,8 @@ typedef struct { DukePlayer_t *ps; input_t *sync; - int32_t movefifoend, syncvalhead, myminlag; + int32_t movefifoend, syncvalhead; + int16_t ping, filler; int32_t pcolor, pteam, frags[MAXPLAYERS], wchoice[MAX_WEAPONS]; char vote, gotvote, playerreadyflag, playerquitflag; diff --git a/polymer/eduke32/source/enet/include/enet/enet.h b/polymer/eduke32/source/enet/include/enet/enet.h index cf7b2d078..27427b5ed 100644 --- a/polymer/eduke32/source/enet/include/enet/enet.h +++ b/polymer/eduke32/source/enet/include/enet/enet.h @@ -199,7 +199,7 @@ enum ENET_PEER_TIMEOUT_LIMIT = 32, ENET_PEER_TIMEOUT_MINIMUM = 5000, ENET_PEER_TIMEOUT_MAXIMUM = 30000, - ENET_PEER_PING_INTERVAL = 500, + ENET_PEER_PING_INTERVAL = 150, ENET_PEER_UNSEQUENCED_WINDOWS = 64, ENET_PEER_UNSEQUENCED_WINDOW_SIZE = 1024, ENET_PEER_FREE_UNSEQUENCED_WINDOWS = 32, diff --git a/polymer/eduke32/source/enet/include/enet/win32.h b/polymer/eduke32/source/enet/include/enet/win32.h index 0e1cf0c5a..7d34953ae 100644 --- a/polymer/eduke32/source/enet/include/enet/win32.h +++ b/polymer/eduke32/source/enet/include/enet/win32.h @@ -5,12 +5,14 @@ #ifndef __ENET_WIN32_H__ #define __ENET_WIN32_H__ +#ifdef _MSC_VER #ifdef ENET_BUILDING_LIB #pragma warning (disable: 4996) // 'strncpy' was declared deprecated #pragma warning (disable: 4267) // size_t to int conversion #pragma warning (disable: 4244) // 64bit to 32bit int #pragma warning (disable: 4018) // signed/unsigned mismatch #endif +#endif #include #include diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index 77b440d28..4435c3168 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -57,6 +57,13 @@ int32_t g_netDisconnect = 0; int32_t net_lists[] = { STAT_PROJECTILE, STAT_STANDABLE, STAT_ACTIVATOR, STAT_TRANSPORT, STAT_EFFECTOR, STAT_ACTOR, STAT_ZOMBIEACTOR }; char g_networkPassword[32]; +enum NetDisconnect_t +{ + DISC_BAD_PASSWORD = 1, + DISC_KICKED, + DISC_BANNED +}; + #ifdef _WIN32 #define WIN32_LEAN_AND_MEAN #include @@ -68,9 +75,6 @@ static int32_t usecwd = 0; #endif /* _WIN32 */ int32_t g_scriptSanityChecks = 1; -#define IDFSIZE 479985668 -#define IDFILENAME "DUKE3D.IDF" - #define TIMERUPDATESIZ 32 int32_t g_cameraDistance = 0, g_cameraClock = 0; @@ -536,8 +540,6 @@ void G_AddUserQuote(const char *daquote) pub = NUMPAGES; } -int32_t lastpackettime = 0; - void G_HandleSpecialKeys(void) { // we need CONTROL_GetInput in order to pick up joystick button presses @@ -844,15 +846,17 @@ static int32_t peractorvals[MAXGAMEVARS][MAXSPRITES], perplayervals[MAXGAMEVARS] static void Net_SendChallenge(void) { - int32_t i, l; + int32_t l; + uint32_t crc; if (!net_peer) return; + crc = crc32once((uint8_t *)g_networkPassword, Bstrlen(g_networkPassword)); + buf[0] = PACKET_AUTH; l = 1; - - for (i=0; g_networkPassword[i]; i++) buf[l++] = g_networkPassword[i]; - buf[l++] = 0; + Bmemcpy(&buf[l], &crc, sizeof(int32_t)); + l += sizeof(int32_t); buf[l++] = myconnectindex; @@ -861,11 +865,16 @@ static void Net_SendChallenge(void) void P_Disconnected(int32_t i) { + if (i == 0) return; + g_player[i].playerquitflag = 0; Bsprintf(buf,"%s^00 is history!",g_player[i].user_name); G_AddUserQuote(buf); + if (numplayers == 1) + S_PlaySound(GENERIC_AMBIENCE17); + if (g_player[myconnectindex].ps->gm & MODE_GAME) { if (screenpeek == i) @@ -874,9 +883,6 @@ void P_Disconnected(int32_t i) if (screenpeek < 0) screenpeek = 0; } - if (numplayers == 2) - S_PlaySound(GENERIC_AMBIENCE17); - pub = NUMPAGES; pus = NUMPAGES; G_UpdateScreenArea(); @@ -902,6 +908,8 @@ void Net_SyncPlayer(ENetEvent * event) { int32_t i, j; + S_PlaySound(DUKE_GETWEAPON2); + TRAVERSE_CONNECT(i) if (!g_player[i].playerquitflag) break; @@ -953,8 +961,10 @@ void Net_SyncPlayer(ENetEvent * event) j = g_player[i].ps->i; Bmemcpy(g_player[i].ps, g_player[0].ps, sizeof(DukePlayer_t)); + g_player[i].ps->i = j; changespritestat(j, STAT_PLAYER); + P_ResetStatus(i); P_ResetWeapons(i); P_ResetInventory(i); @@ -1015,7 +1025,7 @@ void Net_ParsePacket(ENetEvent * event) if (i == myconnectindex && !g_player[i].ps->dead_flag) { - j += sizeof(input_t)-sizeof(loc.filler)+(sizeof(vec3_t)*3) + sizeof(int16_t)*2; + j += sizeof(input_t)-sizeof(loc.filler)+(sizeof(vec3_t)*3) + sizeof(int16_t)*6; goto process; } @@ -1035,6 +1045,8 @@ void Net_ParsePacket(ENetEvent * event) Bmemcpy(&g_player[i].ps->ang, &packbuf[j], sizeof(int16_t) * 2); Bmemcpy(&sprite[g_player[i].ps->i].ang, &packbuf[j], sizeof(int16_t)); j += sizeof(int16_t) * 2; + Bmemcpy(&g_player[i].ps->horiz, &packbuf[j], sizeof(int16_t) * 4); + j += sizeof(int16_t) * 4; process: Bmemcpy(&sprite[g_player[i].ps->i].extra, &packbuf[j], sizeof(int16_t)); @@ -1043,8 +1055,6 @@ process: j += sizeof(int16_t); Bmemcpy(&g_player[i].ps->kickback_pic, &packbuf[j], sizeof(int16_t)); j += sizeof(int16_t); - Bmemcpy(&g_player[i].ps->shield_amount, &packbuf[j], sizeof(int16_t)); - j += sizeof(int16_t); Bmemcpy(&ActorExtra[g_player[i].ps->i].owner, &packbuf[j], sizeof(int16_t)); j += sizeof(int16_t); Bmemcpy(&ActorExtra[g_player[i].ps->i].picnum, &packbuf[j], sizeof(int16_t)); @@ -1053,20 +1063,30 @@ process: j += sizeof(g_player[i].ps->gotweapon); Bmemcpy(&g_player[i].ps->curr_weapon, &packbuf[j], sizeof(int16_t)); j += sizeof(int16_t); + Bmemcpy(&g_player[i].ps->ammo_amount[0], &packbuf[j], sizeof(g_player[i].ps->ammo_amount)); j += sizeof(g_player[i].ps->ammo_amount); + + Bmemcpy(&g_player[i].ps->inv_amount[0], &packbuf[j], sizeof(g_player[i].ps->inv_amount)); + j += sizeof(g_player[i].ps->inv_amount); + Bmemcpy(&g_player[i].ps->last_weapon, &packbuf[j], sizeof(int16_t)); j += sizeof(int16_t); Bmemcpy(&g_player[i].ps->wantweaponfire, &packbuf[j], sizeof(int16_t)); j += sizeof(int16_t); Bmemcpy(&g_player[i].ps->frag_ps, &packbuf[j], sizeof(int16_t)); j += sizeof(int16_t); + Bmemcpy(&g_player[i].ps->frag, &packbuf[j], sizeof(int16_t)); + j += sizeof(int16_t); Bmemcpy(&g_player[i].ps->fraggedself, &packbuf[j], sizeof(int16_t)); j += sizeof(int16_t); Bmemcpy(&g_player[i].ps->last_extra, &packbuf[j], sizeof(int16_t)); j += sizeof(int16_t); Bmemcpy(g_player[i].frags, &packbuf[j], sizeof(g_player[i].frags)); j += sizeof(g_player[i].frags); + Bmemcpy(&g_player[i].ping, &packbuf[j], sizeof(int16_t)); + j += sizeof(int16_t); + sprite[g_player[i].ps->i].pal = packbuf[j++]; l = i; @@ -1285,6 +1305,8 @@ process: Bmemcpy(&g_player[other].ps->ang, &packbuf[j], sizeof(int16_t) * 2); Bmemcpy(&sprite[g_player[other].ps->i].ang, &packbuf[j], sizeof(int16_t)); j += sizeof(int16_t) * 2; + Bmemcpy(&g_player[other].ps->horiz, &packbuf[j], sizeof(int16_t) * 4); + j += sizeof(int16_t) * 4; { int16_t i = g_player[other].ps->i, jj = j++; @@ -1301,7 +1323,7 @@ process: break; case PACKET_PLAYER_READY: - if (net_server) + if (net_server && g_player[myconnectindex].ps->gm & MODE_GAME) { packbuf[0] = PACKET_PLAYER_READY; packbuf[1] = myconnectindex; @@ -1374,17 +1396,18 @@ process: break; case PACKET_AUTH: - for (i=1; i < packbufleng; i++) - tempbuf[i-1] = packbuf[i]; - tempbuf[i-1] = 0; - i++; - - if (!Bstrcmp(tempbuf, g_networkPassword)) - Net_SyncPlayer(event); - else + if (net_server) { - enet_peer_disconnect(event->peer, 1); - initprintf("Bad password: %s\n", tempbuf); + uint32_t crc; + Bmemcpy(&crc, &packbuf[1], sizeof(int32_t)); + + if (crc == crc32once((uint8_t *)g_networkPassword, Bstrlen(g_networkPassword))) + Net_SyncPlayer(event); + else + { + enet_peer_disconnect(event->peer, DISC_BAD_PASSWORD); + initprintf("Bad password from client.\n"); + } } break; @@ -1403,6 +1426,8 @@ process: for (i=0; istate = ENET_PEER_STATE_CONNECTED; } else enet_packet_destroy(event.packet); - lastpackettime = totalclock; + + g_player[(intptr_t)event.peer->data].ping = (event.peer->lastRoundTripTime + event.peer->roundTripTime)/2; + break; case ENET_EVENT_TYPE_DISCONNECT: numplayers--; @@ -1736,12 +1763,24 @@ void Net_GetPackets(void) } else Net_ParsePacket(&event); enet_packet_destroy (event.packet); - lastpackettime = totalclock; break; case ENET_EVENT_TYPE_DISCONNECT: g_netDisconnect = 1; - initprintf (event.data == 1? "Bad password.\n" : "Disconnected.\n"); - return; + switch (event.data) + { + case DISC_BAD_PASSWORD: + initprintf("Bad password.\n"); + return; + case DISC_KICKED: + initprintf("Kicked from server.\n"); + return; + case DISC_BANNED: + initprintf("Banned from server.\n"); + return; + default: + initprintf("Disconnected.\n"); + return; + } default: break; } @@ -1814,6 +1853,8 @@ void faketimerhandler(void) j += sizeof(vec3_t) * 3; Bmemcpy(&packbuf[j], &g_player[myconnectindex].ps->ang, sizeof(int16_t) * 2); j += sizeof(int16_t) * 2; + Bmemcpy(&packbuf[j], &g_player[myconnectindex].ps->horiz, sizeof(int16_t) * 4); + j += sizeof(int16_t) * 4; i = g_player[myconnectindex].ps->i; @@ -1877,14 +1918,14 @@ void faketimerhandler(void) j += sizeof(vec3_t) * 3; Bmemcpy(&packbuf[j], &g_player[i].ps->ang, sizeof(int16_t) * 2); j += sizeof(int16_t) * 2; + Bmemcpy(&packbuf[j], &g_player[i].ps->horiz, sizeof(int16_t) * 4); + j += sizeof(int16_t) * 4; Bmemcpy(&packbuf[j], &sprite[g_player[i].ps->i].extra, sizeof(int16_t)); j += sizeof(int16_t); Bmemcpy(&packbuf[j], &sprite[g_player[i].ps->i].cstat, sizeof(int16_t)); j += sizeof(int16_t); Bmemcpy(&packbuf[j], &g_player[i].ps->kickback_pic, sizeof(int16_t)); j += sizeof(int16_t); - Bmemcpy(&packbuf[j], &g_player[i].ps->shield_amount, sizeof(int16_t)); - j += sizeof(int16_t); Bmemcpy(&packbuf[j], &ActorExtra[g_player[i].ps->i].owner, sizeof(int16_t)); j += sizeof(int16_t); Bmemcpy(&packbuf[j], &ActorExtra[g_player[i].ps->i].picnum, sizeof(int16_t)); @@ -1895,18 +1936,25 @@ void faketimerhandler(void) j += sizeof(int16_t); Bmemcpy(&packbuf[j], &g_player[i].ps->ammo_amount[0], sizeof(g_player[i].ps->ammo_amount)); j += sizeof(g_player[i].ps->ammo_amount); + Bmemcpy(&packbuf[j], &g_player[i].ps->inv_amount[0], sizeof(g_player[i].ps->inv_amount)); + j += sizeof(g_player[i].ps->inv_amount); Bmemcpy(&packbuf[j], &g_player[i].ps->last_weapon, sizeof(int16_t)); j += sizeof(int16_t); Bmemcpy(&packbuf[j], &g_player[i].ps->wantweaponfire, sizeof(int16_t)); j += sizeof(int16_t); Bmemcpy(&packbuf[j], &g_player[i].ps->frag_ps, sizeof(int16_t)); j += sizeof(int16_t); + Bmemcpy(&packbuf[j], &g_player[i].ps->frag, sizeof(int16_t)); + j += sizeof(int16_t); Bmemcpy(&packbuf[j], &g_player[i].ps->fraggedself, sizeof(int16_t)); j += sizeof(int16_t); Bmemcpy(&packbuf[j], &g_player[i].ps->last_extra, sizeof(int16_t)); j += sizeof(int16_t); Bmemcpy(&packbuf[j], g_player[i].frags, sizeof(g_player[i].frags)); j += sizeof(g_player[i].frags); + Bmemcpy(&packbuf[j], &g_player[i].ping, sizeof(int16_t)); + j += sizeof(int16_t); + packbuf[j++] = sprite[g_player[i].ps->i].pal; l = i; @@ -2533,19 +2581,19 @@ static void G_DrawInventory(DukePlayer_t *p) { int32_t n, j = 0, xoff = 0, y; - n = (p->jetpack_amount > 0)<<3; + n = (p->inv_amount[GET_JETPACK] > 0)<<3; if (n&8) j++; - n |= (p->scuba_amount > 0)<<5; + n |= (p->inv_amount[GET_SCUBA] > 0)<<5; if (n&32) j++; - n |= (p->steroids_amount > 0)<<1; + n |= (p->inv_amount[GET_STEROIDS] > 0)<<1; if (n&2) j++; - n |= (p->holoduke_amount > 0)<<2; + n |= (p->inv_amount[GET_HOLODUKE] > 0)<<2; if (n&4) j++; - n |= (p->firstaid_amount > 0); + n |= (p->inv_amount[GET_FIRSTAID] > 0); if (n&1) j++; - n |= (p->heat_amount > 0)<<4; + n |= (p->inv_amount[GET_HEATS] > 0)<<4; if (n&16) j++; - n |= (p->boot_amount > 0)<<6; + n |= (p->inv_amount[GET_BOOTS] > 0)<<6; if (n&64) j++; xoff = 160-(j*11); @@ -2701,7 +2749,7 @@ static void G_DrawStatusBar(int32_t snum) { int32_t lAmount=Gv_GetVarByLabel("PLR_MORALE",-1, p->i, snum); - if (lAmount == -1) lAmount = p->shield_amount; + if (lAmount == -1) lAmount = p->inv_amount[GET_SHIELD]; G_DrawAltDigiNum(105,-(200-22),lAmount,-16,10+16); } @@ -2774,28 +2822,28 @@ static void G_DrawStatusBar(int32_t snum) switch (p->inven_icon) { case 1: - i = p->firstaid_amount; + i = p->inv_amount[GET_FIRSTAID]; break; case 2: - i = ((p->steroids_amount+3)>>2); + i = ((p->inv_amount[GET_STEROIDS]+3)>>2); break; case 3: - i = ((p->holoduke_amount+15)/24); + i = ((p->inv_amount[GET_HOLODUKE]+15)/24); j = p->holoduke_on; break; case 4: - i = ((p->jetpack_amount+15)>>4); + i = ((p->inv_amount[GET_JETPACK]+15)>>4); j = p->jetpack_on; break; case 5: - i = p->heat_amount/12; + i = p->inv_amount[GET_HEATS]/12; j = p->heat_on; break; case 6: - i = ((p->scuba_amount+63)>>6); + i = ((p->inv_amount[GET_SCUBA]+63)>>6); break; case 7: - i = (p->boot_amount>>1); + i = (p->inv_amount[GET_BOOTS]>>1); break; } G_DrawInvNum(-(284-30-o),200-6-3,(uint8_t)i,0,10+permbit); @@ -2873,28 +2921,28 @@ static void G_DrawStatusBar(int32_t snum) switch (p->inven_icon) { case 1: - i = p->firstaid_amount; + i = p->inv_amount[GET_FIRSTAID]; break; case 2: - i = ((p->steroids_amount+3)>>2); + i = ((p->inv_amount[GET_STEROIDS]+3)>>2); break; case 3: - i = ((p->holoduke_amount+15)/24); + i = ((p->inv_amount[GET_HOLODUKE]+15)/24); j = p->holoduke_on; break; case 4: - i = ((p->jetpack_amount+15)>>4); + i = ((p->inv_amount[GET_JETPACK]+15)>>4); j = p->jetpack_on; break; case 5: - i = p->heat_amount/12; + i = p->inv_amount[GET_HEATS]/12; j = p->heat_on; break; case 6: - i = ((p->scuba_amount+63)>>6); + i = ((p->inv_amount[GET_SCUBA]+63)>>6); break; case 7: - i = (p->boot_amount>>1); + i = (p->inv_amount[GET_BOOTS]>>1); break; } G_DrawInvNum(284-30-o,200-6,(uint8_t)i,0,10+permbit); @@ -2935,18 +2983,18 @@ static void G_DrawStatusBar(int32_t snum) int32_t lAmount=Gv_GetVarByLabel("PLR_MORALE",-1, p->i, snum); if (lAmount == -1) { - if (sbar.shield_amount != p->shield_amount) + if (sbar.inv_amount[GET_SHIELD] != p->inv_amount[GET_SHIELD]) { - sbar.shield_amount = p->shield_amount; + sbar.inv_amount[GET_SHIELD] = p->inv_amount[GET_SHIELD]; u |= 2; } } else { - if (sbar.shield_amount != lAmount) + if (sbar.inv_amount[GET_SHIELD] != lAmount) { - sbar.shield_amount = lAmount; + sbar.inv_amount[GET_SHIELD] = lAmount; u |= 2; } @@ -2997,39 +3045,39 @@ static void G_DrawStatusBar(int32_t snum) sbar.heat_on = p->heat_on; u |= (4096+8192); } - if (sbar.firstaid_amount != p->firstaid_amount) + if (sbar.inv_amount[GET_FIRSTAID] != p->inv_amount[GET_FIRSTAID]) { - sbar.firstaid_amount = p->firstaid_amount; + sbar.inv_amount[GET_FIRSTAID] = p->inv_amount[GET_FIRSTAID]; u |= 8192; } - if (sbar.steroids_amount != p->steroids_amount) + if (sbar.inv_amount[GET_STEROIDS] != p->inv_amount[GET_STEROIDS]) { - sbar.steroids_amount = p->steroids_amount; + sbar.inv_amount[GET_STEROIDS] = p->inv_amount[GET_STEROIDS]; u |= 8192; } - if (sbar.holoduke_amount != p->holoduke_amount) + if (sbar.inv_amount[GET_HOLODUKE] != p->inv_amount[GET_HOLODUKE]) { - sbar.holoduke_amount = p->holoduke_amount; + sbar.inv_amount[GET_HOLODUKE] = p->inv_amount[GET_HOLODUKE]; u |= 8192; } - if (sbar.jetpack_amount != p->jetpack_amount) + if (sbar.inv_amount[GET_JETPACK] != p->inv_amount[GET_JETPACK]) { - sbar.jetpack_amount = p->jetpack_amount; + sbar.inv_amount[GET_JETPACK] = p->inv_amount[GET_JETPACK]; u |= 8192; } - if (sbar.heat_amount != p->heat_amount) + if (sbar.inv_amount[GET_HEATS] != p->inv_amount[GET_HEATS]) { - sbar.heat_amount = p->heat_amount; + sbar.inv_amount[GET_HEATS] = p->inv_amount[GET_HEATS]; u |= 8192; } - if (sbar.scuba_amount != p->scuba_amount) + if (sbar.inv_amount[GET_SCUBA] != p->inv_amount[GET_SCUBA]) { - sbar.scuba_amount = p->scuba_amount; + sbar.inv_amount[GET_SCUBA] = p->inv_amount[GET_SCUBA]; u |= 8192; } - if (sbar.boot_amount != p->boot_amount) + if (sbar.inv_amount[GET_BOOTS] != p->inv_amount[GET_BOOTS]) { - sbar.boot_amount = p->boot_amount; + sbar.inv_amount[GET_BOOTS] = p->inv_amount[GET_BOOTS]; u |= 8192; } if (u == 0) return; @@ -3090,7 +3138,7 @@ static void G_DrawStatusBar(int32_t snum) int32_t lAmount=Gv_GetVarByLabel("PLR_MORALE",-1, p->i, snum); if (u != -1) G_PatchStatusBar(52,SBY+17,75,SBY+17+11); if (lAmount == -1) - G_DrawDigiNum(64,SBY+17,p->shield_amount,-16,10+16); + G_DrawDigiNum(64,SBY+17,p->inv_amount[GET_SHIELD],-16,10+16); else G_DrawDigiNum(64,SBY+17,lAmount,-16,10+16); } @@ -3179,25 +3227,25 @@ static void G_DrawStatusBar(int32_t snum) switch (p->inven_icon) { case 1: - i = p->firstaid_amount; + i = p->inv_amount[GET_FIRSTAID]; break; case 2: - i = ((p->steroids_amount+3)>>2); + i = ((p->inv_amount[GET_STEROIDS]+3)>>2); break; case 3: - i = ((p->holoduke_amount+15)/24); + i = ((p->inv_amount[GET_HOLODUKE]+15)/24); break; case 4: - i = ((p->jetpack_amount+15)>>4); + i = ((p->inv_amount[GET_JETPACK]+15)>>4); break; case 5: - i = p->heat_amount/12; + i = p->inv_amount[GET_HEATS]/12; break; case 6: - i = ((p->scuba_amount+63)>>6); + i = ((p->inv_amount[GET_SCUBA]+63)>>6); break; case 7: - i = (p->boot_amount>>1); + i = (p->inv_amount[GET_BOOTS]>>1); break; } G_DrawInvNum(284-30-o,SBY+28,(uint8_t)i,0,10+permbit); @@ -3235,10 +3283,11 @@ static void G_PrintFPS(void) // lag meter if (net_peer) { - chars = Bsprintf(tempbuf, "%d +- %d ms", net_peer->roundTripTime, net_peer->roundTripTimeVariance); + chars = Bsprintf(tempbuf, "%d +- %d ms", (net_peer->lastRoundTripTime + net_peer->roundTripTime)/2, + (net_peer->lastRoundTripTimeVariance + net_peer->roundTripTimeVariance)/2); printext256(windowx2-(chars<<(3-x))+1,windowy1+10+2,0,-1,tempbuf,x); - printext256(windowx2-(chars<<(3-x)),windowy1+10+1,net_peer->roundTripTime > 200 ? COLOR_RED : COLOR_WHITE,-1,tempbuf,x); + printext256(windowx2-(chars<<(3-x)),windowy1+10+1,net_peer->lastRoundTripTime > 200 ? COLOR_RED : COLOR_WHITE,-1,tempbuf,x); } } @@ -7946,7 +7995,7 @@ PALONLY: t->cstat |= 4; } - if (g_player[screenpeek].ps->heat_amount > 0 && g_player[screenpeek].ps->heat_on && + if (g_player[screenpeek].ps->inv_amount[GET_HEATS] > 0 && g_player[screenpeek].ps->heat_on && (A_CheckEnemySprite(s) || A_CheckSpriteFlags(t->owner,SPRITE_NVG) || s->picnum == APLAYER || s->statnum == STAT_DUMMYPLAYER)) { t->pal = 6; @@ -8246,7 +8295,7 @@ void G_CheatGetInv(void) X_OnEvent(EVENT_CHEATGETSTEROIDS, g_player[myconnectindex].ps->i, myconnectindex, -1); if (aGameVars[g_iReturnVarID].val.lValue >=0) { - g_player[myconnectindex].ps->steroids_amount = + g_player[myconnectindex].ps->inv_amount[GET_STEROIDS] = aGameVars[g_iReturnVarID].val.lValue; } @@ -8254,7 +8303,7 @@ void G_CheatGetInv(void) X_OnEvent(EVENT_CHEATGETHEAT, g_player[myconnectindex].ps->i, myconnectindex, -1); if (aGameVars[g_iReturnVarID].val.lValue >=0) { - g_player[myconnectindex].ps->heat_amount = + g_player[myconnectindex].ps->inv_amount[GET_HEATS] = aGameVars[g_iReturnVarID].val.lValue; } @@ -8262,7 +8311,7 @@ void G_CheatGetInv(void) X_OnEvent(EVENT_CHEATGETBOOT, g_player[myconnectindex].ps->i, myconnectindex, -1); if (aGameVars[g_iReturnVarID].val.lValue >=0) { - g_player[myconnectindex].ps->boot_amount = + g_player[myconnectindex].ps->inv_amount[GET_BOOTS] = aGameVars[g_iReturnVarID].val.lValue; } @@ -8270,7 +8319,7 @@ void G_CheatGetInv(void) X_OnEvent(EVENT_CHEATGETSHIELD, g_player[myconnectindex].ps->i, myconnectindex, -1); if (aGameVars[g_iReturnVarID].val.lValue >=0) { - g_player[myconnectindex].ps->shield_amount = + g_player[myconnectindex].ps->inv_amount[GET_SHIELD] = aGameVars[g_iReturnVarID].val.lValue; } @@ -8278,7 +8327,7 @@ void G_CheatGetInv(void) X_OnEvent(EVENT_CHEATGETSCUBA, g_player[myconnectindex].ps->i, myconnectindex, -1); if (aGameVars[g_iReturnVarID].val.lValue >=0) { - g_player[myconnectindex].ps->scuba_amount = + g_player[myconnectindex].ps->inv_amount[GET_SCUBA] = aGameVars[g_iReturnVarID].val.lValue; } @@ -8286,7 +8335,7 @@ void G_CheatGetInv(void) X_OnEvent(EVENT_CHEATGETHOLODUKE, g_player[myconnectindex].ps->i, myconnectindex, -1); if (aGameVars[g_iReturnVarID].val.lValue >=0) { - g_player[myconnectindex].ps->holoduke_amount = + g_player[myconnectindex].ps->inv_amount[GET_HOLODUKE] = aGameVars[g_iReturnVarID].val.lValue; } @@ -8294,7 +8343,7 @@ void G_CheatGetInv(void) X_OnEvent(EVENT_CHEATGETJETPACK, g_player[myconnectindex].ps->i, myconnectindex, -1); if (aGameVars[g_iReturnVarID].val.lValue >=0) { - g_player[myconnectindex].ps->jetpack_amount = + g_player[myconnectindex].ps->inv_amount[GET_JETPACK] = aGameVars[g_iReturnVarID].val.lValue; } @@ -8302,7 +8351,7 @@ void G_CheatGetInv(void) X_OnEvent(EVENT_CHEATGETFIRSTAID, g_player[myconnectindex].ps->i, myconnectindex, -1); if (aGameVars[g_iReturnVarID].val.lValue >=0) { - g_player[myconnectindex].ps->firstaid_amount = + g_player[myconnectindex].ps->inv_amount[GET_FIRSTAID] = aGameVars[g_iReturnVarID].val.lValue; } } @@ -8709,8 +8758,8 @@ FOUNDCHEAT: return; case CHEAT_HYPER: - g_player[myconnectindex].ps->steroids_amount = 399; - g_player[myconnectindex].ps->heat_amount = 1200; + g_player[myconnectindex].ps->inv_amount[GET_STEROIDS] = 399; + g_player[myconnectindex].ps->inv_amount[GET_HEATS] = 1200; g_player[myconnectindex].ps->cheat_phase = 0; P_DoQuote(37,g_player[myconnectindex].ps); KB_FlushKeyBoardQueue(); @@ -8781,78 +8830,36 @@ FOUNDCHEAT: static void G_ShowScores(void) { - int32_t t, i, y,xfragtotal,yfragtotal; + int32_t t, i; if (playerswhenstarted > 1 && (GametypeFlags[ud.coop]&GAMETYPE_SCORESHEET)) { - /* - rotatesprite(160<<16,34<<16,65536L,0,INGAMEDUKETHREEDEE,0,0,10,0,0,xdim-1,ydim-1); - if (PLUTOPAK) // JBF 20030804 - rotatesprite((260)<<16,36<<16,65536L,0,PLUTOPAKSPRITE+2,0,0,2+8,0,0,xdim-1,ydim-1); - */ gametext(160,SCORESHEETOFFSET+58+2,"MULTIPLAYER TOTALS",0,2+8+16); gametext(160,SCORESHEETOFFSET+58+10,MapInfo[(ud.volume_number*MAXLEVELS)+ud.last_level-1].name,0,2+8+16); -// gametext(160,165,"PRESS ANY KEY TO CONTINUE",0,2+8+16); - t = 0; - minitext(23,SCORESHEETOFFSET+80," NAME KILLS",8,2+8+16+128); - for (i=playerswhenstarted-1; i>=0; i--) - { - Bsprintf(tempbuf,"%-4d",i+1); - minitext(92+(i*23),SCORESHEETOFFSET+80,tempbuf,3,2+8+16+128); - } + minitext(70,SCORESHEETOFFSET+80,"NAME",8,2+8+16+128); + minitext(170,SCORESHEETOFFSET+80,"FRAGS",8,2+8+16+128); + minitext(200,SCORESHEETOFFSET+80,"DEATHS",8,2+8+16+128); + minitext(235,SCORESHEETOFFSET+80,"PING",8,2+8+16+128); for (i=playerswhenstarted-1; i>=0; i--) { - xfragtotal = 0; - Bsprintf(tempbuf,"%d",i+1); + if (!g_player[i].playerquitflag) continue; - minitext(30,SCORESHEETOFFSET+90+t,tempbuf,0,2+8+16+128); - minitext(38,SCORESHEETOFFSET+90+t,g_player[i].user_name,g_player[i].ps->palookup,2+8+16+128); + minitext(70,SCORESHEETOFFSET+90+t,g_player[i].user_name,g_player[i].ps->palookup,2+8+16+128); - for (y=playerswhenstarted-1; y>=0; y--) - { - if (i == y) - { - Bsprintf(tempbuf,"%-4d",g_player[y].ps->fraggedself); - minitext(92+(y*23),SCORESHEETOFFSET+90+t,tempbuf,2,2+8+16+128); - xfragtotal -= g_player[y].ps->fraggedself; - } - else - { - Bsprintf(tempbuf,"%-4d",g_player[i].frags[y]); - minitext(92+(y*23),SCORESHEETOFFSET+90+t,tempbuf,0,2+8+16+128); - xfragtotal += g_player[i].frags[y]; - } + Bsprintf(tempbuf,"%-4d",g_player[i].ps->frag); + minitext(170,SCORESHEETOFFSET+90+t,tempbuf,2,2+8+16+128); - if (net_server) - { - Bsprintf(tempbuf,"stats %d killed %d %d\n",i+1,y+1,g_player[i].frags[y]); - sendscore(tempbuf); - } - } + Bsprintf(tempbuf,"%-4d", g_player[i].frags[i] + g_player[i].ps->fraggedself); + minitext(200,SCORESHEETOFFSET+90+t,tempbuf,2,2+8+16+128); - Bsprintf(tempbuf,"%-4d",xfragtotal); - minitext(101+(8*23),SCORESHEETOFFSET+90+t,tempbuf,2,2+8+16+128); + Bsprintf(tempbuf,"%-4d",g_player[i].ping); + minitext(235,SCORESHEETOFFSET+90+t,tempbuf,2,2+8+16+128); t += 7; } - - for (y=playerswhenstarted-1; y>=0; y--) - { - yfragtotal = 0; - for (i=playerswhenstarted-1; i>=0; i--) - { - if (i == y) - yfragtotal += g_player[i].ps->fraggedself; - yfragtotal += g_player[i].frags[y]; - } - Bsprintf(tempbuf,"%-4d",yfragtotal); - minitext(92+(y*23),SCORESHEETOFFSET+96+(8*7),tempbuf,2,2+8+16+128); - } - - minitext(45,SCORESHEETOFFSET+96+(8*7),"DEATHS",8,2+8+16+128); } } @@ -10564,8 +10571,6 @@ static void G_DisplayLogo(void) MOUSE_ClearButton(LEFT_MOUSE); } - Net_WaitForEverybody(); - flushperms(); clearview(0L); nextpage(); @@ -11642,8 +11647,6 @@ MAIN_LOOP_RESTART: ud.m_respawn_monsters = 1; else ud.m_respawn_monsters = 0; - Net_WaitForEverybody(); - TRAVERSE_CONNECT(i) { P_ResetWeapons(i); @@ -11653,6 +11656,8 @@ MAIN_LOOP_RESTART: G_NewGame(ud.m_volume_number,ud.m_level_number,ud.m_player_skill); if (G_EnterLevel(MODE_GAME)) G_BackToMenu(); + + Net_WaitForEverybody(); } else G_DisplayLogo(); @@ -11718,7 +11723,6 @@ MAIN_LOOP_RESTART: if (g_player[myconnectindex].ps->gm&MODE_EOL) { G_CloseDemoWrite(); - Net_WaitForEverybody(); ready2send = 0; @@ -11751,13 +11755,13 @@ MAIN_LOOP_RESTART: } ud.display_bonus_screen = 1; ready2send = 0; - Net_WaitForEverybody(); if (numplayers > 1) g_player[myconnectindex].ps->gm = MODE_GAME; if (G_EnterLevel(g_player[myconnectindex].ps->gm)) { G_BackToMenu(); goto MAIN_LOOP_RESTART; } + Net_WaitForEverybody(); continue; } diff --git a/polymer/eduke32/source/gameexec.c b/polymer/eduke32/source/gameexec.c index cf4d3387f..4a3a81b52 100644 --- a/polymer/eduke32/source/gameexec.c +++ b/polymer/eduke32/source/gameexec.c @@ -2820,28 +2820,28 @@ nullquote: switch (*(insptr-1)) { case GET_STEROIDS: - g_player[vm.g_p].ps->steroids_amount = *insptr; + g_player[vm.g_p].ps->inv_amount[GET_STEROIDS] = *insptr; g_player[vm.g_p].ps->inven_icon = 2; break; case GET_SHIELD: - g_player[vm.g_p].ps->shield_amount += *insptr;// 100; - if (g_player[vm.g_p].ps->shield_amount > g_player[vm.g_p].ps->max_shield_amount) - g_player[vm.g_p].ps->shield_amount = g_player[vm.g_p].ps->max_shield_amount; + g_player[vm.g_p].ps->inv_amount[GET_SHIELD] += *insptr;// 100; + if (g_player[vm.g_p].ps->inv_amount[GET_SHIELD] > g_player[vm.g_p].ps->max_shield_amount) + g_player[vm.g_p].ps->inv_amount[GET_SHIELD] = g_player[vm.g_p].ps->max_shield_amount; break; case GET_SCUBA: - g_player[vm.g_p].ps->scuba_amount = *insptr;// 1600; + g_player[vm.g_p].ps->inv_amount[GET_SCUBA] = *insptr;// 1600; g_player[vm.g_p].ps->inven_icon = 6; break; case GET_HOLODUKE: - g_player[vm.g_p].ps->holoduke_amount = *insptr;// 1600; + g_player[vm.g_p].ps->inv_amount[GET_HOLODUKE] = *insptr;// 1600; g_player[vm.g_p].ps->inven_icon = 3; break; case GET_JETPACK: - g_player[vm.g_p].ps->jetpack_amount = *insptr;// 1600; + g_player[vm.g_p].ps->inv_amount[GET_JETPACK] = *insptr;// 1600; g_player[vm.g_p].ps->inven_icon = 4; break; @@ -2861,18 +2861,18 @@ nullquote: break; case GET_HEATS: - g_player[vm.g_p].ps->heat_amount = *insptr; + g_player[vm.g_p].ps->inv_amount[GET_HEATS] = *insptr; g_player[vm.g_p].ps->inven_icon = 5; break; case GET_FIRSTAID: g_player[vm.g_p].ps->inven_icon = 1; - g_player[vm.g_p].ps->firstaid_amount = *insptr; + g_player[vm.g_p].ps->inv_amount[GET_FIRSTAID] = *insptr; break; case GET_BOOTS: g_player[vm.g_p].ps->inven_icon = 7; - g_player[vm.g_p].ps->boot_amount = *insptr; + g_player[vm.g_p].ps->inv_amount[GET_BOOTS] = *insptr; break; default: OSD_Printf(CON_ERROR "Invalid inventory ID %d\n",g_errorLineNum,keyw[g_tw],*(insptr-1)); @@ -2928,7 +2928,7 @@ nullquote: j = 1; else if ((l&2048) && g_player[vm.g_p].ps->jetpack_on) j = 1; - else if ((l&4096) && g_player[vm.g_p].ps->steroids_amount > 0 && g_player[vm.g_p].ps->steroids_amount < 400) + else if ((l&4096) && g_player[vm.g_p].ps->inv_amount[GET_STEROIDS] > 0 && g_player[vm.g_p].ps->inv_amount[GET_STEROIDS] < 400) j = 1; else if ((l&8192) && g_player[vm.g_p].ps->on_ground) j = 1; @@ -4395,21 +4395,21 @@ nullquote: switch (*insptr++) { case GET_STEROIDS: - if (g_player[vm.g_p].ps->steroids_amount != *insptr) + if (g_player[vm.g_p].ps->inv_amount[GET_STEROIDS] != *insptr) j = 1; break; case GET_SHIELD: - if (g_player[vm.g_p].ps->shield_amount != g_player[vm.g_p].ps->max_shield_amount) + if (g_player[vm.g_p].ps->inv_amount[GET_SHIELD] != g_player[vm.g_p].ps->max_shield_amount) j = 1; break; case GET_SCUBA: - if (g_player[vm.g_p].ps->scuba_amount != *insptr) j = 1; + if (g_player[vm.g_p].ps->inv_amount[GET_SCUBA] != *insptr) j = 1; break; case GET_HOLODUKE: - if (g_player[vm.g_p].ps->holoduke_amount != *insptr) j = 1; + if (g_player[vm.g_p].ps->inv_amount[GET_HOLODUKE] != *insptr) j = 1; break; case GET_JETPACK: - if (g_player[vm.g_p].ps->jetpack_amount != *insptr) j = 1; + if (g_player[vm.g_p].ps->inv_amount[GET_JETPACK] != *insptr) j = 1; break; case GET_ACCESS: switch (vm.g_sp->pal) @@ -4426,13 +4426,13 @@ nullquote: } break; case GET_HEATS: - if (g_player[vm.g_p].ps->heat_amount != *insptr) j = 1; + if (g_player[vm.g_p].ps->inv_amount[GET_HEATS] != *insptr) j = 1; break; case GET_FIRSTAID: - if (g_player[vm.g_p].ps->firstaid_amount != *insptr) j = 1; + if (g_player[vm.g_p].ps->inv_amount[GET_FIRSTAID] != *insptr) j = 1; break; case GET_BOOTS: - if (g_player[vm.g_p].ps->boot_amount != *insptr) j = 1; + if (g_player[vm.g_p].ps->inv_amount[GET_BOOTS] != *insptr) j = 1; break; default: OSD_Printf(CON_ERROR "invalid inventory ID: %d\n",g_errorLineNum,keyw[g_tw],*(insptr-1)); @@ -5047,7 +5047,6 @@ void G_RestoreMapState(mapstate_t *save) Net_ResetPrediction(); - Net_WaitForEverybody(); clearfifo(); G_ResetTimers(); } diff --git a/polymer/eduke32/source/gamestructures.c b/polymer/eduke32/source/gamestructures.c index e76adab0e..8e8c4738e 100644 --- a/polymer/eduke32/source/gamestructures.c +++ b/polymer/eduke32/source/gamestructures.c @@ -1317,7 +1317,7 @@ static void __fastcall X_GetPlayer(register int32_t lVar1, register int32_t lLab case PLAYER_WANTWEAPONFIRE: Gv_SetVar(lVar2, g_player[iPlayer].ps->wantweaponfire, vm.g_i, vm.g_p); return; case PLAYER_HOLODUKE_AMOUNT: - Gv_SetVar(lVar2, g_player[iPlayer].ps->holoduke_amount, vm.g_i, vm.g_p); return; + Gv_SetVar(lVar2, g_player[iPlayer].ps->inv_amount[GET_HOLODUKE], vm.g_i, vm.g_p); return; case PLAYER_NEWOWNER: Gv_SetVar(lVar2, g_player[iPlayer].ps->newowner, vm.g_i, vm.g_p); return; case PLAYER_HURT_DELAY: @@ -1347,7 +1347,7 @@ static void __fastcall X_GetPlayer(register int32_t lVar1, register int32_t lLab case PLAYER_WEAPON_ANG: Gv_SetVar(lVar2, g_player[iPlayer].ps->weapon_ang, vm.g_i, vm.g_p); return; case PLAYER_FIRSTAID_AMOUNT: - Gv_SetVar(lVar2, g_player[iPlayer].ps->firstaid_amount, vm.g_i, vm.g_p); return; + Gv_SetVar(lVar2, g_player[iPlayer].ps->inv_amount[GET_FIRSTAID], vm.g_i, vm.g_p); return; case PLAYER_SOMETHINGONPLAYER: Gv_SetVar(lVar2, g_player[iPlayer].ps->somethingonplayer, vm.g_i, vm.g_p); return; case PLAYER_ON_CRANE: @@ -1373,7 +1373,7 @@ static void __fastcall X_GetPlayer(register int32_t lVar1, register int32_t lLab case PLAYER_QUICK_KICK: Gv_SetVar(lVar2, g_player[iPlayer].ps->quick_kick, vm.g_i, vm.g_p); return; case PLAYER_HEAT_AMOUNT: - Gv_SetVar(lVar2, g_player[iPlayer].ps->heat_amount, vm.g_i, vm.g_p); return; + Gv_SetVar(lVar2, g_player[iPlayer].ps->inv_amount[GET_HEATS], vm.g_i, vm.g_p); return; case PLAYER_ACTORSQU: Gv_SetVar(lVar2, g_player[iPlayer].ps->actorsqu, vm.g_i, vm.g_p); return; case PLAYER_TIMEBEFOREEXIT: @@ -1393,13 +1393,13 @@ static void __fastcall X_GetPlayer(register int32_t lVar1, register int32_t lLab case PLAYER_SHOW_EMPTY_WEAPON: Gv_SetVar(lVar2, g_player[iPlayer].ps->show_empty_weapon, vm.g_i, vm.g_p); return; case PLAYER_SCUBA_AMOUNT: - Gv_SetVar(lVar2, g_player[iPlayer].ps->scuba_amount, vm.g_i, vm.g_p); return; + Gv_SetVar(lVar2, g_player[iPlayer].ps->inv_amount[GET_SCUBA], vm.g_i, vm.g_p); return; case PLAYER_JETPACK_AMOUNT: - Gv_SetVar(lVar2, g_player[iPlayer].ps->jetpack_amount, vm.g_i, vm.g_p); return; + Gv_SetVar(lVar2, g_player[iPlayer].ps->inv_amount[GET_JETPACK], vm.g_i, vm.g_p); return; case PLAYER_STEROIDS_AMOUNT: - Gv_SetVar(lVar2, g_player[iPlayer].ps->steroids_amount, vm.g_i, vm.g_p); return; + Gv_SetVar(lVar2, g_player[iPlayer].ps->inv_amount[GET_STEROIDS], vm.g_i, vm.g_p); return; case PLAYER_SHIELD_AMOUNT: - Gv_SetVar(lVar2, g_player[iPlayer].ps->shield_amount, vm.g_i, vm.g_p); return; + Gv_SetVar(lVar2, g_player[iPlayer].ps->inv_amount[GET_SHIELD], vm.g_i, vm.g_p); return; case PLAYER_HOLODUKE_ON: Gv_SetVar(lVar2, g_player[iPlayer].ps->holoduke_on, vm.g_i, vm.g_p); return; case PLAYER_PYCOUNT: @@ -1415,7 +1415,7 @@ static void __fastcall X_GetPlayer(register int32_t lVar1, register int32_t lLab case PLAYER_FOOTPRINTSHADE: Gv_SetVar(lVar2, g_player[iPlayer].ps->footprintshade, vm.g_i, vm.g_p); return; case PLAYER_BOOT_AMOUNT: - Gv_SetVar(lVar2, g_player[iPlayer].ps->boot_amount, vm.g_i, vm.g_p); return; + Gv_SetVar(lVar2, g_player[iPlayer].ps->inv_amount[GET_BOOTS], vm.g_i, vm.g_p); return; case PLAYER_SCREAM_VOICE: Gv_SetVar(lVar2, g_player[iPlayer].ps->scream_voice, vm.g_i, vm.g_p); return; case PLAYER_GM: @@ -1641,7 +1641,7 @@ static void __fastcall X_SetPlayer(int32_t lVar1, int32_t lLabelID, int32_t lVar case PLAYER_WANTWEAPONFIRE: g_player[iPlayer].ps->wantweaponfire=lVar1; return; case PLAYER_HOLODUKE_AMOUNT: - g_player[iPlayer].ps->holoduke_amount=lVar1; return; + g_player[iPlayer].ps->inv_amount[GET_HOLODUKE]=lVar1; return; case PLAYER_NEWOWNER: g_player[iPlayer].ps->newowner=lVar1; return; case PLAYER_HURT_DELAY: @@ -1671,7 +1671,7 @@ static void __fastcall X_SetPlayer(int32_t lVar1, int32_t lLabelID, int32_t lVar case PLAYER_WEAPON_ANG: g_player[iPlayer].ps->weapon_ang=lVar1; return; case PLAYER_FIRSTAID_AMOUNT: - g_player[iPlayer].ps->firstaid_amount=lVar1; return; + g_player[iPlayer].ps->inv_amount[GET_FIRSTAID]=lVar1; return; case PLAYER_SOMETHINGONPLAYER: g_player[iPlayer].ps->somethingonplayer=lVar1; return; case PLAYER_ON_CRANE: @@ -1697,7 +1697,7 @@ static void __fastcall X_SetPlayer(int32_t lVar1, int32_t lLabelID, int32_t lVar case PLAYER_QUICK_KICK: g_player[iPlayer].ps->quick_kick=lVar1; return; case PLAYER_HEAT_AMOUNT: - g_player[iPlayer].ps->heat_amount=lVar1; return; + g_player[iPlayer].ps->inv_amount[GET_HEATS]=lVar1; return; case PLAYER_ACTORSQU: g_player[iPlayer].ps->actorsqu=lVar1; return; case PLAYER_TIMEBEFOREEXIT: @@ -1717,13 +1717,13 @@ static void __fastcall X_SetPlayer(int32_t lVar1, int32_t lLabelID, int32_t lVar case PLAYER_SHOW_EMPTY_WEAPON: g_player[iPlayer].ps->show_empty_weapon=lVar1; return; case PLAYER_SCUBA_AMOUNT: - g_player[iPlayer].ps->scuba_amount=lVar1; return; + g_player[iPlayer].ps->inv_amount[GET_SCUBA]=lVar1; return; case PLAYER_JETPACK_AMOUNT: - g_player[iPlayer].ps->jetpack_amount=lVar1; return; + g_player[iPlayer].ps->inv_amount[GET_JETPACK]=lVar1; return; case PLAYER_STEROIDS_AMOUNT: - g_player[iPlayer].ps->steroids_amount=lVar1; return; + g_player[iPlayer].ps->inv_amount[GET_STEROIDS]=lVar1; return; case PLAYER_SHIELD_AMOUNT: - g_player[iPlayer].ps->shield_amount=lVar1; return; + g_player[iPlayer].ps->inv_amount[GET_SHIELD]=lVar1; return; case PLAYER_HOLODUKE_ON: g_player[iPlayer].ps->holoduke_on=lVar1; return; case PLAYER_PYCOUNT: @@ -1739,7 +1739,7 @@ static void __fastcall X_SetPlayer(int32_t lVar1, int32_t lLabelID, int32_t lVar case PLAYER_FOOTPRINTSHADE: g_player[iPlayer].ps->footprintshade=lVar1; return; case PLAYER_BOOT_AMOUNT: - g_player[iPlayer].ps->boot_amount=lVar1; return; + g_player[iPlayer].ps->inv_amount[GET_BOOTS]=lVar1; return; case PLAYER_SCREAM_VOICE: g_player[iPlayer].ps->scream_voice=lVar1; return; case PLAYER_GM: @@ -3549,7 +3549,7 @@ static int32_t __fastcall X_AccessPlayerX(int32_t iPlayer, int32_t lLabelID, int case PLAYER_WANTWEAPONFIRE: return g_player[iPlayer].ps->wantweaponfire; case PLAYER_HOLODUKE_AMOUNT: - return g_player[iPlayer].ps->holoduke_amount; + return g_player[iPlayer].ps->inv_amount[GET_HOLODUKE]; case PLAYER_NEWOWNER: return g_player[iPlayer].ps->newowner; case PLAYER_HURT_DELAY: @@ -3579,7 +3579,7 @@ static int32_t __fastcall X_AccessPlayerX(int32_t iPlayer, int32_t lLabelID, int case PLAYER_WEAPON_ANG: return g_player[iPlayer].ps->weapon_ang; case PLAYER_FIRSTAID_AMOUNT: - return g_player[iPlayer].ps->firstaid_amount; + return g_player[iPlayer].ps->inv_amount[GET_FIRSTAID]; case PLAYER_SOMETHINGONPLAYER: return g_player[iPlayer].ps->somethingonplayer; case PLAYER_ON_CRANE: @@ -3605,7 +3605,7 @@ static int32_t __fastcall X_AccessPlayerX(int32_t iPlayer, int32_t lLabelID, int case PLAYER_QUICK_KICK: return g_player[iPlayer].ps->quick_kick; case PLAYER_HEAT_AMOUNT: - return g_player[iPlayer].ps->heat_amount; + return g_player[iPlayer].ps->inv_amount[GET_HEATS]; case PLAYER_ACTORSQU: return g_player[iPlayer].ps->actorsqu; case PLAYER_TIMEBEFOREEXIT: @@ -3625,13 +3625,13 @@ static int32_t __fastcall X_AccessPlayerX(int32_t iPlayer, int32_t lLabelID, int case PLAYER_SHOW_EMPTY_WEAPON: return g_player[iPlayer].ps->show_empty_weapon; case PLAYER_SCUBA_AMOUNT: - return g_player[iPlayer].ps->scuba_amount; + return g_player[iPlayer].ps->inv_amount[GET_SCUBA]; case PLAYER_JETPACK_AMOUNT: - return g_player[iPlayer].ps->jetpack_amount; + return g_player[iPlayer].ps->inv_amount[GET_JETPACK]; case PLAYER_STEROIDS_AMOUNT: - return g_player[iPlayer].ps->steroids_amount; + return g_player[iPlayer].ps->inv_amount[GET_STEROIDS]; case PLAYER_SHIELD_AMOUNT: - return g_player[iPlayer].ps->shield_amount; + return g_player[iPlayer].ps->inv_amount[GET_SHIELD]; case PLAYER_HOLODUKE_ON: return g_player[iPlayer].ps->holoduke_on; case PLAYER_PYCOUNT: @@ -3647,7 +3647,7 @@ static int32_t __fastcall X_AccessPlayerX(int32_t iPlayer, int32_t lLabelID, int case PLAYER_FOOTPRINTSHADE: return g_player[iPlayer].ps->footprintshade; case PLAYER_BOOT_AMOUNT: - return g_player[iPlayer].ps->boot_amount; + return g_player[iPlayer].ps->inv_amount[GET_BOOTS]; case PLAYER_SCREAM_VOICE: return g_player[iPlayer].ps->scream_voice; case PLAYER_GM: diff --git a/polymer/eduke32/source/global.c b/polymer/eduke32/source/global.c index ede4a8389..a7e5417b2 100644 --- a/polymer/eduke32/source/global.c +++ b/polymer/eduke32/source/global.c @@ -23,7 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. //------------------------------------------------------------------------- #include "duke3d.h" -const char *s_buildDate = "20091214"; +const char *s_buildDate = "20091215"; char *MusicPtr = NULL; int32_t g_musicSize; diff --git a/polymer/eduke32/source/osdcmds.c b/polymer/eduke32/source/osdcmds.c index e3c3d5dd4..abec46a12 100644 --- a/polymer/eduke32/source/osdcmds.c +++ b/polymer/eduke32/source/osdcmds.c @@ -31,6 +31,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "osdfuncs.h" #include #include +#include "enet/enet.h" extern int32_t voting, g_doQuickSave; struct osdcmd_cheatsinfo osdcmd_cheatsinfo_stat; @@ -727,7 +728,7 @@ static int32_t osdcmd_give(const osdfuncparm_t *parm) } else if (!Bstrcasecmp(parm->parms[0], "armor")) { - g_player[myconnectindex].ps->shield_amount = 100; + g_player[myconnectindex].ps->inv_amount[GET_SHIELD] = 100; return OSDCMD_OK; } else if (!Bstrcasecmp(parm->parms[0], "keys")) @@ -1179,6 +1180,32 @@ static int32_t osdcmd_password(const osdfuncparm_t *parm) return OSDCMD_OK; } +static int32_t osdcmd_listplayers(const osdfuncparm_t *parm) +{ + ENetPeer * currentPeer; + + if (parm->numparms != 0) + return OSDCMD_SHOWHELP; + + if (!net_server) + { + initprintf("You are not the server.\n"); + return OSDCMD_OK; + } + + for (currentPeer = net_server -> peers; + currentPeer < & net_server -> peers [net_server -> peerCount]; + ++ currentPeer) + { + if (currentPeer -> state != ENET_PEER_STATE_CONNECTED) + continue; + + initprintf("%d %s\n", currentPeer, g_player[(intptr_t)currentPeer->data].user_name); + } + + return OSDCMD_OK; +} + static int32_t osdcmd_cvar_set_multi(const osdfuncparm_t *parm) { int32_t r = osdcmd_cvar_set(parm); @@ -1386,6 +1413,8 @@ int32_t registerosdcommands(void) OSD_RegisterFunction("initgroupfile","initgroupfile : adds a grp file into the game filesystem", osdcmd_initgroupfile); OSD_RegisterFunction("inittimer","debug", osdcmd_inittimer); + OSD_RegisterFunction("listplayers","listplayers: lists currently connected multiplayer clients", osdcmd_listplayers); + OSD_RegisterFunction("name","name: change your multiplayer nickname", osdcmd_name); OSD_RegisterFunction("noclip","noclip: toggles clipping mode", osdcmd_noclip); diff --git a/polymer/eduke32/source/player.c b/polymer/eduke32/source/player.c index cf59d8d6b..16bcb5cd4 100644 --- a/polymer/eduke32/source/player.c +++ b/polymer/eduke32/source/player.c @@ -80,17 +80,17 @@ static void P_IncurDamage(DukePlayer_t *p) { p->extra_extra8 = 0; - if (p->shield_amount > 0) + if (p->inv_amount[GET_SHIELD] > 0) { shield_damage = damage * (20 + (krand()%30)) / 100; damage -= shield_damage; - p->shield_amount += shield_damage; + p->inv_amount[GET_SHIELD] += shield_damage; - if (p->shield_amount < 0) + if (p->inv_amount[GET_SHIELD] < 0) { - damage += p->shield_amount; - p->shield_amount = 0; + damage += p->inv_amount[GET_SHIELD]; + p->inv_amount[GET_SHIELD] = 0; } } @@ -605,7 +605,7 @@ int32_t A_Shoot(int32_t i,int32_t atwith) if (ProjectileData[atwith].sound >= 0) A_PlaySound(ProjectileData[atwith].sound,j); } - if (p >= 0 && g_player[p].ps->steroids_amount > 0 && g_player[p].ps->steroids_amount < 400) + if (p >= 0 && g_player[p].ps->inv_amount[GET_STEROIDS] > 0 && g_player[p].ps->inv_amount[GET_STEROIDS] < 400) sprite[j].extra += (g_player[p].ps->max_player_health>>2); if (hitinfo.hitsprite >= 0 && sprite[hitinfo.hitsprite].picnum != ACCESSSWITCH && sprite[hitinfo.hitsprite].picnum != ACCESSSWITCH2) @@ -1202,7 +1202,7 @@ DOSKIPBULLETHOLE: ActorExtra[k].temp_data[8] = hitinfo.hitsprite; } - if (p >= 0 && g_player[p].ps->steroids_amount > 0 && g_player[p].ps->steroids_amount < 400) + if (p >= 0 && g_player[p].ps->inv_amount[GET_STEROIDS] > 0 && g_player[p].ps->inv_amount[GET_STEROIDS] < 400) sprite[j].extra += (g_player[p].ps->max_player_health>>2); if (hitinfo.hitsprite >= 0 && sprite[hitinfo.hitsprite].picnum != ACCESSSWITCH && sprite[hitinfo.hitsprite].picnum != ACCESSSWITCH2) @@ -3385,20 +3385,20 @@ static int32_t P_DoCounters(DukePlayer_t *p) } } - if (p->steroids_amount > 0 && p->steroids_amount < 400) + if (p->inv_amount[GET_STEROIDS] > 0 && p->inv_amount[GET_STEROIDS] < 400) { - p->steroids_amount--; - if (p->steroids_amount == 0) + p->inv_amount[GET_STEROIDS]--; + if (p->inv_amount[GET_STEROIDS] == 0) P_SelectNextInvItem(p); - if (!(p->steroids_amount&7)) + if (!(p->inv_amount[GET_STEROIDS]&7)) if (snum == screenpeek || GTFLAGS(GAMETYPE_COOPSOUND)) A_PlaySound(DUKE_HARTBEAT,p->i); } - if (p->heat_on && p->heat_amount > 0) + if (p->heat_on && p->inv_amount[GET_HEATS] > 0) { - p->heat_amount--; - if (p->heat_amount == 0) + p->inv_amount[GET_HEATS]--; + if (p->inv_amount[GET_HEATS] == 0) { p->heat_on = 0; P_SelectNextInvItem(p); @@ -3409,8 +3409,8 @@ static int32_t P_DoCounters(DukePlayer_t *p) if (p->holoduke_on >= 0) { - p->holoduke_amount--; - if (p->holoduke_amount <= 0) + p->inv_amount[GET_HOLODUKE]--; + if (p->inv_amount[GET_HOLODUKE] <= 0) { A_PlaySound(TELEPORTER,p->i); p->holoduke_on = -1; @@ -3418,10 +3418,10 @@ static int32_t P_DoCounters(DukePlayer_t *p) } } - if (p->jetpack_on && p->jetpack_amount > 0) + if (p->jetpack_on && p->inv_amount[GET_JETPACK] > 0) { - p->jetpack_amount--; - if (p->jetpack_amount <= 0) + p->inv_amount[GET_JETPACK]--; + if (p->inv_amount[GET_JETPACK] <= 0) { p->jetpack_on = 0; P_SelectNextInvItem(p); @@ -3492,7 +3492,7 @@ static int32_t P_DoCounters(DukePlayer_t *p) if (p->cursectnum >= 0 && p->scuba_on == 0 && sector[p->cursectnum].lotag == 2) { - if (p->scuba_amount > 0) + if (p->inv_amount[GET_SCUBA] > 0) { p->scuba_on = 1; p->inven_icon = 6; @@ -3510,10 +3510,10 @@ static int32_t P_DoCounters(DukePlayer_t *p) } } } - else if (p->scuba_amount > 0 && p->scuba_on) + else if (p->inv_amount[GET_SCUBA] > 0 && p->scuba_on) { - p->scuba_amount--; - if (p->scuba_amount == 0) + p->inv_amount[GET_SCUBA]--; + if (p->inv_amount[GET_SCUBA] == 0) { p->scuba_on = 0; P_SelectNextInvItem(p); @@ -3638,19 +3638,19 @@ void P_AddWeapon(DukePlayer_t *p,int32_t weapon) void P_SelectNextInvItem(DukePlayer_t *p) { - if (p->firstaid_amount > 0) + if (p->inv_amount[GET_FIRSTAID] > 0) p->inven_icon = 1; - else if (p->steroids_amount > 0) + else if (p->inv_amount[GET_STEROIDS] > 0) p->inven_icon = 2; - else if (p->holoduke_amount > 0) + else if (p->inv_amount[GET_HOLODUKE] > 0) p->inven_icon = 3; - else if (p->jetpack_amount > 0) + else if (p->inv_amount[GET_JETPACK] > 0) p->inven_icon = 4; - else if (p->heat_amount > 0) + else if (p->inv_amount[GET_HEATS] > 0) p->inven_icon = 5; - else if (p->scuba_amount > 0) + else if (p->inv_amount[GET_SCUBA] > 0) p->inven_icon = 6; - else if (p->boot_amount > 0) + else if (p->inv_amount[GET_BOOTS] > 0) p->inven_icon = 7; else p->inven_icon = 0; } @@ -3834,13 +3834,7 @@ void P_FragPlayer(int32_t snum) p->pals_time = 63; p->posz -= (16<<8); s->z -= (16<<8); - } - if (ud.recstat == 1 && ud.multimode < 2) - G_CloseDemoWrite(); - - if (s->pal != 1) - { p->dead_flag = (512-((krand()&1)<<10)+(krand()&255)-512)&2047; if (p->dead_flag == 0) p->dead_flag++; @@ -3880,6 +3874,7 @@ void P_FragPlayer(int32_t snum) { g_player[p->frag_ps].ps->frag++; g_player[p->frag_ps].frags[snum]++; + g_player[snum].frags[snum]++; // deaths } if (snum == screenpeek) @@ -4042,7 +4037,7 @@ void P_ProcessInput(int32_t snum) else { s->extra = 0; - p->shield_amount = 0; + p->inv_amount[GET_SHIELD] = 0; } p->last_extra = s->extra; @@ -4149,6 +4144,9 @@ void P_ProcessInput(int32_t snum) if (s->extra <= 0) { + if (ud.recstat == 1 && ud.multimode < 2) + G_CloseDemoWrite(); + if ((numplayers < 2 || net_server) && p->dead_flag == 0) P_FragPlayer(snum); @@ -4703,11 +4701,11 @@ void P_ProcessInput(int32_t snum) if (j == PURPLELAVA || sector[s->sectnum].ceilingpicnum == PURPLELAVA) { - if (p->boot_amount > 0) + if (p->inv_amount[GET_BOOTS] > 0) { - p->boot_amount--; + p->inv_amount[GET_BOOTS]--; p->inven_icon = 7; - if (p->boot_amount <= 0) + if (p->inv_amount[GET_BOOTS] <= 0) P_SelectNextInvItem(p); } else @@ -4731,7 +4729,7 @@ void P_ProcessInput(int32_t snum) case HURTRAIL__STATIC: if (rnd(32)) { - if (p->boot_amount > 0) + if (p->inv_amount[GET_BOOTS] > 0) k = 1; else { @@ -4750,7 +4748,7 @@ void P_ProcessInput(int32_t snum) case FLOORSLIME__STATIC: if (rnd(16)) { - if (p->boot_amount > 0) + if (p->inv_amount[GET_BOOTS] > 0) k = 1; else { @@ -4767,7 +4765,7 @@ void P_ProcessInput(int32_t snum) case FLOORPLASMA__STATIC: if (rnd(32)) { - if (p->boot_amount > 0) + if (p->inv_amount[GET_BOOTS] > 0) k = 1; else { @@ -4787,8 +4785,8 @@ void P_ProcessInput(int32_t snum) if (k) { P_DoQuote(75,p); - p->boot_amount -= 2; - if (p->boot_amount <= 0) + p->inv_amount[GET_BOOTS] -= 2; + if (p->inv_amount[GET_BOOTS] <= 0) P_SelectNextInvItem(p); } } @@ -4852,7 +4850,7 @@ void P_ProcessInput(int32_t snum) else if (p->walking_snd_toggle > 0) p->walking_snd_toggle--; - if (p->jetpack_on == 0 && p->steroids_amount > 0 && p->steroids_amount < 400) + if (p->jetpack_on == 0 && p->inv_amount[GET_STEROIDS] > 0 && p->inv_amount[GET_STEROIDS] < 400) doubvel <<= 1; p->posxv += ((g_player[snum].sync->fvel*doubvel)<<6); @@ -5743,33 +5741,33 @@ int32_t getspritescore(int32_t snum, int32_t dapicnum) if (sprite[g_player[snum].ps->i].extra < g_player[snum].ps->max_player_health) return(30); return(1); case FIRSTAID__STATIC: - if (g_player[snum].ps->firstaid_amount < g_player[snum].ps->max_player_health) return(100); + if (g_player[snum].ps->inv_amount[GET_FIRSTAID] < g_player[snum].ps->max_player_health) return(100); return(1); case SHIELD__STATIC: - if (g_player[snum].ps->shield_amount < g_player[snum].ps->max_shield_amount) return(50); + if (g_player[snum].ps->inv_amount[GET_SHIELD] < g_player[snum].ps->max_shield_amount) return(50); return(1); case STEROIDS__STATIC: - if (g_player[snum].ps->steroids_amount < 400) return(30); + if (g_player[snum].ps->inv_amount[GET_STEROIDS] < 400) return(30); return(1); case AIRTANK__STATIC: - if (g_player[snum].ps->scuba_amount < 6400) return(30); + if (g_player[snum].ps->inv_amount[GET_SCUBA] < 6400) return(30); return(1); case JETPACK__STATIC: - if (g_player[snum].ps->jetpack_amount < 1600) return(100); + if (g_player[snum].ps->inv_amount[GET_JETPACK] < 1600) return(100); return(1); case HEATSENSOR__STATIC: - if (g_player[snum].ps->heat_amount < 1200) return(5); + if (g_player[snum].ps->inv_amount[GET_HEATS] < 1200) return(5); return(1); case ACCESSCARD__STATIC: return(1); case BOOTS__STATIC: - if (g_player[snum].ps->boot_amount < 200) return(15); + if (g_player[snum].ps->inv_amount[GET_BOOTS] < 200) return(15); return(1); case ATOMICHEALTH__STATIC: if (sprite[g_player[snum].ps->i].extra < g_player[snum].ps->max_player_health<<1) return(50); return(1); case HOLODUKE__STATIC: - if (g_player[snum].ps->holoduke_amount < 2400) return(5); + if (g_player[snum].ps->inv_amount[GET_HOLODUKE] < 2400) return(5); return(1); case MUSICANDSFX__STATIC: return(1); @@ -5867,7 +5865,7 @@ void computergetinput(int32_t snum, input_t *syn) z2 = sprite[g_player[goalplayer[snum]].ps->i].z; if (p->dead_flag) syn->bits |= BIT(SK_OPEN); - if ((p->firstaid_amount > 0) && (p->last_extra < 100)) + if ((p->inv_amount[GET_FIRSTAID] > 0) && (p->last_extra < 100)) syn->bits |= BIT(SK_MEDKIT); for (j=headspritestat[STAT_PROJECTILE]; j>=0; j=nextspritestat[j]) diff --git a/polymer/eduke32/source/premap.c b/polymer/eduke32/source/premap.c index 0ded2afc5..c9e4d7c39 100644 --- a/polymer/eduke32/source/premap.c +++ b/polymer/eduke32/source/premap.c @@ -655,7 +655,7 @@ void P_ResetPlayer(int32_t snum) g_player[snum].ps->horizoff = 0; g_player[snum].ps->opyoff = 0; g_player[snum].ps->wackedbyactor = -1; - g_player[snum].ps->shield_amount = g_startArmorAmount; + g_player[snum].ps->inv_amount[GET_SHIELD] = g_startArmorAmount; g_player[snum].ps->dead_flag = 0; g_player[snum].ps->pals_time = 0; g_player[snum].ps->footprintcount = 0; @@ -750,9 +750,9 @@ void P_ResetStatus(int32_t snum) p->sbs = 0; p->palette = (uint8_t *) &palette[0]; - if (p->steroids_amount < 400) + if (p->inv_amount[GET_STEROIDS] < 400) { - p->steroids_amount = 0; + p->inv_amount[GET_STEROIDS] = 0; p->inven_icon = 0; } p->heat_on = 0; @@ -827,19 +827,15 @@ void P_ResetInventory(int32_t snum) { DukePlayer_t *p = g_player[snum].ps; + Bmemset(p->inv_amount, 0, sizeof(p->inv_amount)); + p->inven_icon = 0; - p->boot_amount = 0; p->scuba_on = 0; - p->scuba_amount = 0; - p->heat_amount = 0; p->heat_on = 0; p->jetpack_on = 0; - p->jetpack_amount = 0; - p->shield_amount = g_startArmorAmount; p->holoduke_on = -1; - p->holoduke_amount = 0; - p->firstaid_amount = 0; - p->steroids_amount = 0; + + p->inv_amount[GET_SHIELD] = g_startArmorAmount; p->inven_icon = 0; X_OnEvent(EVENT_RESETINVENTORY, p->i, snum, -1); } @@ -1297,7 +1293,6 @@ void G_NewGame(int32_t vn,int32_t ln,int32_t sk) g_skillSoundID = -1; - Net_WaitForEverybody(); ready2send = 0; if (ud.m_recstat != 2 && ud.last_level >= 0 && ud.multimode > 1 && (ud.coop&GAMETYPE_SCORESHEET)) @@ -1401,24 +1396,16 @@ static void resetpspritevars(char g) tsbar[i].gotweapon[j] = g_player[i].ps->gotweapon[j]; } - tsbar[i].shield_amount = g_player[i].ps->shield_amount; + Bmemcpy(tsbar[i].inv_amount, g_player[i].ps->inv_amount, sizeof(tsbar[i].inv_amount)); tsbar[i].curr_weapon = g_player[i].ps->curr_weapon; tsbar[i].inven_icon = g_player[i].ps->inven_icon; - - tsbar[i].firstaid_amount = g_player[i].ps->firstaid_amount; - tsbar[i].steroids_amount = g_player[i].ps->steroids_amount; - tsbar[i].holoduke_amount = g_player[i].ps->holoduke_amount; - tsbar[i].jetpack_amount = g_player[i].ps->jetpack_amount; - tsbar[i].heat_amount = g_player[i].ps->heat_amount; - tsbar[i].scuba_amount = g_player[i].ps->scuba_amount; - tsbar[i].boot_amount = g_player[i].ps->boot_amount; } } P_ResetStatus(0); TRAVERSE_CONNECT(i) - Bmemcpy(g_player[i].ps,g_player[0].ps,sizeof(DukePlayer_t)); + if (i) Bmemcpy(g_player[i].ps,g_player[0].ps,sizeof(DukePlayer_t)); if (ud.recstat != 2) TRAVERSE_CONNECT(i) @@ -1433,17 +1420,9 @@ static void resetpspritevars(char g) g_player[i].ps->ammo_amount[j] = tsbar[i].ammo_amount[j]; g_player[i].ps->gotweapon[j] = tsbar[i].gotweapon[j]; } - g_player[i].ps->shield_amount = tsbar[i].shield_amount; g_player[i].ps->curr_weapon = tsbar[i].curr_weapon; g_player[i].ps->inven_icon = tsbar[i].inven_icon; - - g_player[i].ps->firstaid_amount = tsbar[i].firstaid_amount; - g_player[i].ps->steroids_amount= tsbar[i].steroids_amount; - g_player[i].ps->holoduke_amount = tsbar[i].holoduke_amount; - g_player[i].ps->jetpack_amount = tsbar[i].jetpack_amount; - g_player[i].ps->heat_amount = tsbar[i].heat_amount; - g_player[i].ps->scuba_amount= tsbar[i].scuba_amount; - g_player[i].ps->boot_amount = tsbar[i].boot_amount; + Bmemcpy(g_player[i].ps->inv_amount, tsbar[i].inv_amount, sizeof(tsbar[i].inv_amount)); } } @@ -1580,12 +1559,6 @@ void Net_WaitForEverybody(void) if (numplayers < 2 || net_server) return; - packbuf[0] = PACKET_PLAYER_READY; - packbuf[1] = myconnectindex; - - if (net_client) - enet_peer_send(net_peer, 0, enet_packet_create(packbuf, 2, ENET_PACKET_FLAG_RELIABLE)); - if (ud.multimode > 1) { P_SetGamePalette(g_player[myconnectindex].ps, titlepal, 11); @@ -1604,6 +1577,12 @@ void Net_WaitForEverybody(void) { if (quitevent || keystatus[1]) G_GameExit(""); + packbuf[0] = PACKET_PLAYER_READY; + packbuf[1] = myconnectindex; + + if (net_peer) + enet_peer_send(net_peer, 0, enet_packet_create(packbuf, 2, ENET_PACKET_FLAG_RELIABLE)); + handleevents(); Net_GetPackets(); @@ -1642,7 +1621,6 @@ void clearfifo(void) Bmemset(g_player[i].sync,0,sizeof(input_t)); Bmemset(&g_player[i].movefifoend,0,sizeof(g_player[i].movefifoend)); Bmemset(&g_player[i].syncvalhead,0,sizeof(g_player[i].syncvalhead)); - Bmemset(&g_player[i].myminlag,0,sizeof(g_player[i].myminlag)); g_player[i].vote = 0; g_player[i].gotvote = 0; } diff --git a/polymer/eduke32/source/sector.c b/polymer/eduke32/source/sector.c index 4f6d07419..a24b7d636 100644 --- a/polymer/eduke32/source/sector.c +++ b/polymer/eduke32/source/sector.c @@ -2565,7 +2565,7 @@ void G_HandleSharedKeys(int32_t snum) aGameVars[g_iReturnVarID].val.lValue = 0; X_OnEvent(EVENT_USENIGHTVISION,g_player[snum].ps->i,snum, -1); if (aGameVars[g_iReturnVarID].val.lValue == 0 - && p->heat_amount > 0) + && p->inv_amount[GET_HEATS] > 0) { p->heat_on = !p->heat_on; P_UpdateScreenPal(p); @@ -2581,13 +2581,13 @@ void G_HandleSharedKeys(int32_t snum) X_OnEvent(EVENT_USESTEROIDS,g_player[snum].ps->i,snum, -1); if (aGameVars[g_iReturnVarID].val.lValue == 0) { - if (p->steroids_amount == 400) + if (p->inv_amount[GET_STEROIDS] == 400) { - p->steroids_amount--; + p->inv_amount[GET_STEROIDS]--; A_PlaySound(DUKE_TAKEPILLS,p->i); P_DoQuote(12,p); } - if (p->steroids_amount > 0) + if (p->inv_amount[GET_STEROIDS] > 0) p->inven_icon = 2; } return; // is there significance to returning? @@ -2617,44 +2617,44 @@ CHECKINV1: switch (dainv) { case 4: - if (p->jetpack_amount > 0 && i > 1) + if (p->inv_amount[GET_JETPACK] > 0 && i > 1) break; if (k) dainv++; else dainv--; goto CHECKINV1; case 6: - if (p->scuba_amount > 0 && i > 1) + if (p->inv_amount[GET_SCUBA] > 0 && i > 1) break; if (k) dainv++; else dainv--; goto CHECKINV1; case 2: - if (p->steroids_amount > 0 && i > 1) + if (p->inv_amount[GET_STEROIDS] > 0 && i > 1) break; if (k) dainv++; else dainv--; goto CHECKINV1; case 3: - if (p->holoduke_amount > 0 && i > 1) + if (p->inv_amount[GET_HOLODUKE] > 0 && i > 1) break; if (k) dainv++; else dainv--; goto CHECKINV1; case 0: case 1: - if (p->firstaid_amount > 0 && i > 1) + if (p->inv_amount[GET_FIRSTAID] > 0 && i > 1) break; if (k) dainv = 2; else dainv = 7; goto CHECKINV1; case 5: - if (p->heat_amount > 0 && i > 1) + if (p->inv_amount[GET_HEATS] > 0 && i > 1) break; if (k) dainv++; else dainv--; goto CHECKINV1; case 7: - if (p->boot_amount > 0 && i > 1) + if (p->inv_amount[GET_BOOTS] > 0 && i > 1) break; if (k) dainv = 1; else dainv = 6; @@ -2682,7 +2682,7 @@ CHECKINV1: { p->inven_icon = dainv; - if (dainv || p->firstaid_amount) + if (dainv || p->inv_amount[GET_FIRSTAID]) { static const int32_t i[8] = { 3, 90, 91, 88, 101, 89, 6, 0 }; P_DoQuote(i[dainv-1], p); @@ -2886,7 +2886,7 @@ CHECKINV1: X_OnEvent(EVENT_HOLODUKEON,g_player[snum].ps->i,snum, -1); if (aGameVars[g_iReturnVarID].val.lValue == 0) { - if (p->holoduke_amount > 0) + if (p->inv_amount[GET_HOLODUKE] > 0) { p->inven_icon = 3; @@ -2923,20 +2923,20 @@ CHECKINV1: X_OnEvent(EVENT_USEMEDKIT,g_player[snum].ps->i,snum, -1); if (aGameVars[g_iReturnVarID].val.lValue == 0) { - if (p->firstaid_amount > 0 && sprite[p->i].extra < p->max_player_health) + if (p->inv_amount[GET_FIRSTAID] > 0 && sprite[p->i].extra < p->max_player_health) { j = p->max_player_health-sprite[p->i].extra; - if ((uint32_t)p->firstaid_amount > j) + if ((uint32_t)p->inv_amount[GET_FIRSTAID] > j) { - p->firstaid_amount -= j; + p->inv_amount[GET_FIRSTAID] -= j; sprite[p->i].extra = p->max_player_health; p->inven_icon = 1; } else { - sprite[p->i].extra += p->firstaid_amount; - p->firstaid_amount = 0; + sprite[p->i].extra += p->inv_amount[GET_FIRSTAID]; + p->inv_amount[GET_FIRSTAID] = 0; P_SelectNextInvItem(p); } A_PlaySound(DUKE_USEMEDKIT,p->i); @@ -2950,7 +2950,7 @@ CHECKINV1: X_OnEvent(EVENT_USEJETPACK,g_player[snum].ps->i,snum, -1); if (aGameVars[g_iReturnVarID].val.lValue == 0) { - if (p->jetpack_amount > 0) + if (p->inv_amount[GET_JETPACK] > 0) { p->jetpack_on = !p->jetpack_on; if (p->jetpack_on)