diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index 1283912a2..00e2125f6 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -8883,11 +8883,22 @@ static void G_CheckCommandLine(int32_t argc, const char **argv) } else { - ud.multimode = Batoi(c)%17; - initprintf("Fake multiplayer mode: %d players.\n", ud.multimode); + int32_t numpl = Batoi(c); - g_fakeMultiMode = 1; + if (numpl < 2 || numpl > MAXPLAYERS) + { + initprintf("Fake multiplayer mode: expected 2-%d players, falling back to 1.\n", + MAXPLAYERS); + } + else + { + ud.multimode = numpl; + initprintf("Fake multiplayer mode: %d players.\n", ud.multimode); + + g_fakeMultiMode = 1; + } } + ud.m_coop = ud.coop = 0; ud.m_marker = ud.marker = 1; ud.m_respawn_monsters = ud.respawn_monsters = 1; diff --git a/polymer/eduke32/source/global.c b/polymer/eduke32/source/global.c index 79be2d9b1..0ee79f377 100644 --- a/polymer/eduke32/source/global.c +++ b/polymer/eduke32/source/global.c @@ -81,7 +81,8 @@ char g_numVolumes = 3; int32_t g_timerTicsPerSecond=TICRATE; -char g_numPlayerSprites,g_loadFromGroupOnly=0,g_earthquakeTime; +int8_t g_numPlayerSprites; +char g_loadFromGroupOnly=0, g_earthquakeTime; int32_t playerswhenstarted; diff --git a/polymer/eduke32/source/global.h b/polymer/eduke32/source/global.h index 0468fed2c..a2e5a87aa 100644 --- a/polymer/eduke32/source/global.h +++ b/polymer/eduke32/source/global.h @@ -56,7 +56,7 @@ G_EXTERN char SkillNames[MAXSKILLS][33]; G_EXTERN char g_RTSPlaying; G_EXTERN int32_t g_musicIndex; G_EXTERN char g_numGametypes; -G_EXTERN char g_numPlayerSprites,g_loadFromGroupOnly; +G_EXTERN char g_loadFromGroupOnly; G_EXTERN char g_numVolumes; G_EXTERN char g_numSkills; G_EXTERN char myjumpingtoggle,myonground,myhardlanding,myreturntocenter; diff --git a/polymer/eduke32/source/net.h b/polymer/eduke32/source/net.h index c8cd0d878..662556720 100644 --- a/polymer/eduke32/source/net.h +++ b/polymer/eduke32/source/net.h @@ -112,7 +112,7 @@ typedef struct { int16_t prevspritestat[MAXSPRITES]; uint8_t g_earthquakeTime; - uint8_t g_numPlayerSprites; + int8_t g_numPlayerSprites; uint8_t scriptptrs[MAXSPRITES]; netactor_t actor[MAXSPRITES]; diff --git a/polymer/eduke32/source/player.h b/polymer/eduke32/source/player.h index 2d1099ce3..b0161cbe1 100644 --- a/polymer/eduke32/source/player.h +++ b/polymer/eduke32/source/player.h @@ -227,7 +227,7 @@ typedef struct { } playerdata_t; #pragma pack(pop) -extern char g_numPlayerSprites; +extern int8_t g_numPlayerSprites; extern int32_t fricxv,fricyv; extern intptr_t *aplWeaponClip[MAX_WEAPONS]; // number of items in clip diff --git a/polymer/eduke32/source/premap.c b/polymer/eduke32/source/premap.c index 614c27a1d..2d37a9aa6 100644 --- a/polymer/eduke32/source/premap.c +++ b/polymer/eduke32/source/premap.c @@ -1567,9 +1567,8 @@ void G_NewGame(int32_t vn,int32_t ln,int32_t sk) static void resetpspritevars(char g) { - int16_t i, j, nexti; //circ; -// int32_t firstx,firsty; - spritetype *s; + int16_t i, j; //circ; + uint8_t aimmode[MAXPLAYERS],autoaim[MAXPLAYERS],weaponswitch[MAXPLAYERS]; DukeStatus_t tsbar[MAXPLAYERS]; @@ -1628,17 +1627,17 @@ static void resetpspritevars(char g) i = headspritestat[STAT_PLAYER]; while (i >= 0) { - nexti = nextspritestat[i]; - s = &sprite[i]; + const int32_t nexti = nextspritestat[i]; + spritetype *const s = &sprite[i]; if (g_numPlayerSprites == MAXPLAYERS) G_GameExit("\nToo many player sprites (max 16.)"); - g_playerSpawnPoints[(uint8_t)g_numPlayerSprites].ox = s->x; - g_playerSpawnPoints[(uint8_t)g_numPlayerSprites].oy = s->y; - g_playerSpawnPoints[(uint8_t)g_numPlayerSprites].oz = s->z; - g_playerSpawnPoints[(uint8_t)g_numPlayerSprites].oa = s->ang; - g_playerSpawnPoints[(uint8_t)g_numPlayerSprites].os = s->sectnum; + g_playerSpawnPoints[g_numPlayerSprites].ox = s->x; + g_playerSpawnPoints[g_numPlayerSprites].oy = s->y; + g_playerSpawnPoints[g_numPlayerSprites].oz = s->z; + g_playerSpawnPoints[g_numPlayerSprites].oa = s->ang; + g_playerSpawnPoints[g_numPlayerSprites].os = s->sectnum; g_numPlayerSprites++; @@ -1651,7 +1650,7 @@ static void resetpspritevars(char g) if (!g_fakeMultiMode) s->cstat = j < numplayers ? 1+256 : 32768; else - s->cstat = 1+256; + s->cstat = j < ud.multimode ? 1+256 : 32768; s->xoffset = 0; s->clipdist = 64; @@ -1716,6 +1715,7 @@ static void resetpspritevars(char g) j++; } else A_DeleteSprite(i); + i = nexti; } } diff --git a/polymer/eduke32/source/sector.h b/polymer/eduke32/source/sector.h index 36a0f7fe1..c491f08f5 100644 --- a/polymer/eduke32/source/sector.h +++ b/polymer/eduke32/source/sector.h @@ -66,7 +66,7 @@ typedef struct { int16_t pskyoff[MAXPSKYTILES], pskybits; uint8_t g_earthquakeTime; - uint8_t g_numPlayerSprites; + int8_t g_numPlayerSprites; uint8_t show2dsector[(MAXSECTORS+7)>>3];