diff --git a/polymer/eduke32/Makefile b/polymer/eduke32/Makefile index ca39b2351..d583406ae 100644 --- a/polymer/eduke32/Makefile +++ b/polymer/eduke32/Makefile @@ -265,7 +265,7 @@ $(JAUDIOLIBDIR)/$(JAUDIOLIB): ifeq ($(PRETTY_OUTPUT),1) printf "\033[K\033[0;35mChanging dir to \033[1;35m$(CURDIR)/$(JAUDIOLIBDIR)\033[0;35m \033[0m\n" endif - $(MAKE) -C $(JAUDIOLIBDIR) PRETTY_OUTPUT=$(PRETTY_OUTPUT) EROOT=$(EROOT) RELEASE=$(RELEASE) OPTLEVEL=$(OPTLEVEL) + $(MAKE) -C $(JAUDIOLIBDIR) PRETTY_OUTPUT=$(PRETTY_OUTPUT) EROOT=$(EROOT) RELEASE=$(RELEASE) OPTLEVEL=$(OPTLEVEL) DEBUGANYWAY=$(DEBUGANYWAY) ifeq ($(PRETTY_OUTPUT),1) printf "\033[K\033[0;35mChanging dir to \033[1;35m$(CURDIR)\033[0;35m \033[0m\n" endif diff --git a/polymer/eduke32/build/include/osxbits.h b/polymer/eduke32/build/include/osxbits.h index 4d176e4c0..42f35bdce 100644 --- a/polymer/eduke32/build/include/osxbits.h +++ b/polymer/eduke32/build/include/osxbits.h @@ -1,5 +1,6 @@ #ifndef __osxbits_h__ #define __osxbits_h__ +#include int32_t osx_msgbox(char *name, char *msg); int32_t osx_ynbox(char *name, char *msg); diff --git a/polymer/eduke32/build/include/polymer.h b/polymer/eduke32/build/include/polymer.h index fa9103564..0dfc95302 100644 --- a/polymer/eduke32/build/include/polymer.h +++ b/polymer/eduke32/build/include/polymer.h @@ -54,6 +54,9 @@ extern float pr_specularpower; extern float pr_specularfactor; extern int32_t pr_ati_fboworkaround; extern int32_t pr_ati_nodepthoffset; +#ifdef __APPLE__ +extern int32_t pr_ati_textureformat_one; +#endif extern int32_t r_pr_maxlightpasses; diff --git a/polymer/eduke32/build/src/kplib.c b/polymer/eduke32/build/src/kplib.c index d30f1ad71..1bc6e9c68 100644 --- a/polymer/eduke32/build/src/kplib.c +++ b/polymer/eduke32/build/src/kplib.c @@ -2639,7 +2639,7 @@ static int32_t kzcheckhash(const char *filnam, char **zipnam, int32_t *fileoffs, (*zipnam) = &kzhashbuf[*(int32_t *)&kzhashbuf[i+8]]; (*fileoffs) = *(int32_t *)&kzhashbuf[i+12]; (*fileleng) = *(int32_t *)&kzhashbuf[i+16]; - (*iscomp) = kzhashbuf[i+20]; + (*iscomp) = *(int32_t *)&kzhashbuf[i+20]; return(1); } return(0); diff --git a/polymer/eduke32/build/src/mdsprite.c b/polymer/eduke32/build/src/mdsprite.c index a94109e05..d325621fe 100644 --- a/polymer/eduke32/build/src/mdsprite.c +++ b/polymer/eduke32/build/src/mdsprite.c @@ -1050,6 +1050,20 @@ static md2model_t *md2load(int32_t fil, const char *filnam) { m->glcmds[i] = B_LITTLE32(m->glcmds[i]); } + for (i = head.numtris-1; i>=0; i--) + { + m->tris[i].v[0] = B_LITTLE16(m->tris[i].v[0]); + m->tris[i].v[1] = B_LITTLE16(m->tris[i].v[1]); + m->tris[i].v[2] = B_LITTLE16(m->tris[i].v[2]); + m->tris[i].u[0] = B_LITTLE16(m->tris[i].u[0]); + m->tris[i].u[1] = B_LITTLE16(m->tris[i].u[1]); + m->tris[i].u[2] = B_LITTLE16(m->tris[i].u[2]); + } + for(i = head.numuv-1; i>=0; i--) + { + m->uv[i].u = B_LITTLE16(m->uv[i].u); + m->uv[i].v = B_LITTLE16(m->uv[i].v); + } } #endif diff --git a/polymer/eduke32/build/src/nedmalloc.c b/polymer/eduke32/build/src/nedmalloc.c index d055729d4..baa7aeead 100644 --- a/polymer/eduke32/build/src/nedmalloc.c +++ b/polymer/eduke32/build/src/nedmalloc.c @@ -56,9 +56,8 @@ DEALINGS IN THE SOFTWARE. // #define NOINLINE #endif - #include "nedmalloc.h" -#if defined(WIN32) +#if defined(_WIN32) #include #endif #ifdef __linux__ diff --git a/polymer/eduke32/build/src/polymost.c b/polymer/eduke32/build/src/polymost.c index e059dc51d..60795851b 100644 --- a/polymer/eduke32/build/src/polymost.c +++ b/polymer/eduke32/build/src/polymost.c @@ -82,6 +82,7 @@ Low priority: #include "engine_priv.h" #include "hightile.h" #include "polymost.h" +#include "polymer.h" #include "scriptfile.h" #include "cache1d.h" #include "kplib.h" @@ -1378,6 +1379,9 @@ void writexcache(char *fn, int32_t len, int32_t dameth, char effect, texcachehea if (gi != GL_TRUE) goto failure; // an uncompressed mipmap bglGetTexLevelParameteriv(GL_TEXTURE_2D, level, GL_TEXTURE_INTERNAL_FORMAT, (GLint *)&gi); if (bglGetError() != GL_NO_ERROR) goto failure; +#ifdef __APPLE__ + if(pr_ati_textureformat_one && gi == 1 ) gi = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; +#endif pict.format = B_LITTLE32(gi); bglGetTexLevelParameteriv(GL_TEXTURE_2D, level, GL_TEXTURE_WIDTH, (GLint *)&gi); if (bglGetError() != GL_NO_ERROR) goto failure; @@ -1523,7 +1527,7 @@ int32_t gloadtile_cached(int32_t fil, texcacheheader *head, int32_t *doalloc, pt GLint format; bglGetTexLevelParameteriv(GL_TEXTURE_2D, level, GL_TEXTURE_INTERNAL_FORMAT, &format); if (bglGetError() != GL_NO_ERROR) goto failure; - format = B_LITTLE32(format); +// format = B_LITTLE32(format); if (pict.format != format) { OSD_Printf("invalid texture cache file format %d %d\n",pict.format, format); @@ -6234,15 +6238,15 @@ int32_t dedxtfilter(int32_t fil, texcachepicture *pict, char *pic, void *midbuf, void *inbuf; #if (USEKENFILTER == 0) uint32_t cleng; - if (kread(fil, &cleng, sizeof(uint32_t)) != sizeof(uint32_t)) return -1; cleng = B_LITTLE32(cleng); + if (Bread(fil, &cleng, sizeof(uint32_t)) != sizeof(uint32_t)) return -1; cleng = B_LITTLE32(cleng); #ifdef USELZF if (ispacked && cleng < pict->size) inbuf = packbuf; else inbuf = pic; - if (kread(fil, inbuf, cleng) != cleng) return -1; + if (Bread(fil, inbuf, cleng) != cleng) return -1; if (ispacked && cleng < pict->size) if (qlz_decompress(packbuf, pic, state_decompress) == 0) return -1; #else if (ispacked) inbuf = packbuf; else inbuf = pic; - if (kread(fil, inbuf, cleng) != cleng) return -1; + if (Bread(fil, inbuf, cleng) != cleng) return -1; if (ispacked && lzwuncompress(packbuf, cleng, pic, pict->size) != pict->size) return -1; #endif #else diff --git a/polymer/eduke32/build/src/sdlayer.c b/polymer/eduke32/build/src/sdlayer.c index 92b575730..db8576c19 100644 --- a/polymer/eduke32/build/src/sdlayer.c +++ b/polymer/eduke32/build/src/sdlayer.c @@ -1147,6 +1147,14 @@ int32_t setvideomode(int32_t x, int32_t y, int32_t c, int32_t fs) initprintf("Enabling ATI R520 polygon offset workaround.\n"); } else pr_ati_nodepthoffset = 0; +#ifdef __APPLE__ + //See bug description at http://lists.apple.com/archives/mac-opengl/2005/Oct/msg00169.html + if (!Bstrncmp(glinfo.renderer,"ATI Radeon 9600", 15)) { + pr_ati_textureformat_one = 1; + initprintf("Enabling ATI Radeon 9600 texture format workaround.\n"); + } else + pr_ati_textureformat_one = 0; +#endif } else pr_ati_fboworkaround = 0; #endif @@ -1530,20 +1538,24 @@ static SDL_Surface * loadappicon(void) // handleevents() -- process the SDL message queue // returns !0 if there was an important event worth checking (like quitting) // + +static inline void SetKey(int32_t key, int32_t state) +{ + keystatus[remap[key]] = state; + + if (state) + { + keyfifo[keyfifoend] = remap[key]; + keyfifo[(keyfifoend+1)&(KEYFIFOSIZ-1)] = state; + keyfifoend = ((keyfifoend+2)&(KEYFIFOSIZ-1)); + } +} + int32_t handleevents(void) { int32_t code, rv=0, j; SDL_Event ev; -#define SetKey(key,state) { \ - keystatus[remap[key]] = state; \ - if (state) { \ - keyfifo[keyfifoend] = remap[key]; \ - keyfifo[(keyfifoend+1)&(KEYFIFOSIZ-1)] = state; \ - keyfifoend = ((keyfifoend+2)&(KEYFIFOSIZ-1)); \ - } \ -} - while (SDL_PollEvent(&ev)) { switch (ev.type) @@ -2087,7 +2099,7 @@ static int32_t buildkeytranslationtable(void) #if defined _WIN32 # define WIN32_LEAN_AND_MEAN # include -#elif defined __linux || defined __FreeBSD__ || defined __NetBSD__ || defined __OpenBSD__ +#elif defined __linux || defined __FreeBSD__ || defined __NetBSD__ || defined __OpenBSD__ || defined __APPLE__ # include #endif @@ -2102,7 +2114,7 @@ void makeasmwriteable(void) initprint("Error making code writeable\n"); return; } -# elif defined __linux || defined __FreeBSD__ || defined __NetBSD__ || defined __OpenBSD__ +# elif defined __linux || defined __FreeBSD__ || defined __NetBSD__ || defined __OpenBSD__ || defined __APPLE__ int32_t pagesize; size_t dep_begin_page; pagesize = sysconf(_SC_PAGE_SIZE); diff --git a/polymer/eduke32/build/src/winlayer.c b/polymer/eduke32/build/src/winlayer.c index 146bab9e8..cb6a72c8c 100644 --- a/polymer/eduke32/build/src/winlayer.c +++ b/polymer/eduke32/build/src/winlayer.c @@ -788,13 +788,16 @@ static struct _joydevicedefn *thisjoydef = NULL, joyfeatures[] = #undef featurecount // I don't see any pressing need to store the key-up events yet -#define SetKey(key,state) { \ - keystatus[remap[key]] = state; \ - if (state) { \ - keyfifo[keyfifoend] = remap[key]; \ - keyfifo[(keyfifoend+1)&(KEYFIFOSIZ-1)] = state; \ - keyfifoend = ((keyfifoend+2)&(KEYFIFOSIZ-1)); \ - } \ +static inline void SetKey(int32_t key, int32_t state) +{ + keystatus[remap[key]] = state; + + if (state) + { + keyfifo[keyfifoend] = remap[key]; + keyfifo[(keyfifoend+1)&(KEYFIFOSIZ-1)] = state; + keyfifoend = ((keyfifoend+2)&(KEYFIFOSIZ-1)); + } } char map_dik_code(int32_t scanCode) @@ -883,7 +886,7 @@ void setkeypresscallback(void (*callback)(int32_t, int32_t)) { keypresscallback void setmousepresscallback(void (*callback)(int32_t, int32_t)) { mousepresscallback = callback; } void setjoypresscallback(void (*callback)(int32_t, int32_t)) { joypresscallback = callback; } -#define DINPUT_EVENTS 4 +#define DINPUT_EVENTS 16 DWORD WINAPI ProcessMouse(LPVOID lpThreadParameter) { @@ -909,11 +912,13 @@ DWORD WINAPI ProcessMouse(LPVOID lpThreadParameter) result = IDirectInputDevice7_GetDeviceData(lpDID[MOUSE], sizeof(DIDEVICEOBJECTDATA), (LPDIDEVICEOBJECTDATA)&didod[0], &dwElements, 0); - if (!dwElements || result != DI_OK) + if (!dwElements || (result != DI_OK && result != DI_BUFFEROVERFLOW)) continue; do { + int32_t bit = 1<<(didod[dwElements-1].dwOfs - DIMOFS_BUTTON0); + switch (didod[dwElements-1].dwOfs) { case DIMOFS_X: @@ -941,74 +946,21 @@ DWORD WINAPI ProcessMouse(LPVOID lpThreadParameter) } break; - case DIMOFS_BUTTON0: - { - if (didod[dwElements-1].dwData & 0x80) mouseb |= 1; - else mouseb &= ~1; - if (mousepresscallback) - mousepresscallback(1, mouseb & 1); - } - break; - case DIMOFS_BUTTON1: - { - if (didod[dwElements-1].dwData & 0x80) mouseb |= 2; - else mouseb &= ~2; - if (mousepresscallback) - mousepresscallback(2, mouseb & 2); - } - break; - case DIMOFS_BUTTON2: - { - if (didod[dwElements-1].dwData & 0x80) mouseb |= 4; - else mouseb &= ~4; - if (mousepresscallback) - mousepresscallback(3, mouseb & 4); - } - break; - case DIMOFS_BUTTON3: - { - if (didod[dwElements-1].dwData & 0x80) mouseb |= 8; - else mouseb &= ~8; - if (mousepresscallback) - mousepresscallback(4, mouseb & 8); - } - break; case DIMOFS_BUTTON4: - { - OSD_Printf("got button4\n"); - if (didod[dwElements-1].dwData & 0x80) mouseb |= 64; - else mouseb &= ~64; - if (mousepresscallback) - mousepresscallback(7, mouseb & 64); - } - break; case DIMOFS_BUTTON5: - { - OSD_Printf("got button5\n"); - if (didod[dwElements-1].dwData & 0x80) mouseb |= 128; - else mouseb &= ~128; - if (mousepresscallback) - mousepresscallback(8, mouseb & 128); - } - break; case DIMOFS_BUTTON6: - { - OSD_Printf("got button6\n"); - if (didod[dwElements-1].dwData & 0x80) mouseb |= 256; - else mouseb &= ~256; - if (mousepresscallback) - mousepresscallback(9, mouseb & 256); - } - break; case DIMOFS_BUTTON7: - { - OSD_Printf("got button7\n"); - if (didod[dwElements-1].dwData & 0x80) mouseb |= 512; - else mouseb &= ~512; + didod[dwElements-1].dwOfs += 2; // skip mousewheel buttons + bit = 1<<(didod[dwElements-1].dwOfs - DIMOFS_BUTTON0); + case DIMOFS_BUTTON0: + case DIMOFS_BUTTON1: + case DIMOFS_BUTTON2: + case DIMOFS_BUTTON3: + if (didod[dwElements-1].dwData & 0x80) mouseb |= bit; + else mouseb &= ~bit; if (mousepresscallback) - mousepresscallback(10, mouseb & 512); - } - break; + mousepresscallback(didod[dwElements-1].dwOfs - DIMOFS_BUTTON0 + 1, mouseb & bit); + break; } } while (--dwElements); diff --git a/polymer/eduke32/eduke32.vcproj b/polymer/eduke32/eduke32.vcproj index a935508e7..23febdbe7 100644 --- a/polymer/eduke32/eduke32.vcproj +++ b/polymer/eduke32/eduke32.vcproj @@ -144,10 +144,6 @@ RelativePath=".\build\include\mmulti.h" > - - @@ -284,10 +280,6 @@ RelativePath=".\build\src\mdsprite.c" > - - diff --git a/polymer/eduke32/source/actors.c b/polymer/eduke32/source/actors.c index fa26ff23d..52ef00cd7 100644 --- a/polymer/eduke32/source/actors.c +++ b/polymer/eduke32/source/actors.c @@ -402,7 +402,7 @@ int32_t A_MoveSprite(int32_t spritenum, const vec3_t *change, uint32_t cliptype) if ((daz > ActorExtra[spritenum].ceilingz) && (daz <= ActorExtra[spritenum].floorz)/* && (osectnum == dasectnum || cansee(oldx, oldy, spr->z - bg, osectnum, spr->x, spr->y, daz - bg, dasectnum))*/ - ) + ) spr->z = daz; else if (retval == 0) retval = 16384+dasectnum; @@ -458,9 +458,10 @@ int32_t A_MoveSprite(int32_t spritenum, const vec3_t *change, uint32_t cliptype) inline int32_t A_SetSprite(int32_t i,uint32_t cliptype) { - vec3_t davect = { (sprite[i].xvel*(sintable[(sprite[i].ang+512)&2047]))>>14, - (sprite[i].xvel*(sintable[sprite[i].ang&2047]))>>14, - sprite[i].zvel }; + vec3_t davect = {(sprite[i].xvel*(sintable[(sprite[i].ang+512)&2047]))>>14, + (sprite[i].xvel*(sintable[sprite[i].ang&2047]))>>14, + sprite[i].zvel + }; return (A_MoveSprite(i,&davect,cliptype)==0); } @@ -3355,7 +3356,7 @@ static void G_MoveTransports(void) if (onfloorz) { if (sprite[j].statnum == STAT_PROJECTILE || - (G_CheckPlayerInSector(sect) == -1 && G_CheckPlayerInSector(sprite[OW].sectnum) == -1)) + (G_CheckPlayerInSector(sect) == -1 && G_CheckPlayerInSector(sprite[OW].sectnum) == -1)) { sprite[j].x += (sprite[OW].x-SX); sprite[j].y += (sprite[OW].y-SY); @@ -5675,38 +5676,38 @@ static void G_MoveEffectors(void) //STATNUM 3 x = (s->xvel*sintable[s->ang&2047])>>14; TRAVERSE_CONNECT(p) - if (sector[g_player[p].ps->cursectnum].lotag != 2) + if (sector[g_player[p].ps->cursectnum].lotag != 2) + { + if (g_playerSpawnPoints[p].os == s->sectnum) { - if (g_playerSpawnPoints[p].os == s->sectnum) + g_playerSpawnPoints[p].ox += m; + g_playerSpawnPoints[p].oy += x; + } + + if (s->sectnum == sprite[g_player[p].ps->i].sectnum) + { + rotatepoint(s->x,s->y,g_player[p].ps->posx,g_player[p].ps->posy,q,&g_player[p].ps->posx,&g_player[p].ps->posy); + + g_player[p].ps->posx += m; + g_player[p].ps->posy += x; + + g_player[p].ps->bobposx += m; + g_player[p].ps->bobposy += x; + + g_player[p].ps->ang += q; + + if (g_netServer || numplayers > 1) { - g_playerSpawnPoints[p].ox += m; - g_playerSpawnPoints[p].oy += x; + g_player[p].ps->oposx = g_player[p].ps->posx; + g_player[p].ps->oposy = g_player[p].ps->posy; } - - if (s->sectnum == sprite[g_player[p].ps->i].sectnum) + if (sprite[g_player[p].ps->i].extra <= 0) { - rotatepoint(s->x,s->y,g_player[p].ps->posx,g_player[p].ps->posy,q,&g_player[p].ps->posx,&g_player[p].ps->posy); - - g_player[p].ps->posx += m; - g_player[p].ps->posy += x; - - g_player[p].ps->bobposx += m; - g_player[p].ps->bobposy += x; - - g_player[p].ps->ang += q; - - if (g_netServer || numplayers > 1) - { - g_player[p].ps->oposx = g_player[p].ps->posx; - g_player[p].ps->oposy = g_player[p].ps->posy; - } - if (sprite[g_player[p].ps->i].extra <= 0) - { - sprite[g_player[p].ps->i].x = g_player[p].ps->posx; - sprite[g_player[p].ps->i].y = g_player[p].ps->posy; - } + sprite[g_player[p].ps->i].x = g_player[p].ps->posx; + sprite[g_player[p].ps->i].y = g_player[p].ps->posy; } } + } j = headspritesect[s->sectnum]; while (j >= 0) { @@ -5758,7 +5759,7 @@ static void G_MoveEffectors(void) //STATNUM 3 { l = nextspritesect[j]; if (sprite[j].statnum == STAT_ACTOR && A_CheckEnemySprite(&sprite[j]) && - sprite[j].picnum != SECTOREFFECTOR && sprite[j].picnum != LOCATORS) + sprite[j].picnum != SECTOREFFECTOR && sprite[j].picnum != LOCATORS) { k = sprite[j].sectnum; updatesector(sprite[j].x,sprite[j].y,&k); @@ -5931,7 +5932,7 @@ static void G_MoveEffectors(void) //STATNUM 3 { l = nextspritesect[j]; if (sprite[j].statnum == STAT_ACTOR && A_CheckEnemySprite(&sprite[j]) && - sprite[j].picnum != SECTOREFFECTOR && sprite[j].picnum != LOCATORS) + sprite[j].picnum != SECTOREFFECTOR && sprite[j].picnum != LOCATORS) { // if(sprite[j].sectnum != s->sectnum) { @@ -7140,8 +7141,8 @@ static void G_MoveEffectors(void) //STATNUM 3 } TRAVERSE_CONNECT(p) - if (sprite[g_player[p].ps->i].sectnum == s->sectnum && g_player[p].ps->on_ground) - g_player[p].ps->posz += s->zvel; + if (sprite[g_player[p].ps->i].sectnum == s->sectnum && g_player[p].ps->on_ground) + g_player[p].ps->posz += s->zvel; A_MoveSector(i); setsprite(i,(vec3_t *)s); diff --git a/polymer/eduke32/source/astub.c b/polymer/eduke32/source/astub.c index ac5741f34..a3e4e5b47 100644 --- a/polymer/eduke32/source/astub.c +++ b/polymer/eduke32/source/astub.c @@ -245,7 +245,7 @@ void create_map_snapshot(void) { mapstate->sectors = (sectortype *)Bcalloc(1, sizeof(sectortype) * numsectors); mapstate->sectsiz = j = qlz_compress(§or[0], (char *)&mapstate->sectors[0], - sizeof(sectortype) * numsectors, state_compress); + sizeof(sectortype) * numsectors, state_compress); mapstate->sectors = (sectortype *)Brealloc(mapstate->sectors, j); mapstate->sectcrc = tempcrc; } @@ -266,7 +266,7 @@ void create_map_snapshot(void) { mapstate->walls = (walltype *)Bcalloc(1, sizeof(walltype) * numwalls); mapstate->wallsiz = j = qlz_compress(&wall[0], (char *)&mapstate->walls[0], - sizeof(walltype) * numwalls, state_compress); + sizeof(walltype) * numwalls, state_compress); mapstate->walls = (walltype *)Brealloc(mapstate->walls, j); mapstate->wallcrc = tempcrc; } @@ -299,7 +299,7 @@ void create_map_snapshot(void) } } mapstate->spritesiz = j = qlz_compress(&tspri[0], (char *)&mapstate->sprites[0], - sizeof(spritetype) * numsprites, state_compress); + sizeof(spritetype) * numsprites, state_compress); mapstate->sprites = (spritetype *)Brealloc(mapstate->sprites, j); mapstate->spritecrc = tempcrc; Bfree(tspri); @@ -5951,7 +5951,7 @@ static void Keys3d(void) FX_StopAllSounds(); S_ClearSoundLocks(); #ifdef POLYMER - for (i=0;iflags.invalidate = 1; } if ((sprite[i].xvel != spritelightptr[i]->color[0]) || - (sprite[i].yvel != spritelightptr[i]->color[1]) || - (sprite[i].zvel != spritelightptr[i]->color[2])) + (sprite[i].yvel != spritelightptr[i]->color[1]) || + (sprite[i].zvel != spritelightptr[i]->color[2])) { spritelightptr[i]->color[0] = sprite[i].xvel; spritelightptr[i]->color[1] = sprite[i].yvel; @@ -10202,8 +10202,8 @@ void ExtPreCheckKeys(void) // just before drawrooms spritelightptr[i]->flags.invalidate = 1; } if ((sprite[i].xvel != spritelightptr[i]->color[0]) || - (sprite[i].yvel != spritelightptr[i]->color[1]) || - (sprite[i].zvel != spritelightptr[i]->color[2])) + (sprite[i].yvel != spritelightptr[i]->color[1]) || + (sprite[i].zvel != spritelightptr[i]->color[2])) { spritelightptr[i]->color[0] = sprite[i].xvel; spritelightptr[i]->color[1] = sprite[i].yvel; diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index 0ebe07404..03a93624a 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -65,7 +65,8 @@ ENetPeer * g_netClientPeer = NULL; int32_t g_netPort = 23513; int32_t g_netDisconnect = 0; int8_t g_netStatnums[] = { STAT_PROJECTILE, STAT_STANDABLE, STAT_ACTIVATOR, STAT_TRANSPORT, - STAT_EFFECTOR, STAT_ACTOR, STAT_ZOMBIEACTOR, STAT_MISC }; + STAT_EFFECTOR, STAT_ACTOR, STAT_ZOMBIEACTOR, STAT_MISC + }; char g_netPassword[32]; int32_t g_quitDeadline = 0; @@ -574,46 +575,46 @@ void G_HandleSpecialKeys(void) void Net_Connect(const char * srvaddr) { - ENetAddress address; - ENetEvent event; - char * addrstr = NULL; + ENetAddress address; + ENetEvent event; + char * addrstr = NULL; Net_Disconnect(); - g_netClient = enet_host_create (NULL, 1, 0, 0); - - if (g_netClient == NULL) - { - initprintf ("An error occurred while trying to create an ENet client host.\n"); - return; - } - - addrstr = strtok((char *)srvaddr, ":"); - enet_address_set_host (&address, addrstr); + g_netClient = enet_host_create(NULL, 1, 0, 0); + + if (g_netClient == NULL) + { + initprintf("An error occurred while trying to create an ENet client host.\n"); + return; + } + + addrstr = strtok((char *)srvaddr, ":"); + enet_address_set_host(&address, addrstr); address.port = atoi((addrstr = strtok(NULL, ":")) == NULL ? "23513" : addrstr); - - // use 2 channels for easy packet sorting at a lower level than the game later - g_netClientPeer = enet_host_connect (g_netClient, &address, CHAN_MAX); - - if (g_netClientPeer == NULL) - { - initprintf ("No available peers for initiating an ENet connection.\n"); - return; - } - - /* Wait up to 5 seconds for the connection attempt to succeed. */ - if (enet_host_service (g_netClient, & event, 5000) > 0 && - event.type == ENET_EVENT_TYPE_CONNECT) - initprintf("Connection to %s:%d succeeded.\n", (char *)srvaddr, address.port); - else - { - /* Either the 5 seconds are up or a disconnect event was */ - /* received. Reset the peer in the event the 5 seconds */ - /* had run out without any significant event. */ - enet_peer_reset (g_netClientPeer); - Net_Disconnect(); - initprintf("Connection to %s:%d failed.\n",(char *)srvaddr,address.port); - } + + // use 2 channels for easy packet sorting at a lower level than the game later + g_netClientPeer = enet_host_connect(g_netClient, &address, CHAN_MAX); + + if (g_netClientPeer == NULL) + { + initprintf("No available peers for initiating an ENet connection.\n"); + return; + } + + /* Wait up to 5 seconds for the connection attempt to succeed. */ + if (enet_host_service(g_netClient, & event, 5000) > 0 && + event.type == ENET_EVENT_TYPE_CONNECT) + initprintf("Connection to %s:%d succeeded.\n", (char *)srvaddr, address.port); + else + { + /* Either the 5 seconds are up or a disconnect event was */ + /* received. Reset the peer in the event the 5 seconds */ + /* had run out without any significant event. */ + enet_peer_reset(g_netClientPeer); + Net_Disconnect(); + initprintf("Connection to %s:%d failed.\n",(char *)srvaddr,address.port); + } } void Net_Disconnect(void) @@ -625,29 +626,29 @@ void Net_Disconnect(void) if (g_netClientPeer) enet_peer_disconnect_later(g_netClientPeer, 0); - while (enet_host_service (g_netClient, & event, 3000) > 0) - { - switch (event.type) - { - case ENET_EVENT_TYPE_CONNECT: - case ENET_EVENT_TYPE_NONE: - case ENET_EVENT_TYPE_RECEIVE: - if (event.packet) - enet_packet_destroy (event.packet); - break; - - case ENET_EVENT_TYPE_DISCONNECT: + while (enet_host_service(g_netClient, & event, 3000) > 0) + { + switch (event.type) + { + case ENET_EVENT_TYPE_CONNECT: + case ENET_EVENT_TYPE_NONE: + case ENET_EVENT_TYPE_RECEIVE: + if (event.packet) + enet_packet_destroy(event.packet); + break; + + case ENET_EVENT_TYPE_DISCONNECT: numplayers = playerswhenstarted = ud.multimode = 1; myconnectindex = screenpeek = 0; G_BackToMenu(); break; - } - } - - enet_peer_reset(g_netClientPeer); - g_netClientPeer = NULL; - enet_host_destroy(g_netClient); - g_netClient = NULL; + } + } + + enet_peer_reset(g_netClientPeer); + g_netClientPeer = NULL; + enet_host_destroy(g_netClient); + g_netClient = NULL; } if (g_netServer) @@ -656,25 +657,25 @@ void Net_Disconnect(void) ENetEvent event; for (currentPeer = g_netServer -> peers; - currentPeer < & g_netServer -> peers [g_netServer -> peerCount]; - ++ currentPeer) + currentPeer < & g_netServer -> peers [g_netServer -> peerCount]; + ++ currentPeer) { - enet_peer_disconnect_later (currentPeer, 0); + enet_peer_disconnect_later(currentPeer, 0); } - while (enet_host_service (g_netServer, & event, 3000) > 0) - { - switch (event.type) - { - case ENET_EVENT_TYPE_CONNECT: - case ENET_EVENT_TYPE_NONE: - case ENET_EVENT_TYPE_RECEIVE: - case ENET_EVENT_TYPE_DISCONNECT: - if (event.packet) - enet_packet_destroy (event.packet); - break; - } - } + while (enet_host_service(g_netServer, & event, 3000) > 0) + { + switch (event.type) + { + case ENET_EVENT_TYPE_CONNECT: + case ENET_EVENT_TYPE_NONE: + case ENET_EVENT_TYPE_RECEIVE: + case ENET_EVENT_TYPE_DISCONNECT: + if (event.packet) + enet_packet_destroy(event.packet); + break; + } + } enet_host_destroy(g_netServer); g_netServer = NULL; } @@ -687,9 +688,9 @@ void G_GameQuit(void) if (g_gameQuit == 0) { - g_gameQuit = 1; - g_quitDeadline = totalclock+120; - g_netDisconnect = 1; + g_gameQuit = 1; + g_quitDeadline = totalclock+120; + g_netDisconnect = 1; } if ((totalclock > g_quitDeadline) && (g_gameQuit == 1)) @@ -818,7 +819,7 @@ static void Net_SendChallenge(void) void P_Disconnected(int32_t i) { // server obviously can't leave the game, and index 0 shows up for disconnect events from - // players that haven't gotten far enough into the connection process to get a player ID + // players that haven't gotten far enough into the connection process to get a player ID if (i == 0) return; @@ -866,8 +867,8 @@ void Net_SyncPlayer(ENetEvent * event) S_PlaySound(DUKE_GETWEAPON2); TRAVERSE_CONNECT(i) - if (!g_player[i].playerquitflag) - break; + if (!g_player[i].playerquitflag) + break; // no slots empty from players quitting, so open a new one if (i == -1) @@ -951,517 +952,517 @@ void Net_ParseServerPacket(ENetEvent * event) input_t *nsyn; #if 0 - initprintf("RECEIVED PACKET: type: %d : len %d\n", packbuf[0], packbufleng); + initprintf("RECEIVED PACKET: type: %d : len %d\n", packbuf[0], packbufleng); #endif - switch (packbuf[0]) + switch (packbuf[0]) + { + case PACKET_MASTER_TO_SLAVE: //[0] (receive master sync buffer) + if (!(g_player[myconnectindex].ps->gm & MODE_GAME)) return; + + j = 0; + + packbufleng = qlz_size_decompressed((char *)&packbuf[1]); + packbuf = Bcalloc(1, packbufleng+1); + packbufleng = qlz_decompress((char *)&event->packet->data[1], (char *)(packbuf), state_decompress); + + ticrandomseed = *(int32_t *)&packbuf[j]; + j += sizeof(int32_t); + ud.pause_on = packbuf[j++]; + + TRAVERSE_CONNECT(i) { - case PACKET_MASTER_TO_SLAVE: //[0] (receive master sync buffer) - if (!(g_player[myconnectindex].ps->gm & MODE_GAME)) return; + if (g_player[i].playerquitflag == 0) continue; - j = 0; + g_player[i].ps->dead_flag = *(int16_t *)&packbuf[j]; + j += sizeof(int16_t); - packbufleng = qlz_size_decompressed((char *)&packbuf[1]); - packbuf = Bcalloc(1, packbufleng+1); - packbufleng = qlz_decompress((char *)&event->packet->data[1], (char *)(packbuf), state_decompress); - - ticrandomseed = *(int32_t *)&packbuf[j]; - j += sizeof(int32_t); - ud.pause_on = packbuf[j++]; - - TRAVERSE_CONNECT(i) + if (i == myconnectindex && !g_player[i].ps->dead_flag) { - if (g_player[i].playerquitflag == 0) continue; + j += (sizeof(input_t) - sizeof(loc.filler)) + + (sizeof(vec3_t) * 3) + // position and velocity + (sizeof(int16_t) * 3); // ang and horiz + goto process; + } - g_player[i].ps->dead_flag = *(int16_t *)&packbuf[j]; - j += sizeof(int16_t); + nsyn = (input_t *)&inputfifo[0][0]; - if (i == myconnectindex && !g_player[i].ps->dead_flag) - { - j += (sizeof(input_t) - sizeof(loc.filler)) + - (sizeof(vec3_t) * 3) + // position and velocity - (sizeof(int16_t) * 3); // ang and horiz - goto process; - } + Bmemcpy(&nsyn[i], &packbuf[j], sizeof(input_t)); - nsyn = (input_t *)&inputfifo[0][0]; + j += sizeof(input_t)-sizeof(loc.filler); - Bmemcpy(&nsyn[i], &packbuf[j], sizeof(input_t)); - - j += sizeof(input_t)-sizeof(loc.filler); - - if (TEST_SYNC_KEY(nsyn[i].bits,SK_GAMEQUIT)) g_player[i].playerquitflag = 0; - g_player[i].movefifoend++; + if (TEST_SYNC_KEY(nsyn[i].bits,SK_GAMEQUIT)) g_player[i].playerquitflag = 0; + g_player[i].movefifoend++; // Bmemcpy(&g_player[i].ps->oposx, &g_player[i].ps->posx, sizeof(vec3_t)); - Bmemcpy(&g_player[i].ps->posx, &packbuf[j], sizeof(vec3_t) * 2); - updatesectorz(g_player[i].ps->posx, g_player[i].ps->posy, g_player[i].ps->posz, - &g_player[i].ps->cursectnum); - changespritesect(g_player[i].ps->i, g_player[i].ps->cursectnum); - Bmemcpy(&sprite[g_player[i].ps->i], &packbuf[j], sizeof(vec3_t)); - sprite[g_player[i].ps->i].z += PHEIGHT; - j += sizeof(vec3_t) * 2; + Bmemcpy(&g_player[i].ps->posx, &packbuf[j], sizeof(vec3_t) * 2); + updatesectorz(g_player[i].ps->posx, g_player[i].ps->posy, g_player[i].ps->posz, + &g_player[i].ps->cursectnum); + changespritesect(g_player[i].ps->i, g_player[i].ps->cursectnum); + Bmemcpy(&sprite[g_player[i].ps->i], &packbuf[j], sizeof(vec3_t)); + sprite[g_player[i].ps->i].z += PHEIGHT; + j += sizeof(vec3_t) * 2; - Bmemcpy(&g_player[i].ps->posxv, &packbuf[j], sizeof(vec3_t)); - j += sizeof(vec3_t); + Bmemcpy(&g_player[i].ps->posxv, &packbuf[j], sizeof(vec3_t)); + j += sizeof(vec3_t); - g_player[i].ps->oang = g_player[i].ps->ang; - g_player[i].ps->ang = sprite[g_player[i].ps->i].ang = *(int16_t *)&packbuf[j]; - j += sizeof(int16_t); + g_player[i].ps->oang = g_player[i].ps->ang; + g_player[i].ps->ang = sprite[g_player[i].ps->i].ang = *(int16_t *)&packbuf[j]; + j += sizeof(int16_t); - Bmemcpy(&g_player[i].ps->ohoriz, &g_player[i].ps->horiz, sizeof(int16_t) * 2); - Bmemcpy(&g_player[i].ps->horiz, &packbuf[j], sizeof(int16_t) * 2); - j += sizeof(int16_t) * 2; + Bmemcpy(&g_player[i].ps->ohoriz, &g_player[i].ps->horiz, sizeof(int16_t) * 2); + Bmemcpy(&g_player[i].ps->horiz, &packbuf[j], sizeof(int16_t) * 2); + j += sizeof(int16_t) * 2; process: - Bmemcpy(&g_player[i].ps->gotweapon[0], &packbuf[j], sizeof(g_player[i].ps->gotweapon)); - j += sizeof(g_player[i].ps->gotweapon); + Bmemcpy(&g_player[i].ps->gotweapon[0], &packbuf[j], sizeof(g_player[i].ps->gotweapon)); + j += sizeof(g_player[i].ps->gotweapon); - 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->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->inv_amount[0], &packbuf[j], sizeof(g_player[i].ps->inv_amount)); + j += sizeof(g_player[i].ps->inv_amount); - Bmemcpy(g_player[i].frags, &packbuf[j], sizeof(g_player[i].frags)); - j += sizeof(g_player[i].frags); + Bmemcpy(g_player[i].frags, &packbuf[j], sizeof(g_player[i].frags)); + j += sizeof(g_player[i].frags); - sprite[g_player[i].ps->i].extra = *(int16_t *)&packbuf[j]; - j += sizeof(int16_t); + sprite[g_player[i].ps->i].extra = *(int16_t *)&packbuf[j]; + j += sizeof(int16_t); - sprite[g_player[i].ps->i].cstat = *(int16_t *)&packbuf[j]; - j += sizeof(int16_t); + sprite[g_player[i].ps->i].cstat = *(int16_t *)&packbuf[j]; + j += sizeof(int16_t); - g_player[i].ps->kickback_pic = *(int16_t *)&packbuf[j]; - j += sizeof(int16_t); + g_player[i].ps->kickback_pic = *(int16_t *)&packbuf[j]; + j += sizeof(int16_t); - ActorExtra[g_player[i].ps->i].owner = *(int16_t *)&packbuf[j]; - j += sizeof(int16_t); + ActorExtra[g_player[i].ps->i].owner = *(int16_t *)&packbuf[j]; + j += sizeof(int16_t); - ActorExtra[g_player[i].ps->i].picnum = *(int16_t *)&packbuf[j]; - j += sizeof(int16_t); + ActorExtra[g_player[i].ps->i].picnum = *(int16_t *)&packbuf[j]; + j += sizeof(int16_t); - g_player[i].ps->curr_weapon = (int8_t)packbuf[j++]; - g_player[i].ps->last_weapon = (int8_t)packbuf[j++]; - g_player[i].ps->wantweaponfire = (int8_t)packbuf[j++]; - g_player[i].ps->frag_ps = (int8_t)packbuf[j++]; + g_player[i].ps->curr_weapon = (int8_t)packbuf[j++]; + g_player[i].ps->last_weapon = (int8_t)packbuf[j++]; + g_player[i].ps->wantweaponfire = (int8_t)packbuf[j++]; + g_player[i].ps->frag_ps = (int8_t)packbuf[j++]; - g_player[i].ps->frag = *(int16_t *)&packbuf[j]; - j += sizeof(int16_t); + g_player[i].ps->frag = *(int16_t *)&packbuf[j]; + j += sizeof(int16_t); - g_player[i].ps->fraggedself = *(int16_t *)&packbuf[j]; - j += sizeof(int16_t); + g_player[i].ps->fraggedself = *(int16_t *)&packbuf[j]; + j += sizeof(int16_t); - g_player[i].ps->last_extra = *(int16_t *)&packbuf[j]; - j += sizeof(int16_t); + g_player[i].ps->last_extra = *(int16_t *)&packbuf[j]; + j += sizeof(int16_t); - g_player[i].ping = *(int16_t *)&packbuf[j]; - j += sizeof(int16_t); + g_player[i].ping = *(int16_t *)&packbuf[j]; + j += sizeof(int16_t); - sprite[g_player[i].ps->i].pal = (int8_t)packbuf[j++]; + sprite[g_player[i].ps->i].pal = (int8_t)packbuf[j++]; - l = i; - - { - int16_t i = g_player[l].ps->i, jj = j++; - int32_t oa = (T5 >= (intptr_t)&script[0] && T5 < (intptr_t)&script[g_scriptSize]) ? T5-(intptr_t)&script[0] : T5; - - Bmemcpy(&T5, &packbuf[j], sizeof(T5)); - j += sizeof(T5); - - if (oa != T5) T3 = T4 = 0; - if (packbuf[jj] & 2) T5 += (intptr_t)&script[0]; - } - - i = l; - - do - { - int16_t var_id = *(int16_t *)&packbuf[j]; - - j += sizeof(int16_t); - - if (var_id == MAXGAMEVARS) break; - - aGameVars[var_id].val.plValues[i] = *(int32_t *)&packbuf[j]; - j += sizeof(int32_t); - } - while (1); - - i = l; - - do - { - int16_t var_id = *(int16_t *)&packbuf[j]; - - j += sizeof(int16_t); - - if (var_id == MAXGAMEVARS) break; - - aGameVars[var_id].val.plValues[i] = *(int32_t *)&packbuf[j]; - j += sizeof(int32_t); - } - while (1); - } + l = i; { - // sprite/sector/wall updates tacked on to the end of the packet + int16_t i = g_player[l].ps->i, jj = j++; + int32_t oa = (T5 >= (intptr_t)&script[0] && T5 < (intptr_t)&script[g_scriptSize]) ? T5-(intptr_t)&script[0] : T5; - l = packbuf[j++]; - while (l--) - { - int16_t i, sect, statnum, osect, ostatnum, jj, opicnum; -#ifdef POLYMER - int16_t lightid = -1; - _prlight *mylight = NULL; -#endif + Bmemcpy(&T5, &packbuf[j], sizeof(T5)); + j += sizeof(T5); - i = *(int16_t *)&packbuf[j]; - j += sizeof(int16_t); - - osect = sprite[i].sectnum; - ostatnum = sprite[i].statnum; - opicnum = sprite[i].picnum; - - Bmemcpy(&sprite[i], &packbuf[j], sizeof(spritetype)); - j += sizeof(spritetype); - - sect = sprite[i].sectnum; - statnum = sprite[i].statnum; - - sprite[i].sectnum = osect; - sprite[i].statnum = ostatnum; - - // doesn't exist on the client yet - if (ostatnum == MAXSTATUS || osect == MAXSECTORS) - { - int16_t sprs[MAXSPRITES], z = 0; - while ((sprs[z++] = insertsprite(sect, statnum)) != i); - z--; - while (z--) deletesprite(sprs[z]); - } - else - { - if (sect != osect) changespritesect(i, sect); - if (statnum != ostatnum) changespritestat(i, statnum); - } -#ifdef POLYMER - if (sprite[i].picnum == opicnum) - { - mylight = ActorExtra[i].lightptr; - lightid = ActorExtra[i].lightId; - } - else if (getrendermode() == 4 && ActorExtra[i].lightptr != NULL) - { - polymer_deletelight(ActorExtra[i].lightId); - ActorExtra[i].lightId = -1; - ActorExtra[i].lightptr = NULL; - } -#endif - - /*initprintf("updating sprite %d (%d)\n",i,sprite[i].picnum);*/ - - jj = j++; - - Bmemcpy(&ActorExtra[i], &packbuf[j], sizeof(NetActorData_t)); - j += sizeof(NetActorData_t); - - ActorExtra[i].projectile = &SpriteProjectile[i]; -#ifdef POLYMER - ActorExtra[i].lightptr = mylight; - ActorExtra[i].lightId = lightid; -#endif - - if (packbuf[jj] & 1) T2 += (intptr_t)&script[0]; - if (packbuf[jj] & 2) T5 += (intptr_t)&script[0]; - if (packbuf[jj] & 4) T6 += (intptr_t)&script[0]; - - do - { - int16_t var_id = *(int16_t *)&packbuf[j]; - - j += sizeof(int16_t); - - if (var_id == MAXGAMEVARS) break; - - aGameVars[var_id].val.plValues[i] = *(int32_t *)&packbuf[j]; - j += sizeof(int32_t); - } - while (1); - } - - l = packbuf[j++]; - while (l--) - { - int16_t secid = *(int16_t *)&packbuf[j]; - - Bmemcpy(§or[secid], &packbuf[j + sizeof(int16_t)], sizeof(sectortype)); - j += sizeof(int16_t) + sizeof(sectortype); - } - - l = packbuf[j++]; - while (l--) - { - int16_t wallid = *(int16_t *)&packbuf[j]; - - Bmemcpy(&wall[wallid], &packbuf[j + sizeof(int16_t)], sizeof(walltype)); - j += sizeof(int16_t) + sizeof(walltype); - // we call dragpoint() to make sure the nextwall position gets updated too - dragpoint(wallid, wall[wallid].x, wall[wallid].y); - } + if (oa != T5) T3 = T4 = 0; + if (packbuf[jj] & 2) T5 += (intptr_t)&script[0]; } - Bfree(packbuf); - // movefifosendplc++; + i = l; - break; - g_player[other].playerreadyflag++; - return; + do + { + int16_t var_id = *(int16_t *)&packbuf[j]; - case PACKET_MESSAGE: - //slaves in M/S mode only send to master - Bstrcpy(recbuf,(char *)packbuf+2); - recbuf[packbufleng-2] = 0; + j += sizeof(int16_t); - G_AddUserQuote(recbuf); - S_PlaySound(EXITMENUSOUND); + if (var_id == MAXGAMEVARS) break; - pus = NUMPAGES; - pub = NUMPAGES; + aGameVars[var_id].val.plValues[i] = *(int32_t *)&packbuf[j]; + j += sizeof(int32_t); + } + while (1); - break; + i = l; - case PACKET_NEW_GAME: - if ((vote_map + vote_episode + voting) != -3) - G_AddUserQuote("VOTE SUCCEEDED"); + do + { + int16_t var_id = *(int16_t *)&packbuf[j]; - ud.m_level_number = ud.level_number = packbuf[1]; - ud.m_volume_number = ud.volume_number = packbuf[2]; - ud.m_player_skill = ud.player_skill = packbuf[3]; - ud.m_monsters_off = ud.monsters_off = packbuf[4]; - ud.m_respawn_monsters = ud.respawn_monsters = packbuf[5]; - ud.m_respawn_items = ud.respawn_items = packbuf[6]; - ud.m_respawn_inventory = ud.respawn_inventory = packbuf[7]; - ud.m_coop = packbuf[8]; - ud.m_marker = ud.marker = packbuf[9]; - ud.m_ffire = ud.ffire = packbuf[10]; - ud.m_noexits = ud.noexits = packbuf[11]; + j += sizeof(int16_t); - TRAVERSE_CONNECT(i) - { - P_ResetWeapons(i); - P_ResetInventory(i); - } + if (var_id == MAXGAMEVARS) break; - G_NewGame(ud.volume_number,ud.level_number,ud.player_skill); - ud.coop = ud.m_coop; - - if (G_EnterLevel(MODE_GAME)) G_BackToMenu(); - - break; - - case PACKET_VERSION: - if (packbuf[1] != BYTEVERSION || packbuf[2] != (uint8_t)atoi(s_buildDate)) - { - Bsprintf(tempbuf, "Server protocol is version %d.%d, expecting %d.%d\n", - packbuf[1], packbuf[2], BYTEVERSION, (uint8_t)atoi(s_buildDate)); - initprintf(tempbuf); - initprintf("Version mismatch! You cannot play Duke with different versions!\n"); - g_netDisconnect = 1; - return; - } - Net_SendChallenge(); - break; - - case PACKET_NUM_PLAYERS: - numplayers = packbuf[1]; - playerswhenstarted = packbuf[2]; - ud.multimode = packbuf[3]; - if (packbuf[4]) // ID of new player - { - clearbufbyte(&g_player[packbuf[4]].playerquitflag,1,0x01010101); - - if (!g_player[packbuf[4]].ps) g_player[packbuf[4]].ps = (DukePlayer_t *) Bcalloc(1,sizeof(DukePlayer_t)); - if (!g_player[packbuf[4]].sync) g_player[packbuf[4]].sync = (input_t *) Bcalloc(1,sizeof(input_t)); - } - - for (i=0; ifrag_ps = packbuf[2]; - ActorExtra[g_player[packbuf[1]].ps->i].picnum = packbuf[3]; - P_FragPlayer(packbuf[1]); - break; - - case PACKET_CLIENT_INFO: - for (i=1; packbuf[i]; i++) - g_player[other].user_name[i-1] = packbuf[i]; - g_player[other].user_name[i-1] = 0; - i++; - - g_player[other].ps->aim_mode = packbuf[i++]; - g_player[other].ps->auto_aim = packbuf[i++]; - g_player[other].ps->weaponswitch = packbuf[i++]; - g_player[other].ps->palookup = g_player[other].pcolor = packbuf[i++]; - g_player[other].pteam = packbuf[i++]; - - j = i; - for (; i-j<10; i++) g_player[other].wchoice[i-j] = packbuf[i]; - - break; - - - case PACKET_RTS: - if (numlumps == 0) break; - - if (ud.config.SoundToggle == 0 || ud.lockout == 1 || ud.config.FXDevice < 0 || !(ud.config.VoiceToggle & 4)) - break; - FX_PlayAuto3D((char *)RTS_GetSound(packbuf[1]-1),RTS_SoundLength(packbuf[1]-1),0,0,0,255,-packbuf[1]); - g_RTSPlaying = 7; - - break; - - case PACKET_USER_MAP: - Bstrcpy(boardfilename,(char *)packbuf+1); - boardfilename[packbufleng-1] = 0; - Bcorrectfilename(boardfilename,0); - if (boardfilename[0] != 0) - { - if ((i = kopen4loadfrommod(boardfilename,0)) < 0) - { - Bmemset(boardfilename,0,sizeof(boardfilename)); - Net_SendUserMapName(); - } - else kclose(i); - } - - if (ud.m_level_number == 7 && ud.m_volume_number == 0 && boardfilename[0] == 0) - ud.m_level_number = 0; - - break; - - case PACKET_MAP_VOTE: - if (voting == myconnectindex && g_player[(uint8_t)packbuf[1]].gotvote == 0) - { - g_player[(uint8_t)packbuf[1]].gotvote = 1; - g_player[(uint8_t)packbuf[1]].vote = packbuf[2]; - Bsprintf(tempbuf,"CONFIRMED VOTE FROM %s",g_player[(uint8_t)packbuf[1]].user_name); - G_AddUserQuote(tempbuf); - } - break; - - case PACKET_MAP_VOTE_INITIATE: // call map vote - voting = packbuf[1]; - vote_episode = packbuf[2]; - vote_map = packbuf[3]; - - Bsprintf(tempbuf,"%s^00 HAS CALLED A VOTE TO CHANGE MAP TO %s (E%dL%d)", - g_player[(uint8_t)packbuf[1]].user_name, - MapInfo[(uint8_t)(packbuf[2]*MAXLEVELS + packbuf[3])].name, - packbuf[2]+1,packbuf[3]+1); - G_AddUserQuote(tempbuf); - - Bsprintf(tempbuf,"PRESS F1 TO ACCEPT, F2 TO DECLINE"); - G_AddUserQuote(tempbuf); - - for (i=MAXPLAYERS-1; i>=0; i--) - { - g_player[i].vote = 0; - g_player[i].gotvote = 0; - } - g_player[voting].gotvote = g_player[voting].vote = 1; - break; - - case PACKET_MAP_VOTE_CANCEL: // cancel map vote - if (voting == packbuf[1]) - { - voting = -1; - i = 0; - for (j=MAXPLAYERS-1; j>=0; j--) - i += g_player[j].gotvote; - - if (i != numplayers) - Bsprintf(tempbuf,"%s^00 HAS CANCELED THE VOTE",g_player[(uint8_t)packbuf[1]].user_name); - else Bsprintf(tempbuf,"VOTE FAILED"); - for (i=MAXPLAYERS-1; i>=0; i--) - { - g_player[i].vote = 0; - g_player[i].gotvote = 0; - } - G_AddUserQuote(tempbuf); - } - break; - - case PACKET_LOAD_GAME: - multiflag = 2; - multiwhat = 0; - multiwho = packbuf[2]; //other: need to send in m/s mode because of possible re-transmit - multipos = packbuf[1]; - G_LoadPlayer(multipos); - multiflag = 0; - break; - - case PACKET_REQUEST_GAMESTATE: - if (g_netServer && g_player[0].ps->gm & MODE_GAME) - { - packbuf[0] = PACKET_NEW_GAME; - packbuf[1] = ud.level_number; - packbuf[2] = ud.volume_number; - packbuf[3] = ud.player_skill+1; - packbuf[4] = ud.monsters_off; - packbuf[5] = ud.respawn_monsters; - packbuf[6] = ud.respawn_items; - packbuf[7] = ud.respawn_inventory; - packbuf[8] = ud.coop; - packbuf[9] = ud.marker; - packbuf[10] = ud.ffire; - packbuf[11] = ud.noexits; - packbuf[12] = myconnectindex; - - enet_peer_send(event->peer, CHAN_GAMESTATE, enet_packet_create(packbuf, 13, ENET_PACKET_FLAG_RELIABLE)); - - // a player connecting is a good time to mark everything as needing to be updated - Bmemset(spritecrc, 0, sizeof(spritecrc)); - Bmemset(sectcrc, 0, sizeof(sectcrc)); - Bmemset(wallcrc, 0, sizeof(wallcrc)); - Bmemset(peractorvals, 0, sizeof(peractorvals)); - Bmemset(perplayervals, 0, sizeof(perplayervals)); - } - break; + aGameVars[var_id].val.plValues[i] = *(int32_t *)&packbuf[j]; + j += sizeof(int32_t); + } + while (1); } + + { + // sprite/sector/wall updates tacked on to the end of the packet + + l = packbuf[j++]; + while (l--) + { + int16_t i, sect, statnum, osect, ostatnum, jj, opicnum; +#ifdef POLYMER + int16_t lightid = -1; + _prlight *mylight = NULL; +#endif + + i = *(int16_t *)&packbuf[j]; + j += sizeof(int16_t); + + osect = sprite[i].sectnum; + ostatnum = sprite[i].statnum; + opicnum = sprite[i].picnum; + + Bmemcpy(&sprite[i], &packbuf[j], sizeof(spritetype)); + j += sizeof(spritetype); + + sect = sprite[i].sectnum; + statnum = sprite[i].statnum; + + sprite[i].sectnum = osect; + sprite[i].statnum = ostatnum; + + // doesn't exist on the client yet + if (ostatnum == MAXSTATUS || osect == MAXSECTORS) + { + int16_t sprs[MAXSPRITES], z = 0; + while ((sprs[z++] = insertsprite(sect, statnum)) != i); + z--; + while (z--) deletesprite(sprs[z]); + } + else + { + if (sect != osect) changespritesect(i, sect); + if (statnum != ostatnum) changespritestat(i, statnum); + } +#ifdef POLYMER + if (sprite[i].picnum == opicnum) + { + mylight = ActorExtra[i].lightptr; + lightid = ActorExtra[i].lightId; + } + else if (getrendermode() == 4 && ActorExtra[i].lightptr != NULL) + { + polymer_deletelight(ActorExtra[i].lightId); + ActorExtra[i].lightId = -1; + ActorExtra[i].lightptr = NULL; + } +#endif + + /*initprintf("updating sprite %d (%d)\n",i,sprite[i].picnum);*/ + + jj = j++; + + Bmemcpy(&ActorExtra[i], &packbuf[j], sizeof(NetActorData_t)); + j += sizeof(NetActorData_t); + + ActorExtra[i].projectile = &SpriteProjectile[i]; +#ifdef POLYMER + ActorExtra[i].lightptr = mylight; + ActorExtra[i].lightId = lightid; +#endif + + if (packbuf[jj] & 1) T2 += (intptr_t)&script[0]; + if (packbuf[jj] & 2) T5 += (intptr_t)&script[0]; + if (packbuf[jj] & 4) T6 += (intptr_t)&script[0]; + + do + { + int16_t var_id = *(int16_t *)&packbuf[j]; + + j += sizeof(int16_t); + + if (var_id == MAXGAMEVARS) break; + + aGameVars[var_id].val.plValues[i] = *(int32_t *)&packbuf[j]; + j += sizeof(int32_t); + } + while (1); + } + + l = packbuf[j++]; + while (l--) + { + int16_t secid = *(int16_t *)&packbuf[j]; + + Bmemcpy(§or[secid], &packbuf[j + sizeof(int16_t)], sizeof(sectortype)); + j += sizeof(int16_t) + sizeof(sectortype); + } + + l = packbuf[j++]; + while (l--) + { + int16_t wallid = *(int16_t *)&packbuf[j]; + + Bmemcpy(&wall[wallid], &packbuf[j + sizeof(int16_t)], sizeof(walltype)); + j += sizeof(int16_t) + sizeof(walltype); + // we call dragpoint() to make sure the nextwall position gets updated too + dragpoint(wallid, wall[wallid].x, wall[wallid].y); + } + } + + Bfree(packbuf); + // movefifosendplc++; + + break; + g_player[other].playerreadyflag++; + return; + + case PACKET_MESSAGE: + //slaves in M/S mode only send to master + Bstrcpy(recbuf,(char *)packbuf+2); + recbuf[packbufleng-2] = 0; + + G_AddUserQuote(recbuf); + S_PlaySound(EXITMENUSOUND); + + pus = NUMPAGES; + pub = NUMPAGES; + + break; + + case PACKET_NEW_GAME: + if ((vote_map + vote_episode + voting) != -3) + G_AddUserQuote("VOTE SUCCEEDED"); + + ud.m_level_number = ud.level_number = packbuf[1]; + ud.m_volume_number = ud.volume_number = packbuf[2]; + ud.m_player_skill = ud.player_skill = packbuf[3]; + ud.m_monsters_off = ud.monsters_off = packbuf[4]; + ud.m_respawn_monsters = ud.respawn_monsters = packbuf[5]; + ud.m_respawn_items = ud.respawn_items = packbuf[6]; + ud.m_respawn_inventory = ud.respawn_inventory = packbuf[7]; + ud.m_coop = packbuf[8]; + ud.m_marker = ud.marker = packbuf[9]; + ud.m_ffire = ud.ffire = packbuf[10]; + ud.m_noexits = ud.noexits = packbuf[11]; + + TRAVERSE_CONNECT(i) + { + P_ResetWeapons(i); + P_ResetInventory(i); + } + + G_NewGame(ud.volume_number,ud.level_number,ud.player_skill); + ud.coop = ud.m_coop; + + if (G_EnterLevel(MODE_GAME)) G_BackToMenu(); + + break; + + case PACKET_VERSION: + if (packbuf[1] != BYTEVERSION || packbuf[2] != (uint8_t)atoi(s_buildDate)) + { + Bsprintf(tempbuf, "Server protocol is version %d.%d, expecting %d.%d\n", + packbuf[1], packbuf[2], BYTEVERSION, (uint8_t)atoi(s_buildDate)); + initprintf(tempbuf); + initprintf("Version mismatch! You cannot play Duke with different versions!\n"); + g_netDisconnect = 1; + return; + } + Net_SendChallenge(); + break; + + case PACKET_NUM_PLAYERS: + numplayers = packbuf[1]; + playerswhenstarted = packbuf[2]; + ud.multimode = packbuf[3]; + if (packbuf[4]) // ID of new player + { + clearbufbyte(&g_player[packbuf[4]].playerquitflag,1,0x01010101); + + if (!g_player[packbuf[4]].ps) g_player[packbuf[4]].ps = (DukePlayer_t *) Bcalloc(1,sizeof(DukePlayer_t)); + if (!g_player[packbuf[4]].sync) g_player[packbuf[4]].sync = (input_t *) Bcalloc(1,sizeof(input_t)); + } + + for (i=0; ifrag_ps = packbuf[2]; + ActorExtra[g_player[packbuf[1]].ps->i].picnum = packbuf[3]; + P_FragPlayer(packbuf[1]); + break; + + case PACKET_CLIENT_INFO: + for (i=1; packbuf[i]; i++) + g_player[other].user_name[i-1] = packbuf[i]; + g_player[other].user_name[i-1] = 0; + i++; + + g_player[other].ps->aim_mode = packbuf[i++]; + g_player[other].ps->auto_aim = packbuf[i++]; + g_player[other].ps->weaponswitch = packbuf[i++]; + g_player[other].ps->palookup = g_player[other].pcolor = packbuf[i++]; + g_player[other].pteam = packbuf[i++]; + + j = i; + for (; i-j<10; i++) g_player[other].wchoice[i-j] = packbuf[i]; + + break; + + + case PACKET_RTS: + if (numlumps == 0) break; + + if (ud.config.SoundToggle == 0 || ud.lockout == 1 || ud.config.FXDevice < 0 || !(ud.config.VoiceToggle & 4)) + break; + FX_PlayAuto3D((char *)RTS_GetSound(packbuf[1]-1),RTS_SoundLength(packbuf[1]-1),0,0,0,255,-packbuf[1]); + g_RTSPlaying = 7; + + break; + + case PACKET_USER_MAP: + Bstrcpy(boardfilename,(char *)packbuf+1); + boardfilename[packbufleng-1] = 0; + Bcorrectfilename(boardfilename,0); + if (boardfilename[0] != 0) + { + if ((i = kopen4loadfrommod(boardfilename,0)) < 0) + { + Bmemset(boardfilename,0,sizeof(boardfilename)); + Net_SendUserMapName(); + } + else kclose(i); + } + + if (ud.m_level_number == 7 && ud.m_volume_number == 0 && boardfilename[0] == 0) + ud.m_level_number = 0; + + break; + + case PACKET_MAP_VOTE: + if (voting == myconnectindex && g_player[(uint8_t)packbuf[1]].gotvote == 0) + { + g_player[(uint8_t)packbuf[1]].gotvote = 1; + g_player[(uint8_t)packbuf[1]].vote = packbuf[2]; + Bsprintf(tempbuf,"CONFIRMED VOTE FROM %s",g_player[(uint8_t)packbuf[1]].user_name); + G_AddUserQuote(tempbuf); + } + break; + + case PACKET_MAP_VOTE_INITIATE: // call map vote + voting = packbuf[1]; + vote_episode = packbuf[2]; + vote_map = packbuf[3]; + + Bsprintf(tempbuf,"%s^00 HAS CALLED A VOTE TO CHANGE MAP TO %s (E%dL%d)", + g_player[(uint8_t)packbuf[1]].user_name, + MapInfo[(uint8_t)(packbuf[2]*MAXLEVELS + packbuf[3])].name, + packbuf[2]+1,packbuf[3]+1); + G_AddUserQuote(tempbuf); + + Bsprintf(tempbuf,"PRESS F1 TO ACCEPT, F2 TO DECLINE"); + G_AddUserQuote(tempbuf); + + for (i=MAXPLAYERS-1; i>=0; i--) + { + g_player[i].vote = 0; + g_player[i].gotvote = 0; + } + g_player[voting].gotvote = g_player[voting].vote = 1; + break; + + case PACKET_MAP_VOTE_CANCEL: // cancel map vote + if (voting == packbuf[1]) + { + voting = -1; + i = 0; + for (j=MAXPLAYERS-1; j>=0; j--) + i += g_player[j].gotvote; + + if (i != numplayers) + Bsprintf(tempbuf,"%s^00 HAS CANCELED THE VOTE",g_player[(uint8_t)packbuf[1]].user_name); + else Bsprintf(tempbuf,"VOTE FAILED"); + for (i=MAXPLAYERS-1; i>=0; i--) + { + g_player[i].vote = 0; + g_player[i].gotvote = 0; + } + G_AddUserQuote(tempbuf); + } + break; + + case PACKET_LOAD_GAME: + multiflag = 2; + multiwhat = 0; + multiwho = packbuf[2]; //other: need to send in m/s mode because of possible re-transmit + multipos = packbuf[1]; + G_LoadPlayer(multipos); + multiflag = 0; + break; + + case PACKET_REQUEST_GAMESTATE: + if (g_netServer && g_player[0].ps->gm & MODE_GAME) + { + packbuf[0] = PACKET_NEW_GAME; + packbuf[1] = ud.level_number; + packbuf[2] = ud.volume_number; + packbuf[3] = ud.player_skill+1; + packbuf[4] = ud.monsters_off; + packbuf[5] = ud.respawn_monsters; + packbuf[6] = ud.respawn_items; + packbuf[7] = ud.respawn_inventory; + packbuf[8] = ud.coop; + packbuf[9] = ud.marker; + packbuf[10] = ud.ffire; + packbuf[11] = ud.noexits; + packbuf[12] = myconnectindex; + + enet_peer_send(event->peer, CHAN_GAMESTATE, enet_packet_create(packbuf, 13, ENET_PACKET_FLAG_RELIABLE)); + + // a player connecting is a good time to mark everything as needing to be updated + Bmemset(spritecrc, 0, sizeof(spritecrc)); + Bmemset(sectcrc, 0, sizeof(sectcrc)); + Bmemset(wallcrc, 0, sizeof(wallcrc)); + Bmemset(peractorvals, 0, sizeof(peractorvals)); + Bmemset(perplayervals, 0, sizeof(perplayervals)); + } + break; + } } void Net_ParseClientPacket(ENetEvent * event) @@ -1477,264 +1478,264 @@ void Net_ParseClientPacket(ENetEvent * event) #endif switch (packbuf[0]) { - case PACKET_SLAVE_TO_MASTER: //[1] (receive slave sync buffer) - j = 0; + case PACKET_SLAVE_TO_MASTER: //[1] (receive slave sync buffer) + j = 0; - packbufleng = qlz_size_decompressed((char *)&packbuf[1]); - packbuf = Bcalloc(1, packbufleng+1); - packbufleng = qlz_decompress((char *)&event->packet->data[1], (char *)(packbuf), state_decompress); + packbufleng = qlz_size_decompressed((char *)&packbuf[1]); + packbuf = Bcalloc(1, packbufleng+1); + packbufleng = qlz_decompress((char *)&event->packet->data[1], (char *)(packbuf), state_decompress); - nsyn = (input_t *)&inputfifo[0][0]; + nsyn = (input_t *)&inputfifo[0][0]; - Bmemcpy(&nsyn[other], &packbuf[j], sizeof(input_t)); + Bmemcpy(&nsyn[other], &packbuf[j], sizeof(input_t)); - j += sizeof(input_t)-sizeof(loc.filler); + j += sizeof(input_t)-sizeof(loc.filler); - g_player[other].movefifoend++; - - // anyone the server thinks is dead can go fuck themselves - if (g_player[other].ps->dead_flag) - { - Bfree(packbuf); - break; - } - -// Bmemcpy(&g_player[other].ps->oposx, &g_player[other].ps->posx, sizeof(vec3_t)); - Bmemcpy(&g_player[other].ps->posx, &packbuf[j], sizeof(vec3_t) * 2); - updatesectorz(g_player[other].ps->posx, g_player[other].ps->posy, g_player[other].ps->posz, - &g_player[other].ps->cursectnum); - Bmemcpy(&sprite[g_player[other].ps->i], &packbuf[j], sizeof(vec3_t)); - sprite[g_player[other].ps->i].z += PHEIGHT; - changespritesect(g_player[other].ps->i, g_player[other].ps->cursectnum); - j += sizeof(vec3_t) * 2; - - Bmemcpy(&g_player[other].ps->posxv, &packbuf[j], sizeof(vec3_t)); - j += sizeof(vec3_t); - - g_player[other].ps->oang = g_player[other].ps->ang; - Bmemcpy(&g_player[other].ps->ang, &packbuf[j], sizeof(int16_t)); - Bmemcpy(&sprite[g_player[other].ps->i].ang, &packbuf[j], sizeof(int16_t)); - j += sizeof(int16_t); - - Bmemcpy(&g_player[other].ps->ohoriz, &g_player[other].ps->horiz, sizeof(int16_t) * 2); - Bmemcpy(&g_player[other].ps->horiz, &packbuf[j], sizeof(int16_t) * 2); - j += sizeof(int16_t) * 2; - -/* - { - int16_t i = g_player[other].ps->i, jj = j++; - int32_t oa = (T5 >= (intptr_t)&script[0] && T5 < (intptr_t)&script[g_scriptSize]) ? T5-(intptr_t)&script[0] : T5; - - Bmemcpy(&T5, &packbuf[j], sizeof(T5)); - j += sizeof(T5); - - if (oa != T5) T3 = T4 = 0; - if (packbuf[jj] & 2) T5 += (intptr_t)&script[0]; - } -*/ + g_player[other].movefifoend++; + // anyone the server thinks is dead can go fuck themselves + if (g_player[other].ps->dead_flag) + { Bfree(packbuf); break; + } - case PACKET_PLAYER_READY: - if (g_player[myconnectindex].ps->gm & MODE_GAME) +// Bmemcpy(&g_player[other].ps->oposx, &g_player[other].ps->posx, sizeof(vec3_t)); + Bmemcpy(&g_player[other].ps->posx, &packbuf[j], sizeof(vec3_t) * 2); + updatesectorz(g_player[other].ps->posx, g_player[other].ps->posy, g_player[other].ps->posz, + &g_player[other].ps->cursectnum); + Bmemcpy(&sprite[g_player[other].ps->i], &packbuf[j], sizeof(vec3_t)); + sprite[g_player[other].ps->i].z += PHEIGHT; + changespritesect(g_player[other].ps->i, g_player[other].ps->cursectnum); + j += sizeof(vec3_t) * 2; + + Bmemcpy(&g_player[other].ps->posxv, &packbuf[j], sizeof(vec3_t)); + j += sizeof(vec3_t); + + g_player[other].ps->oang = g_player[other].ps->ang; + Bmemcpy(&g_player[other].ps->ang, &packbuf[j], sizeof(int16_t)); + Bmemcpy(&sprite[g_player[other].ps->i].ang, &packbuf[j], sizeof(int16_t)); + j += sizeof(int16_t); + + Bmemcpy(&g_player[other].ps->ohoriz, &g_player[other].ps->horiz, sizeof(int16_t) * 2); + Bmemcpy(&g_player[other].ps->horiz, &packbuf[j], sizeof(int16_t) * 2); + j += sizeof(int16_t) * 2; + + /* + { + int16_t i = g_player[other].ps->i, jj = j++; + int32_t oa = (T5 >= (intptr_t)&script[0] && T5 < (intptr_t)&script[g_scriptSize]) ? T5-(intptr_t)&script[0] : T5; + + Bmemcpy(&T5, &packbuf[j], sizeof(T5)); + j += sizeof(T5); + + if (oa != T5) T3 = T4 = 0; + if (packbuf[jj] & 2) T5 += (intptr_t)&script[0]; + } + */ + + Bfree(packbuf); + break; + + case PACKET_PLAYER_READY: + if (g_player[myconnectindex].ps->gm & MODE_GAME) + { + packbuf[0] = PACKET_PLAYER_READY; + packbuf[1] = myconnectindex; + enet_peer_send(event->peer, CHAN_GAMESTATE, enet_packet_create(packbuf, 2, ENET_PACKET_FLAG_RELIABLE)); + } + g_player[other].playerreadyflag++; + return; + + case PACKET_MESSAGE: + //slaves in M/S mode only send to master + Bstrcpy(recbuf,(char *)packbuf+2); + recbuf[packbufleng-2] = 0; + + G_AddUserQuote(recbuf); + S_PlaySound(EXITMENUSOUND); + + pus = pub = NUMPAGES; + + break; + + case PACKET_NEW_GAME: + if ((vote_map + vote_episode + voting) != -3) + G_AddUserQuote("VOTE SUCCEEDED"); + + ud.m_level_number = ud.level_number = packbuf[1]; + ud.m_volume_number = ud.volume_number = packbuf[2]; + ud.m_player_skill = ud.player_skill = packbuf[3]; + ud.m_monsters_off = ud.monsters_off = packbuf[4]; + ud.m_respawn_monsters = ud.respawn_monsters = packbuf[5]; + ud.m_respawn_items = ud.respawn_items = packbuf[6]; + ud.m_respawn_inventory = ud.respawn_inventory = packbuf[7]; + ud.m_coop = packbuf[8]; + ud.m_marker = ud.marker = packbuf[9]; + ud.m_ffire = ud.ffire = packbuf[10]; + ud.m_noexits = ud.noexits = packbuf[11]; + + TRAVERSE_CONNECT(i) + { + P_ResetWeapons(i); + P_ResetInventory(i); + } + + G_NewGame(ud.volume_number,ud.level_number,ud.player_skill); + ud.coop = ud.m_coop; + + if (G_EnterLevel(MODE_GAME)) G_BackToMenu(); + + break; + + case PACKET_AUTH: + { + uint32_t crc = *(uint32_t *)&packbuf[1]; + + if (crc == crc32once((uint8_t *)g_netPassword, Bstrlen(g_netPassword))) + Net_SyncPlayer(event); + else + { + enet_peer_disconnect_later(event->peer, DISC_BAD_PASSWORD); + initprintf("Bad password from client.\n"); + } + } + break; + + case PACKET_CLIENT_INFO: + for (i=1; packbuf[i]; i++) + g_player[other].user_name[i-1] = packbuf[i]; + g_player[other].user_name[i-1] = 0; + i++; + + g_player[other].ps->aim_mode = packbuf[i++]; + g_player[other].ps->auto_aim = packbuf[i++]; + g_player[other].ps->weaponswitch = packbuf[i++]; + g_player[other].ps->palookup = g_player[other].pcolor = packbuf[i++]; + g_player[other].pteam = packbuf[i++]; + + j = i; + for (; i-j<10; i++) g_player[other].wchoice[i-j] = packbuf[i]; + + break; + + case PACKET_RTS: + if (numlumps == 0) break; + + if (ud.config.SoundToggle == 0 || ud.lockout == 1 || ud.config.FXDevice < 0 || !(ud.config.VoiceToggle & 4)) + break; + FX_PlayAuto3D((char *)RTS_GetSound(packbuf[1]-1),RTS_SoundLength(packbuf[1]-1),0,0,0,255,-packbuf[1]); + g_RTSPlaying = 7; + + break; + + case PACKET_USER_MAP: + Bstrcpy(boardfilename,(char *)packbuf+1); + boardfilename[packbufleng-1] = 0; + Bcorrectfilename(boardfilename,0); + if (boardfilename[0] != 0) + { + if ((i = kopen4loadfrommod(boardfilename,0)) < 0) { - packbuf[0] = PACKET_PLAYER_READY; - packbuf[1] = myconnectindex; - enet_peer_send(event->peer, CHAN_GAMESTATE, enet_packet_create(packbuf, 2, ENET_PACKET_FLAG_RELIABLE)); + Bmemset(boardfilename,0,sizeof(boardfilename)); + Net_SendUserMapName(); } - g_player[other].playerreadyflag++; - return; + else kclose(i); + } - case PACKET_MESSAGE: - //slaves in M/S mode only send to master - Bstrcpy(recbuf,(char *)packbuf+2); - recbuf[packbufleng-2] = 0; + if (ud.m_level_number == 7 && ud.m_volume_number == 0 && boardfilename[0] == 0) + ud.m_level_number = 0; - G_AddUserQuote(recbuf); - S_PlaySound(EXITMENUSOUND); + break; - pus = pub = NUMPAGES; - - break; - - case PACKET_NEW_GAME: - if ((vote_map + vote_episode + voting) != -3) - G_AddUserQuote("VOTE SUCCEEDED"); - - ud.m_level_number = ud.level_number = packbuf[1]; - ud.m_volume_number = ud.volume_number = packbuf[2]; - ud.m_player_skill = ud.player_skill = packbuf[3]; - ud.m_monsters_off = ud.monsters_off = packbuf[4]; - ud.m_respawn_monsters = ud.respawn_monsters = packbuf[5]; - ud.m_respawn_items = ud.respawn_items = packbuf[6]; - ud.m_respawn_inventory = ud.respawn_inventory = packbuf[7]; - ud.m_coop = packbuf[8]; - ud.m_marker = ud.marker = packbuf[9]; - ud.m_ffire = ud.ffire = packbuf[10]; - ud.m_noexits = ud.noexits = packbuf[11]; - - TRAVERSE_CONNECT(i) - { - P_ResetWeapons(i); - P_ResetInventory(i); - } - - G_NewGame(ud.volume_number,ud.level_number,ud.player_skill); - ud.coop = ud.m_coop; - - if (G_EnterLevel(MODE_GAME)) G_BackToMenu(); - - break; - - case PACKET_AUTH: - { - uint32_t crc = *(uint32_t *)&packbuf[1]; - - if (crc == crc32once((uint8_t *)g_netPassword, Bstrlen(g_netPassword))) - Net_SyncPlayer(event); - else - { - enet_peer_disconnect_later(event->peer, DISC_BAD_PASSWORD); - initprintf("Bad password from client.\n"); - } - } - break; - - case PACKET_CLIENT_INFO: - for (i=1; packbuf[i]; i++) - g_player[other].user_name[i-1] = packbuf[i]; - g_player[other].user_name[i-1] = 0; - i++; - - g_player[other].ps->aim_mode = packbuf[i++]; - g_player[other].ps->auto_aim = packbuf[i++]; - g_player[other].ps->weaponswitch = packbuf[i++]; - g_player[other].ps->palookup = g_player[other].pcolor = packbuf[i++]; - g_player[other].pteam = packbuf[i++]; - - j = i; - for (; i-j<10; i++) g_player[other].wchoice[i-j] = packbuf[i]; - - break; - - case PACKET_RTS: - if (numlumps == 0) break; - - if (ud.config.SoundToggle == 0 || ud.lockout == 1 || ud.config.FXDevice < 0 || !(ud.config.VoiceToggle & 4)) - break; - FX_PlayAuto3D((char *)RTS_GetSound(packbuf[1]-1),RTS_SoundLength(packbuf[1]-1),0,0,0,255,-packbuf[1]); - g_RTSPlaying = 7; - - break; - - case PACKET_USER_MAP: - Bstrcpy(boardfilename,(char *)packbuf+1); - boardfilename[packbufleng-1] = 0; - Bcorrectfilename(boardfilename,0); - if (boardfilename[0] != 0) - { - if ((i = kopen4loadfrommod(boardfilename,0)) < 0) - { - Bmemset(boardfilename,0,sizeof(boardfilename)); - Net_SendUserMapName(); - } - else kclose(i); - } - - if (ud.m_level_number == 7 && ud.m_volume_number == 0 && boardfilename[0] == 0) - ud.m_level_number = 0; - - break; - - case PACKET_MAP_VOTE: - if (voting == myconnectindex && g_player[(uint8_t)packbuf[1]].gotvote == 0) - { - g_player[(uint8_t)packbuf[1]].gotvote = 1; - g_player[(uint8_t)packbuf[1]].vote = packbuf[2]; - Bsprintf(tempbuf,"CONFIRMED VOTE FROM %s",g_player[(uint8_t)packbuf[1]].user_name); - G_AddUserQuote(tempbuf); - } - break; - - case PACKET_MAP_VOTE_INITIATE: // call map vote - voting = packbuf[1]; - vote_episode = packbuf[2]; - vote_map = packbuf[3]; - - Bsprintf(tempbuf,"%s^00 HAS CALLED A VOTE TO CHANGE MAP TO %s (E%dL%d)", - g_player[(uint8_t)packbuf[1]].user_name, - MapInfo[(uint8_t)(packbuf[2]*MAXLEVELS + packbuf[3])].name, - packbuf[2]+1,packbuf[3]+1); + case PACKET_MAP_VOTE: + if (voting == myconnectindex && g_player[(uint8_t)packbuf[1]].gotvote == 0) + { + g_player[(uint8_t)packbuf[1]].gotvote = 1; + g_player[(uint8_t)packbuf[1]].vote = packbuf[2]; + Bsprintf(tempbuf,"CONFIRMED VOTE FROM %s",g_player[(uint8_t)packbuf[1]].user_name); G_AddUserQuote(tempbuf); + } + break; - Bsprintf(tempbuf,"PRESS F1 TO ACCEPT, F2 TO DECLINE"); - G_AddUserQuote(tempbuf); + case PACKET_MAP_VOTE_INITIATE: // call map vote + voting = packbuf[1]; + vote_episode = packbuf[2]; + vote_map = packbuf[3]; + Bsprintf(tempbuf,"%s^00 HAS CALLED A VOTE TO CHANGE MAP TO %s (E%dL%d)", + g_player[(uint8_t)packbuf[1]].user_name, + MapInfo[(uint8_t)(packbuf[2]*MAXLEVELS + packbuf[3])].name, + packbuf[2]+1,packbuf[3]+1); + G_AddUserQuote(tempbuf); + + Bsprintf(tempbuf,"PRESS F1 TO ACCEPT, F2 TO DECLINE"); + G_AddUserQuote(tempbuf); + + for (i=MAXPLAYERS-1; i>=0; i--) + { + g_player[i].vote = 0; + g_player[i].gotvote = 0; + } + g_player[voting].gotvote = g_player[voting].vote = 1; + break; + + case PACKET_MAP_VOTE_CANCEL: // cancel map vote + if (voting == packbuf[1]) + { + voting = -1; + i = 0; + for (j=MAXPLAYERS-1; j>=0; j--) + i += g_player[j].gotvote; + + if (i != numplayers) + Bsprintf(tempbuf,"%s^00 HAS CANCELED THE VOTE",g_player[(uint8_t)packbuf[1]].user_name); + else Bsprintf(tempbuf,"VOTE FAILED"); for (i=MAXPLAYERS-1; i>=0; i--) { g_player[i].vote = 0; g_player[i].gotvote = 0; } - g_player[voting].gotvote = g_player[voting].vote = 1; - break; + G_AddUserQuote(tempbuf); + } + break; - case PACKET_MAP_VOTE_CANCEL: // cancel map vote - if (voting == packbuf[1]) - { - voting = -1; - i = 0; - for (j=MAXPLAYERS-1; j>=0; j--) - i += g_player[j].gotvote; + case PACKET_LOAD_GAME: + multiflag = 2; + multiwhat = 0; + multiwho = packbuf[2]; //other: need to send in m/s mode because of possible re-transmit + multipos = packbuf[1]; + G_LoadPlayer(multipos); + multiflag = 0; + break; - if (i != numplayers) - Bsprintf(tempbuf,"%s^00 HAS CANCELED THE VOTE",g_player[(uint8_t)packbuf[1]].user_name); - else Bsprintf(tempbuf,"VOTE FAILED"); - for (i=MAXPLAYERS-1; i>=0; i--) - { - g_player[i].vote = 0; - g_player[i].gotvote = 0; - } - G_AddUserQuote(tempbuf); - } - break; + case PACKET_REQUEST_GAMESTATE: + if (g_netServer && g_player[0].ps->gm & MODE_GAME) + { + packbuf[0] = PACKET_NEW_GAME; + packbuf[1] = ud.level_number; + packbuf[2] = ud.volume_number; + packbuf[3] = ud.player_skill+1; + packbuf[4] = ud.monsters_off; + packbuf[5] = ud.respawn_monsters; + packbuf[6] = ud.respawn_items; + packbuf[7] = ud.respawn_inventory; + packbuf[8] = ud.coop; + packbuf[9] = ud.marker; + packbuf[10] = ud.ffire; + packbuf[11] = ud.noexits; + packbuf[12] = myconnectindex; - case PACKET_LOAD_GAME: - multiflag = 2; - multiwhat = 0; - multiwho = packbuf[2]; //other: need to send in m/s mode because of possible re-transmit - multipos = packbuf[1]; - G_LoadPlayer(multipos); - multiflag = 0; - break; + enet_peer_send(event->peer, CHAN_GAMESTATE, enet_packet_create(packbuf, 13, ENET_PACKET_FLAG_RELIABLE)); - case PACKET_REQUEST_GAMESTATE: - if (g_netServer && g_player[0].ps->gm & MODE_GAME) - { - packbuf[0] = PACKET_NEW_GAME; - packbuf[1] = ud.level_number; - packbuf[2] = ud.volume_number; - packbuf[3] = ud.player_skill+1; - packbuf[4] = ud.monsters_off; - packbuf[5] = ud.respawn_monsters; - packbuf[6] = ud.respawn_items; - packbuf[7] = ud.respawn_inventory; - packbuf[8] = ud.coop; - packbuf[9] = ud.marker; - packbuf[10] = ud.ffire; - packbuf[11] = ud.noexits; - packbuf[12] = myconnectindex; - - enet_peer_send(event->peer, CHAN_GAMESTATE, enet_packet_create(packbuf, 13, ENET_PACKET_FLAG_RELIABLE)); - - // a player connecting is a good time to mark everything as needing to be updated - Bmemset(spritecrc, 0, sizeof(spritecrc)); - Bmemset(sectcrc, 0, sizeof(sectcrc)); - Bmemset(wallcrc, 0, sizeof(wallcrc)); - Bmemset(peractorvals, 0, sizeof(peractorvals)); - Bmemset(perplayervals, 0, sizeof(perplayervals)); - } - break; + // a player connecting is a good time to mark everything as needing to be updated + Bmemset(spritecrc, 0, sizeof(spritecrc)); + Bmemset(sectcrc, 0, sizeof(sectcrc)); + Bmemset(wallcrc, 0, sizeof(wallcrc)); + Bmemset(peractorvals, 0, sizeof(peractorvals)); + Bmemset(perplayervals, 0, sizeof(perplayervals)); + } + break; } } @@ -1762,32 +1763,32 @@ void Net_GetPackets(void) ENetEvent event; // pull events from the wire into the packet queue without dispatching them, once per Net_GetPackets() call - enet_host_service (g_netServer, NULL, 0); + enet_host_service(g_netServer, NULL, 0); // dispatch any pending events from the local packet queue - while (enet_host_check_events (g_netServer, &event) > 0) + while (enet_host_check_events(g_netServer, &event) > 0) { switch (event.type) { case ENET_EVENT_TYPE_CONNECT: - { - char ipaddr[32]; + { + char ipaddr[32]; - enet_address_get_host_ip(&event.peer->address, ipaddr, sizeof(ipaddr)); + enet_address_get_host_ip(&event.peer->address, ipaddr, sizeof(ipaddr)); - initprintf ("A new client connected from %s:%u.\n", - ipaddr, event.peer -> address.port); - } - Net_SendVersion(event.peer); - break; + initprintf("A new client connected from %s:%u.\n", + ipaddr, event.peer -> address.port); + } + Net_SendVersion(event.peer); + break; case ENET_EVENT_TYPE_RECEIVE: -/* - initprintf ("A packet of length %u containing %s was received from player %d on channel %u.\n", - event.packet -> dataLength, - event.packet -> data, - event.peer -> data, - event.channelID); -*/ + /* + initprintf ("A packet of length %u containing %s was received from player %d on channel %u.\n", + event.packet -> dataLength, + event.packet -> data, + event.peer -> data, + event.channelID); + */ Net_ParseClientPacket(&event); // broadcast takes care of enet_packet_destroy itself // we set the state to disconnected so enet_host_broadcast doesn't send the player back his own packets @@ -1813,7 +1814,7 @@ void Net_GetPackets(void) packbuf[2] = myconnectindex; enet_host_broadcast(g_netServer, CHAN_GAMESTATE, enet_packet_create(packbuf, 3, ENET_PACKET_FLAG_RELIABLE)); - initprintf ("%s disconnected.\n", g_player[(intptr_t)event.peer->data].user_name); + initprintf("%s disconnected.\n", g_player[(intptr_t)event.peer->data].user_name); event.peer->data = NULL; break; default: @@ -1825,18 +1826,18 @@ void Net_GetPackets(void) { ENetEvent event; - enet_host_service (g_netClient, NULL, 0); + enet_host_service(g_netClient, NULL, 0); - while (enet_host_check_events (g_netClient, &event) > 0) + while (enet_host_check_events(g_netClient, &event) > 0) { switch (event.type) { case ENET_EVENT_TYPE_RECEIVE: - initprintf ("A packet of length %u was received from player %d on channel %u.\n", - event.packet -> dataLength, - event.peer -> data, - event.channelID); + initprintf("A packet of length %u was received from player %d on channel %u.\n", + event.packet -> dataLength, + event.peer -> data, + event.channelID); // mapstate transfer from the server... all packets but the last are exactly 1 kB if (event.channelID == CHAN_SYNC) @@ -1888,7 +1889,7 @@ void Net_GetPackets(void) } else Net_ParseServerPacket(&event); - enet_packet_destroy (event.packet); + enet_packet_destroy(event.packet); break; case ENET_EVENT_TYPE_DISCONNECT: g_netDisconnect = 1; @@ -3370,8 +3371,8 @@ static void G_PrintFPS(void) // lag meter if (g_netClientPeer) { - chars = Bsprintf(tempbuf, "%d +- %d ms", (g_netClientPeer->lastRoundTripTime + g_netClientPeer->roundTripTime)/2, - (g_netClientPeer->lastRoundTripTimeVariance + g_netClientPeer->roundTripTimeVariance)/2); + chars = Bsprintf(tempbuf, "%d +- %d ms", (g_netClientPeer->lastRoundTripTime + g_netClientPeer->roundTripTime)/2, + (g_netClientPeer->lastRoundTripTimeVariance + g_netClientPeer->roundTripTimeVariance)/2); printext256(windowx2-(chars<<(3-x))+1,windowy1+10+2,0,-1,tempbuf,x); printext256(windowx2-(chars<<(3-x)),windowy1+10+1,g_netClientPeer->lastRoundTripTime > 200 ? COLOR_RED : COLOR_WHITE,-1,tempbuf,x); @@ -3815,16 +3816,16 @@ static void Net_EnterMessage(void) } quotebotgoal = quotebot; } -/* - else if (g_chatPlayer >= 0) - { - tempbuf[1] = (uint8_t)g_chatPlayer; - if ((!g_networkBroadcastMode) && (myconnectindex != connecthead)) - g_chatPlayer = connecthead; - mmulti_sendpacket(g_chatPlayer,tempbuf,j+2); - } + /* + else if (g_chatPlayer >= 0) + { + tempbuf[1] = (uint8_t)g_chatPlayer; + if ((!g_networkBroadcastMode) && (myconnectindex != connecthead)) + g_chatPlayer = connecthead; + mmulti_sendpacket(g_chatPlayer,tempbuf,j+2); + } -*/ + */ g_chatPlayer = -1; g_player[myconnectindex].ps->gm &= ~(MODE_TYPE|MODE_SENDTOWHOM); } @@ -4279,7 +4280,7 @@ void G_SetCrosshairColor(int32_t r, int32_t g, int32_t b) CrosshairColors.r = r; CrosshairColors.g = g; CrosshairColors.b = b; - + if (waloff[CROSSHAIR] == 0) { loadtile(CROSSHAIR); @@ -4355,10 +4356,10 @@ void G_DisplayRest(int32_t smoothratio) else if (pp->palette == slimepal) { // if ((*(uint32_t *)&hictinting[MAXPALOOKUPS-3].r)|0x000000FF) == 0xFFFFFFFF) - { - static palette_t sp = { 208, 255, 192, 0 }; - Bmemcpy(&hictinting[MAXPALOOKUPS-1], &sp, sizeof(palette_t)); - } + { + static palette_t sp = { 208, 255, 192, 0 }; + Bmemcpy(&hictinting[MAXPALOOKUPS-1], &sp, sizeof(palette_t)); + } // else Bmemcpy(&hictinting[MAXPALOOKUPS-1], &hictinting[MAXPALOOKUPS-3], sizeof(palette_t)); } @@ -4466,15 +4467,15 @@ void G_DisplayRest(int32_t smoothratio) { if (pp->newowner == -1 && !ud.pause_on) { -/* - if (screenpeek == myconnectindex && numplayers > 1) - { - cposx = omy.x+mulscale16((int32_t)(my.x-omy.x),smoothratio); - cposy = omy.y+mulscale16((int32_t)(my.y-omy.y),smoothratio); - cang = omyang+mulscale16((int32_t)(((myang+1024-omyang)&2047)-1024),smoothratio); - } - else -*/ + /* + if (screenpeek == myconnectindex && numplayers > 1) + { + cposx = omy.x+mulscale16((int32_t)(my.x-omy.x),smoothratio); + cposy = omy.y+mulscale16((int32_t)(my.y-omy.y),smoothratio); + cang = omyang+mulscale16((int32_t)(((myang+1024-omyang)&2047)-1024),smoothratio); + } + else + */ { cposx = pp->oposx+mulscale16((int32_t)(pp->posx-pp->oposx),smoothratio); cposy = pp->oposy+mulscale16((int32_t)(pp->posy-pp->oposy),smoothratio); @@ -5065,7 +5066,7 @@ void G_DrawRooms(int32_t snum, int32_t smoothratio) else if (s->yvel > 199) s->yvel = 300; ud.cameraang = ActorExtra[ud.camerasprite].tempang+ - mulscale16((int32_t)(((s->ang+1024-ActorExtra[ud.camerasprite].tempang)&2047)-1024),smoothratio); + mulscale16((int32_t)(((s->ang+1024-ActorExtra[ud.camerasprite].tempang)&2047)-1024),smoothratio); #ifdef POLYMER if (getrendermode() == 4) @@ -5146,24 +5147,25 @@ void G_DrawRooms(int32_t snum, int32_t smoothratio) p->orotscrnang = p->rotscrnang; // JBF: save it for next time } -/* - if ((snum == myconnectindex) && (numplayers > 1)) - { - vec3_t cam = { omy.x+mulscale16((int32_t)(my.x-omy.x),smoothratio), - omy.y+mulscale16((int32_t)(my.y-omy.y),smoothratio), - omy.z+mulscale16((int32_t)(my.z-omy.z),smoothratio) }; + /* + if ((snum == myconnectindex) && (numplayers > 1)) + { + vec3_t cam = { omy.x+mulscale16((int32_t)(my.x-omy.x),smoothratio), + omy.y+mulscale16((int32_t)(my.y-omy.y),smoothratio), + omy.z+mulscale16((int32_t)(my.z-omy.z),smoothratio) }; - Bmemcpy(&ud.camera, &cam, sizeof(vec3_t)); - ud.cameraang = omyang+mulscale16((int32_t)(((myang+1024-omyang)&2047)-1024),smoothratio); - ud.camerahoriz = omyhoriz+omyhorizoff+mulscale16((int32_t)(myhoriz+myhorizoff-omyhoriz-omyhorizoff),smoothratio); - ud.camerasect = mycursectnum; - } - else -*/ + Bmemcpy(&ud.camera, &cam, sizeof(vec3_t)); + ud.cameraang = omyang+mulscale16((int32_t)(((myang+1024-omyang)&2047)-1024),smoothratio); + ud.camerahoriz = omyhoriz+omyhorizoff+mulscale16((int32_t)(myhoriz+myhorizoff-omyhoriz-omyhorizoff),smoothratio); + ud.camerasect = mycursectnum; + } + else + */ { vec3_t cam = { p->oposx+mulscale16((int32_t)(p->posx-p->oposx),smoothratio), - p->oposy+mulscale16((int32_t)(p->posy-p->oposy),smoothratio), - p->oposz+mulscale16((int32_t)(p->posz-p->oposz),smoothratio) }; + p->oposy+mulscale16((int32_t)(p->posy-p->oposy),smoothratio), + p->oposz+mulscale16((int32_t)(p->posz-p->oposz),smoothratio) + }; Bmemcpy(&ud.camera, &cam, sizeof(vec3_t)); ud.cameraang = p->oang+mulscale16((int32_t)(((p->ang+1024-p->oang)&2047)-1024),smoothratio); @@ -5413,13 +5415,14 @@ int32_t A_InsertSprite(int32_t whatsect,int32_t s_x,int32_t s_y,int32_t s_z,int3 int32_t p, i = insertsprite(whatsect,s_ss); spritetype *s = &sprite[i]; spritetype spr_temp = { s_x, s_y, s_z, 0, s_pn, s_s, 0, 0, 0, s_xr, s_yr, 0, 0, - whatsect, s_ss, s_a, s_ow, s_ve, 0, s_zv, 0, 0, 0 }; + whatsect, s_ss, s_a, s_ow, s_ve, 0, s_zv, 0, 0, 0 + }; if (i < 0) { G_DumpDebugInfo(); OSD_Printf("Failed spawning pic %d spr from pic %d spr %d at x:%d,y:%d,z:%d,sect:%d\n", - s_pn,sprite[s_ow].picnum,s_ow,s_x,s_y,s_z,whatsect); + s_pn,sprite[s_ow].picnum,s_ow,s_x,s_y,s_z,whatsect); G_GameExit("Too many sprites spawned."); } @@ -7608,10 +7611,10 @@ void G_DoSpriteAnimations(int32_t x,int32_t y,int32_t a,int32_t smoothratio) // dirty hack if (g_player[s->yvel].ps->dead_flag) t->z = g_player[s->yvel].ps->oposz; t->z += mulscale16(smoothratio,g_player[s->yvel].ps->posz-g_player[s->yvel].ps->oposz) - - (g_player[s->yvel].ps->dead_flag ? 0 : PHEIGHT) + PHEIGHT; + (g_player[s->yvel].ps->dead_flag ? 0 : PHEIGHT) + PHEIGHT; } else if ((s->statnum == STAT_DEFAULT && s->picnum != CRANEPOLE) || s->statnum == STAT_PLAYER || - s->statnum == STAT_STANDABLE || s->statnum == STAT_PROJECTILE || s->statnum == STAT_MISC || s->statnum == STAT_ACTOR) + s->statnum == STAT_STANDABLE || s->statnum == STAT_PROJECTILE || s->statnum == STAT_MISC || s->statnum == STAT_ACTOR) { t->x -= mulscale16(65536-smoothratio,s->x-ActorExtra[i].bposx); t->y -= mulscale16(65536-smoothratio,s->y-ActorExtra[i].bposy); @@ -7772,17 +7775,17 @@ void G_DoSpriteAnimations(int32_t x,int32_t y,int32_t a,int32_t smoothratio) if (g_player[p].ps->over_shoulder_on > 0 && g_player[p].ps->newowner < 0) { -/* - if (screenpeek == myconnectindex && numplayers >= 2) - { - t->x = omy.x+mulscale16((int32_t)(my.x-omy.x),smoothratio); - t->y = omy.y+mulscale16((int32_t)(my.y-omy.y),smoothratio); - t->z = omy.z+mulscale16((int32_t)(my.z-omy.z),smoothratio)+PHEIGHT; - t->ang = omyang+mulscale16((int32_t)(((myang+1024-omyang)&2047)-1024),smoothratio); - t->sectnum = mycursectnum; - } - else*/ - t->ang = g_player[p].ps->ang+mulscale16((int32_t)(((g_player[p].ps->ang+1024- g_player[p].ps->oang)&2047)-1024),smoothratio); + /* + if (screenpeek == myconnectindex && numplayers >= 2) + { + t->x = omy.x+mulscale16((int32_t)(my.x-omy.x),smoothratio); + t->y = omy.y+mulscale16((int32_t)(my.y-omy.y),smoothratio); + t->z = omy.z+mulscale16((int32_t)(my.z-omy.z),smoothratio)+PHEIGHT; + t->ang = omyang+mulscale16((int32_t)(((myang+1024-omyang)&2047)-1024),smoothratio); + t->sectnum = mycursectnum; + } + else*/ + t->ang = g_player[p].ps->ang+mulscale16((int32_t)(((g_player[p].ps->ang+1024- g_player[p].ps->oang)&2047)-1024),smoothratio); #if defined(POLYMOST) && defined(USE_OPENGL) if (bpp > 8 && usemodels && md_tilehasmodel(t->picnum, t->pal) >= 0) { @@ -9132,7 +9135,7 @@ static void G_HandleLocalKeys(void) FX_StopAllSounds(); S_ClearSoundLocks(); } - + } else if (KB_KeyPressed(sc_kpad_4)) { @@ -9174,7 +9177,7 @@ static void G_HandleLocalKeys(void) i = 0; j = sc_F1; - do + do { if (KB_UnBoundKeyPressed(j)) { @@ -9183,7 +9186,7 @@ static void G_HandleLocalKeys(void) } } while (++j < sc_F11); - + if (i) { if (SHIFTS_IS_PRESSED) @@ -10145,19 +10148,19 @@ static void G_CheckCommandLine(int32_t argc, const char **argv) } if (!Bstrcasecmp(c+1,"server")) { - ENetAddress address; - - /* Bind the server to the default localhost. */ - /* A specific host address can be specified by */ - /* enet_address_set_host (& address, "x.x.x.x"); */ - - address.host = ENET_HOST_ANY; - address.port = g_netPort; - - g_netServer = enet_host_create (&address, MAXPLAYERS, 0, 0); - - if (g_netServer == NULL) - initprintf("An error occurred while trying to create an ENet server host.\n"); + ENetAddress address; + + /* Bind the server to the default localhost. */ + /* A specific host address can be specified by */ + /* enet_address_set_host (& address, "x.x.x.x"); */ + + address.host = ENET_HOST_ANY; + address.port = g_netPort; + + g_netServer = enet_host_create(&address, MAXPLAYERS, 0, 0); + + if (g_netServer == NULL) + initprintf("An error occurred while trying to create an ENet server host.\n"); g_noSetup = g_noLogo = TRUE; i++; @@ -11109,9 +11112,9 @@ void app_main(int32_t argc,const char **argv) } #endif - if (enet_initialize_with_callbacks(ENET_VERSION, &callbacks) != 0) - initprintf("An error occurred while initializing ENet.\n"); - else atexit (enet_deinitialize); + if (enet_initialize_with_callbacks(ENET_VERSION, &callbacks) != 0) + initprintf("An error occurred while initializing ENet.\n"); + else atexit(enet_deinitialize); #ifdef RENDERTYPEWIN backgroundidle = 0; @@ -11613,8 +11616,8 @@ CLEAN_DIRECTORY: ud.last_level = 0; if (!Bstrcasecmp(ud.rtsname,"DUKE.RTS") || - !Bstrcasecmp(ud.rtsname,"WW2GI.RTS") || - !Bstrcasecmp(ud.rtsname,"NAM.RTS")) + !Bstrcasecmp(ud.rtsname,"WW2GI.RTS") || + !Bstrcasecmp(ud.rtsname,"NAM.RTS")) { // ud.last_level is used as a flag here to reset the string to DUKE.RTS after load if (WW2GI) @@ -12221,8 +12224,8 @@ RECHECK: } while (totalclock >= (lockclock+TICSPERFRAME) - || (ud.reccnt > (TICRATE/TICSPERFRAME)*2 && ud.pause_on) - || (g_demo_goalCnt>0 && g_demo_goalCnt (TICRATE/TICSPERFRAME)*2 && ud.pause_on) + || (g_demo_goalCnt>0 && g_demo_goalCnt= RECSYNCBUFSIZ)) { @@ -12390,20 +12393,20 @@ RECHECK: static inline int32_t G_MoveLoop() { -/* - if (numplayers > 1) - Net_DoPrediction(); -*/ + /* + if (numplayers > 1) + Net_DoPrediction(); + */ Net_GetPackets(); while (g_player[myconnectindex].movefifoend-movefifoplc > 0) { -/* - TRAVERSE_CONNECT(i) - if (movefifoplc == g_player[i].movefifoend) break; - if (i != ud.multimode) break; -*/ + /* + TRAVERSE_CONNECT(i) + if (movefifoplc == g_player[i].movefifoend) break; + if (i != ud.multimode) break; + */ if (G_DoMoveThings()) return 1; } return 0; @@ -12528,7 +12531,7 @@ static int32_t G_DoMoveThings(void) randomseed = ticrandomseed; TRAVERSE_CONNECT(i) - copybufbyte(&inputfifo[(g_netServer && myconnectindex == i) ? 1 : 0][i],g_player[i].sync,sizeof(input_t)); + copybufbyte(&inputfifo[(g_netServer && myconnectindex == i) ? 1 : 0][i],g_player[i].sync,sizeof(input_t)); movefifoplc++; @@ -12626,23 +12629,23 @@ static int32_t G_DoMoveThings(void) i = g_player[myconnectindex].ps->i; -/* - { - int32_t j; - packbuf[(jj = j++)] = 0; + /* + { + int32_t j; + packbuf[(jj = j++)] = 0; - if (T5 >= (intptr_t)&script[0] && T5 < (intptr_t)(&script[g_scriptSize])) - { - packbuf[jj] |= 2; - T5 -= (intptr_t)&script[0]; - } + if (T5 >= (intptr_t)&script[0] && T5 < (intptr_t)(&script[g_scriptSize])) + { + packbuf[jj] |= 2; + T5 -= (intptr_t)&script[0]; + } - Bmemcpy(&packbuf[j], &T5, sizeof(T5)); - j += sizeof(T5); + Bmemcpy(&packbuf[j], &T5, sizeof(T5)); + j += sizeof(T5); - if (packbuf[jj] & 2) T5 += (intptr_t)&script[0]; - } -*/ + if (packbuf[jj] & 2) T5 += (intptr_t)&script[0]; + } + */ { char buf[1024]; diff --git a/polymer/eduke32/source/gamedef.c b/polymer/eduke32/source/gamedef.c index cad685e3a..28df1c5d6 100644 --- a/polymer/eduke32/source/gamedef.c +++ b/polymer/eduke32/source/gamedef.c @@ -1178,14 +1178,14 @@ static int32_t C_SetScriptSize(int32_t size) return 0; } -static inline int32_t ispecial(const char c) -{ - if (c == ' ' || c == 0x0d || c == '(' || c == ')' || - c == ',' || c == ';' || (c == 0x0a && ++g_lineNumber)) - return 1; - - return 0; -} +static inline int32_t ispecial(const char c) +{ + if (c == ' ' || c == 0x0d || c == '(' || c == ')' || + c == ',' || c == ';' || (c == 0x0a && ++g_lineNumber)) + return 1; + + return 0; +} #define C_NextLine() while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0) textptr++ @@ -4006,7 +4006,7 @@ static int32_t C_ParseCommand(void) C_ReportError(ERROR_NOTAGAMEARRAY); return 1; } - + C_SkipComments();// skip comments and whitespace if (*textptr != '[') { @@ -5565,16 +5565,16 @@ repeatcase: textptr++; } else while (*textptr != ' ' && *textptr != '\t' && *textptr != '\r' && *textptr != '\n') - { - g_sounds[k].filename[i++] = *textptr++; - if (i >= BMAX_PATH) { - initprintf("%s:%d: error: sound filename exceeds limit of %d characters.\n",g_szScriptFileName,g_lineNumber,BMAX_PATH); - g_numCompilerErrors++; - C_SkipComments(); - break; + g_sounds[k].filename[i++] = *textptr++; + if (i >= BMAX_PATH) + { + initprintf("%s:%d: error: sound filename exceeds limit of %d characters.\n",g_szScriptFileName,g_lineNumber,BMAX_PATH); + g_numCompilerErrors++; + C_SkipComments(); + break; + } } - } g_sounds[k].filename[i] = '\0'; C_GetNextValue(LABEL_DEFINE); @@ -6002,12 +6002,12 @@ void C_Compile(const char *filenam) { #ifdef WIN32 Bsprintf(tempbuf,"Duke Nukem 3D game data was not found. A valid copy of '%s' or other compatible data is needed to run EDuke32.\n\n" - "You can find '%s' in the 'DN3DINST' or 'ATOMINST' directory on your Duke Nukem 3D installation CD.\n\n" - "If you don't already own a copy of Duke or haven't seen your disc in years, don't worry -- you can download the full, registered " - "version of Duke Nukem 3D: Atomic Edition immediately for only $5.99 through our partnership with GOG.com.\n\n" - "Not a typo; it's less than 6 bucks. Get Duke now?\n\n" - "(Clicking yes will bring you to our web store)", - g_grpNamePtr,g_grpNamePtr); + "You can find '%s' in the 'DN3DINST' or 'ATOMINST' directory on your Duke Nukem 3D installation CD.\n\n" + "If you don't already own a copy of Duke or haven't seen your disc in years, don't worry -- you can download the full, registered " + "version of Duke Nukem 3D: Atomic Edition immediately for only $5.99 through our partnership with GOG.com.\n\n" + "Not a typo; it's less than 6 bucks. Get Duke now?\n\n" + "(Clicking yes will bring you to our web store)", + g_grpNamePtr,g_grpNamePtr); if (wm_ynbox("Important - Duke Nukem 3D not found - EDuke32",tempbuf)) { diff --git a/polymer/eduke32/source/global.c b/polymer/eduke32/source/global.c index 541fe4574..2054c6f28 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 = "20100107"; +const char *s_buildDate = "20100122"; char *MusicPtr = NULL; int32_t g_musicSize; diff --git a/polymer/eduke32/source/jaudiolib/include/fx_man.h b/polymer/eduke32/source/jaudiolib/include/fx_man.h index 161ed3159..257a9db9b 100644 --- a/polymer/eduke32/source/jaudiolib/include/fx_man.h +++ b/polymer/eduke32/source/jaudiolib/include/fx_man.h @@ -107,7 +107,5 @@ int32_t FX_StopAllSounds( void ); int32_t FX_StartDemandFeedPlayback( void ( *function )( char **ptr, uint32_t *length ), int32_t rate, int32_t pitchoffset, int32_t vol, int32_t left, int32_t right, int32_t priority, uint32_t callbackval ); -int32_t FX_StartRecording( int32_t MixRate, void ( *function )( char *ptr, int32_t length ) ); -void FX_StopRecord( void ); #endif diff --git a/polymer/eduke32/source/jaudiolib/src/driver_sdl.c b/polymer/eduke32/source/jaudiolib/src/driver_sdl.c index a063ab169..07940053d 100644 --- a/polymer/eduke32/source/jaudiolib/src/driver_sdl.c +++ b/polymer/eduke32/source/jaudiolib/src/driver_sdl.c @@ -24,7 +24,11 @@ #include -#include +#if defined(SDL_FRAMEWORK) +# include +#else +# include +#endif #include #include "driver_sdl.h" diff --git a/polymer/eduke32/source/jaudiolib/src/fx_man.c b/polymer/eduke32/source/jaudiolib/src/fx_man.c index 1870dee20..6c70c8f5d 100644 --- a/polymer/eduke32/source/jaudiolib/src/fx_man.c +++ b/polymer/eduke32/source/jaudiolib/src/fx_man.c @@ -36,6 +36,24 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "multivoc.h" #include "fx_man.h" +#ifdef __POWERPC__ +static inline uint16_t SWAP16(uint16_t s) +{ + return (s >> 8) | (s << 8); +} + +static inline uint32_t SWAP32(uint32_t s) +{ + return (s >> 24) | (s << 24) | ((s&0xff00) << 8) | ((s & 0xff0000) >> 8); +} + +#define LITTLE16 SWAP16 +#define LITTLE32 SWAP32 +#else +#define LITTLE16 +#define LITTLE32 +#endif + #define TRUE ( 1 == 1 ) #define FALSE ( !TRUE ) @@ -930,43 +948,6 @@ int32_t FX_StartDemandFeedPlayback } -/*--------------------------------------------------------------------- - Function: FX_StartRecording - - Starts the sound recording engine. ----------------------------------------------------------------------*/ - -int32_t FX_StartRecording -( - int32_t MixRate, - void (*function)(char *ptr, int32_t length) -) - -{ - int32_t status; - - FX_SetErrorCode(FX_InvalidCard); - status = FX_Warning; - - return(status); -} - - -/*--------------------------------------------------------------------- - Function: FX_StopRecord - - Stops the sound record engine. ----------------------------------------------------------------------*/ - -void FX_StopRecord -( - void -) - -{ -} - - /*--------------------------------------------------------------------- Function: FX_PlayAuto @@ -1017,22 +998,22 @@ int32_t FX_PlayLoopedAuto(char *ptr, uint32_t length, int32_t loopstart, int32_t uint32_t callbackval) { int32_t handle = -1; - + printf("FX_PlayLoopedAuto %X\n",*(int32_t *)ptr); switch (*(int32_t *)ptr) { - case 'C'+('r'<<8)+('e'<<16)+('a'<<24): + case LITTLE32('C'+('r'<<8)+('e'<<16)+('a'<<24)): handle = MV_PlayLoopedVOC(ptr, length, loopstart, loopend, pitchoffset, vol, left, right, priority, callbackval); break; - case 'R'+('I'<<8)+('F'<<16)+('F'<<24): + case LITTLE32('R'+('I'<<8)+('F'<<16)+('F'<<24)): handle = MV_PlayLoopedWAV(ptr, length, loopstart, loopend, pitchoffset, vol, left, right, priority, callbackval); break; - case 'O'+('g'<<8)+('g'<<16)+('S'<<24): + case LITTLE32('O'+('g'<<8)+('g'<<16)+('S'<<24)): handle = MV_PlayLoopedVorbis(ptr, length, loopstart, loopend, pitchoffset, vol, left, right, priority, callbackval); break; default: switch (*(int32_t *)(ptr + 8)) { - case 'W'+('A'<<8)+('V'<<16)+('E'<<24): + case LITTLE32('W'+('A'<<8)+('V'<<16)+('E'<<24)): handle = MV_PlayLoopedWAV(ptr, length, loopstart, loopend, pitchoffset, vol, left, right, priority, callbackval); break; } @@ -1061,19 +1042,19 @@ int32_t FX_PlayAuto3D(char *ptr, uint32_t length, int32_t pitchoffset, int32_t a switch (*(int32_t *)ptr) { - case 'C'+('r'<<8)+('e'<<16)+('a'<<24): // Crea + case LITTLE32('C'+('r'<<8)+('e'<<16)+('a'<<24)): // Crea handle = MV_PlayVOC3D(ptr, length, pitchoffset, angle, distance, priority, callbackval); break; - case 'R'+('I'<<8)+('F'<<16)+('F'<<24): // RIFF + case LITTLE32('R'+('I'<<8)+('F'<<16)+('F'<<24)): // RIFF handle = MV_PlayWAV3D(ptr, length, pitchoffset, angle, distance, priority, callbackval); break; - case 'O'+('g'<<8)+('g'<<16)+('S'<<24): // OggS + case LITTLE32('O'+('g'<<8)+('g'<<16)+('S'<<24)): // OggS handle = MV_PlayVorbis3D(ptr, length, pitchoffset, angle, distance, priority, callbackval); break; default: switch (*(int32_t *)(ptr + 8)) { - case 'W'+('A'<<8)+('V'<<16)+('E'<<24): // WAVE + case LITTLE32('W'+('A'<<8)+('V'<<16)+('E'<<24)): // WAVE handle = MV_PlayWAV3D(ptr, length, pitchoffset, angle, distance, priority, callbackval); break; } diff --git a/polymer/eduke32/source/jaudiolib/src/multivoc.c b/polymer/eduke32/source/jaudiolib/src/multivoc.c index bcd02a346..908713579 100644 --- a/polymer/eduke32/source/jaudiolib/src/multivoc.c +++ b/polymer/eduke32/source/jaudiolib/src/multivoc.c @@ -109,7 +109,6 @@ Pan MV_PanTable[ MV_NumPanPositions ][ 255 + 1 ]; int32_t MV_Installed = FALSE; static int32_t MV_TotalVolume = MV_MaxTotalVolume; static int32_t MV_MaxVoices = 1; -static int32_t MV_Recording; static int32_t MV_BufferSize = MixBufferSize; static int32_t MV_BufferLength; @@ -142,7 +141,6 @@ static int32_t MV_MixPage = 0; static int32_t MV_VoiceHandle = MV_MinVoiceHandle; static void (*MV_CallBackFunc)(uint32_t) = NULL; -static void (*MV_RecordFunc)(char *ptr, int32_t length) = NULL; static void (*MV_MixFunction)(VoiceNode *voice, int32_t buffer); int32_t MV_MaxVolume = 255; @@ -241,10 +239,6 @@ const char *MV_ErrorString ErrorString = "Invalid mix mode request in Multivoc."; break; - case MV_NullRecordFunction : - ErrorString = "Null record function passed to MV_StartRecording."; - break; - default : ErrorString = "Unknown Multivoc error code."; break; @@ -914,35 +908,6 @@ playbackstatus MV_GetNextWAVBlock } -/*--------------------------------------------------------------------- - Function: MV_ServiceRecord - - Starts recording of the waiting buffer. ----------------------------------------------------------------------*/ - -/* -static void MV_ServiceRecord -( - void -) - -{ - if (MV_RecordFunc) - { - MV_RecordFunc(MV_MixBuffer[ 0 ] + MV_MixPage * MixBufferSize, - MixBufferSize); - } - - // Toggle which buffer we'll mix next - MV_MixPage++; - if (MV_MixPage >= NumberOfBuffers) - { - MV_MixPage = 0; - } -} -*/ - - /*--------------------------------------------------------------------- Function: MV_GetVoice @@ -1150,11 +1115,6 @@ VoiceNode *MV_AllocVoice VoiceNode *voice; VoiceNode *node; - if (MV_Recording) - { - return(NULL); - } - DisableInterrupts(); // Check if we have any free voices @@ -1987,39 +1947,6 @@ void MV_StopPlayback } -/*--------------------------------------------------------------------- - Function: MV_StartRecording - - Starts the sound recording engine. ----------------------------------------------------------------------*/ - -int32_t MV_StartRecording -( - int32_t MixRate, - void (*function)(char *ptr, int32_t length) -) - -{ - MV_SetErrorCode(MV_UnsupportedCard); - return(MV_Error); -} - - -/*--------------------------------------------------------------------- - Function: MV_StopRecord - - Stops the sound record engine. ----------------------------------------------------------------------*/ - -void MV_StopRecord -( - void -) - -{ -} - - /*--------------------------------------------------------------------- Function: MV_StartDemandFeedPlayback @@ -2839,8 +2766,6 @@ int32_t MV_Init MV_Installed = TRUE; MV_CallBackFunc = NULL; - MV_RecordFunc = NULL; - MV_Recording = FALSE; MV_ReverbLevel = 0; MV_ReverbTable = NULL; @@ -2902,12 +2827,6 @@ int32_t MV_Shutdown MV_Installed = FALSE; - // Stop the sound recording engine - if (MV_Recording) - { - MV_StopRecord(); - } - // Stop the sound playback engine MV_StopPlayback(); diff --git a/polymer/eduke32/source/jaudiolib/src/multivoc.h b/polymer/eduke32/source/jaudiolib/src/multivoc.h index 9c42ecd1d..b476832a9 100644 --- a/polymer/eduke32/source/jaudiolib/src/multivoc.h +++ b/polymer/eduke32/source/jaudiolib/src/multivoc.h @@ -73,8 +73,6 @@ void MV_SetReverbDelay( int32_t delay ); int32_t MV_SetMixMode( int32_t numchannels, int32_t samplebits ); int32_t MV_StartPlayback( void ); void MV_StopPlayback( void ); -int32_t MV_StartRecording( int32_t MixRate, void ( *function )( char *ptr, int32_t length ) ); -void MV_StopRecord( void ); int32_t MV_StartDemandFeedPlayback( void ( *function )( char **ptr, uint32_t *length ), int32_t rate, int32_t pitchoffset, int32_t vol, int32_t left, int32_t right, int32_t priority, uint32_t callbackval ); diff --git a/polymer/eduke32/source/m32def.c b/polymer/eduke32/source/m32def.c index e48f3c241..39772f09b 100644 --- a/polymer/eduke32/source/m32def.c +++ b/polymer/eduke32/source/m32def.c @@ -50,7 +50,7 @@ typedef struct int32_t checkingSwitch; int32_t numCases; instype *caseScriptPtr; // the pointer to the start of the case table in a switch statement - // first entry is 'default' code. + // first entry is 'default' code. instype *caseCodePtr; // the pointer to the start of the different cases' code int32_t labelsOnly; int32_t numBraces; @@ -206,8 +206,8 @@ const char *keyw[] = "getsector", "setwall", "getwall", - "setsprite", - "getsprite", + "setsprite", + "getsprite", "gettspr", "settspr", @@ -834,7 +834,7 @@ static void C_GetNextVarType(int32_t type) // constant where gamevar expected if ((type==0 || type==GAMEVAR_SPECIAL) && !cs.labelsOnly && - (isdigit(*textptr) || ((*textptr == '-') && isdigit(*(textptr+1))))) + (isdigit(*textptr) || ((*textptr == '-') && isdigit(*(textptr+1))))) { // if (!(g_numCompilerErrors || g_numCompilerWarnings) && g_scriptDebug) // initprintf("%s:%d: debug: accepted constant %d in place of gamevar.\n",g_szScriptFileName,g_lineNumber,atol(textptr)); @@ -1016,14 +1016,14 @@ static void C_GetNextVarType(int32_t type) textptr++; /// now pointing at 'xxx' C_GetNextLabelName(); - /*initprintf("found xxx label of '%s'\n", label+(g_numLabels*MAXLABELLEN));*/ + /*initprintf("found xxx label of '%s'\n", label+(g_numLabels*MAXLABELLEN));*/ if (id == g_iSpriteVarID || id==3) lLabelID = C_GetLabelNameID(SpriteLabels, &spriteH, strtolower(tlabel,Bstrlen(tlabel))); else if (id == g_iSectorVarID) lLabelID = C_GetLabelNameID(SectorLabels, §orH, strtolower(tlabel,Bstrlen(tlabel))); else if (id == g_iWallVarID) lLabelID = C_GetLabelNameID(WallLabels, &wallH, strtolower(tlabel,Bstrlen(tlabel))); - //printf("LabelID is %d\n",lLabelID); + //printf("LabelID is %d\n",lLabelID); if (lLabelID == -1) { g_numCompilerErrors++; @@ -1064,7 +1064,7 @@ static void C_GetNextVarType(int32_t type) { C_ReportError(-1); initprintf("%s:%d: error: label %s=%d not suitable as array index. (max: 65535)\n",g_szScriptFileName,g_lineNumber, label+(id*MAXLABELLEN), num); - g_numCompilerErrors++; + g_numCompilerErrors++; } else if (num != (int16_t)num) { @@ -1718,7 +1718,7 @@ static int32_t C_ParseCommand(void) *g_scriptPtr++ = j; return 0; } - + C_ReportError(-1); initprintf("%s:%d: error: state `%s' not found.\n",g_szScriptFileName,g_lineNumber,tlabel); g_numCompilerErrors++; @@ -1753,7 +1753,7 @@ static int32_t C_ParseCommand(void) cs.currentEvent = j; cs.parsingEventOfs = g_scriptPtr-script; - //Bsprintf(g_szBuf,"Adding Event for %d at %lX",j, g_parsingEventPtr); AddLog(g_szBuf); + //Bsprintf(g_szBuf,"Adding Event for %d at %lX",j, g_parsingEventPtr); AddLog(g_szBuf); if (j<0 || j >= MAXEVENTS) { initprintf("%s:%d: error: invalid event ID.\n",g_szScriptFileName,g_lineNumber); @@ -1892,7 +1892,7 @@ static int32_t C_ParseCommand(void) return 0; tscrptr = (instype *)script+offset; - *tscrptr = (ofstype) (g_scriptPtr-script)-offset; // relative offset + *tscrptr = (ofstype)(g_scriptPtr-script)-offset; // relative offset } else { @@ -1934,7 +1934,7 @@ static int32_t C_ParseCommand(void) ofstype tempoffset; //AddLog("Got Switch statement"); - // if (cs.checkingSwitch) Bsprintf(g_szBuf,"ERROR::%s %d: cs.checkingSwitch=",__FILE__,__LINE__, cs.checkingSwitch); AddLog(g_szBuf); + // if (cs.checkingSwitch) Bsprintf(g_szBuf,"ERROR::%s %d: cs.checkingSwitch=",__FILE__,__LINE__, cs.checkingSwitch); AddLog(g_szBuf); cs.checkingSwitch++; // allow nesting (if other things work) C_GetNextVar(); // Get The ID of the DEF @@ -1949,16 +1949,16 @@ static int32_t C_ParseCommand(void) temptextptr = textptr; // probably does not allow nesting... - //AddLog("Counting Case Statements..."); + //AddLog("Counting Case Statements..."); j = C_CountCaseStatements(); - // initprintf("Done Counting Case Statements for switch %d: found %d.\n", cs.checkingSwitch,j); + // initprintf("Done Counting Case Statements for switch %d: found %d.\n", cs.checkingSwitch,j); g_scriptPtr += j*2; cs.caseCodePtr = g_scriptPtr; C_SkipComments(); g_scriptPtr -= j*2; // allocate buffer for the table tempscrptr = (instype *)(script+tempoffset); - // if (cs.checkingSwitch>1) Bsprintf(g_szBuf,"ERROR::%s %d: cs.checkingSwitch=",__FILE__,__LINE__, cs.checkingSwitch); AddLog(g_szBuf); + // if (cs.checkingSwitch>1) Bsprintf(g_szBuf,"ERROR::%s %d: cs.checkingSwitch=",__FILE__,__LINE__, cs.checkingSwitch); AddLog(g_szBuf); if (j<0) return 1; @@ -1974,7 +1974,7 @@ static int32_t C_ParseCommand(void) *g_scriptPtr++ = -1; // code offset C_SkipComments(); } - //Bsprintf(g_szBuf,"SWITCH1: '%.22s'",textptr); AddLog(g_szBuf); + //Bsprintf(g_szBuf,"SWITCH1: '%.22s'",textptr); AddLog(g_szBuf); cs.numCases = 0; while (C_ParseCommand() == 0) { @@ -1982,9 +1982,9 @@ static int32_t C_ParseCommand(void) } tempscrptr = (instype *)(script+tempoffset); - //Bsprintf(g_szBuf,"SWITCHXX: '%.22s'",textptr); AddLog(g_szBuf); + //Bsprintf(g_szBuf,"SWITCHXX: '%.22s'",textptr); AddLog(g_szBuf); // done processing switch. clean up. - // if (cs.checkingSwitch < 1) Bsprintf(g_szBuf,"ERROR::%s %d: cs.checkingSwitch=%d",__FILE__,__LINE__, cs.checkingSwitch); AddLog(g_szBuf); + // if (cs.checkingSwitch < 1) Bsprintf(g_szBuf,"ERROR::%s %d: cs.checkingSwitch=%d",__FILE__,__LINE__, cs.checkingSwitch); AddLog(g_szBuf); if (tempscrptr) { int32_t t,n; // !!! @@ -2008,14 +2008,14 @@ static int32_t C_ParseCommand(void) // for (j=3;j<3+tempscrptr[1]*2;j+=2)initprintf("%5d %8x\n",tempscrptr[j],tempscrptr[j+1]); tempscrptr[0] = (ofstype)(g_scriptPtr-cs.caseCodePtr); // save 'end' location as offset from code-place } - // else Bsprintf(g_szBuf,"ERROR::%s %d",__FILE__,__LINE__); AddLog(g_szBuf); + // else Bsprintf(g_szBuf,"ERROR::%s %d",__FILE__,__LINE__); AddLog(g_szBuf); cs.numCases = 0; cs.caseScriptPtr = NULL; cs.caseCodePtr = NULL; // decremented in endswitch. Don't decrement here... // cs.checkingSwitch--; // allow nesting (maybe if other things work) tempscrptr = NULL; - // if (cs.checkingSwitch) Bsprintf(g_szBuf,"ERROR::%s %d: cs.checkingSwitch=%d",__FILE__,__LINE__, cs.checkingSwitch); AddLog(g_szBuf); + // if (cs.checkingSwitch) Bsprintf(g_szBuf,"ERROR::%s %d: cs.checkingSwitch=%d",__FILE__,__LINE__, cs.checkingSwitch); AddLog(g_szBuf); //AddLog("End of Switch statement"); } break; @@ -2035,13 +2035,13 @@ repeatcase: } cs.numCases++; - //Bsprintf(g_szBuf,"case1: %.12s",textptr); AddLog(g_szBuf); + //Bsprintf(g_szBuf,"case1: %.12s",textptr); AddLog(g_szBuf); C_GetNextValue(LABEL_DEFINE); if (*textptr == ':') textptr++; - //Bsprintf(g_szBuf,"case2: %.12s",textptr); AddLog(g_szBuf); + //Bsprintf(g_szBuf,"case2: %.12s",textptr); AddLog(g_szBuf); j = *(--g_scriptPtr); // get value - //Bsprintf(g_szBuf,"case: Value of case %d is %d",(int32_t)cs.numCases,(int32_t)j); AddLog(g_szBuf); + //Bsprintf(g_szBuf,"case: Value of case %d is %d",(int32_t)cs.numCases,(int32_t)j); AddLog(g_szBuf); if (cs.caseScriptPtr) { for (i=(cs.numCases/2)-1; i>=0; i--) @@ -2055,7 +2055,7 @@ repeatcase: cs.caseScriptPtr[cs.numCases++] = j; // save value cs.caseScriptPtr[cs.numCases] = (ofstype)(g_scriptPtr - cs.caseCodePtr); // offset from beginning of cases' code } - //Bsprintf(g_szBuf,"case3: %.12s",textptr); AddLog(g_szBuf); + //Bsprintf(g_szBuf,"case3: %.12s",textptr); AddLog(g_szBuf); j = C_GetKeyword(); if (j == CON_CASE) { @@ -2063,11 +2063,11 @@ repeatcase: C_GetNextKeyword(); // eat 'case' goto repeatcase; } - //Bsprintf(g_szBuf,"case4: '%.12s'",textptr); AddLog(g_szBuf); + //Bsprintf(g_szBuf,"case4: '%.12s'",textptr); AddLog(g_szBuf); tempoffset = (unsigned)(tempscrptr-script); while (C_ParseCommand() == 0) { - //Bsprintf(g_szBuf,"case5 '%.25s'",textptr); AddLog(g_szBuf); + //Bsprintf(g_szBuf,"case5 '%.25s'",textptr); AddLog(g_szBuf); j = C_GetKeyword(); if (j == CON_CASE) { @@ -2078,7 +2078,7 @@ repeatcase: } } tempscrptr = (instype *)(script+tempoffset); - //AddLog("End Case"); + //AddLog("End Case"); return 0; // break; } @@ -2101,7 +2101,7 @@ repeatcase: } if (cs.caseScriptPtr) cs.caseScriptPtr[0] = (ofstype)(g_scriptPtr-cs.caseCodePtr); // save offset from cases' code - //Bsprintf(g_szBuf,"default: '%.22s'",textptr); AddLog(g_szBuf); + //Bsprintf(g_szBuf,"default: '%.22s'",textptr); AddLog(g_szBuf); while (C_ParseCommand() == 0) { //Bsprintf(g_szBuf,"defaultParse: '%.22s'",textptr); AddLog(g_szBuf); @@ -2318,7 +2318,7 @@ repeatcase: } C_GetNextLabelName(); - //printf("Got Label '%.20s'\n",textptr); + //printf("Got Label '%.20s'\n",textptr); // Check to see it's already defined if (hash_find(&keywH, tlabel) >= 0) { @@ -2857,7 +2857,7 @@ repeatcase: case CON_DEFINEQUOTE: case CON_REDEFINEQUOTE: if (tw == CON_DEFINEQUOTE) - g_scriptPtr--; + g_scriptPtr--; C_GetNextValue(LABEL_DEFINE); @@ -3319,7 +3319,7 @@ void C_Compile(const char *filenameortext, int32_t isfilename) C_AddDefaultDefinitions(); script = Bcalloc(g_scriptSize, sizeof(instype)); - // initprintf("script: %d\n",script); + // initprintf("script: %d\n",script); if (!script || !label || !labelval || !labeltype || !constants) { initprintf("C_Compile(): ERROR: out of memory!\n"); diff --git a/polymer/eduke32/source/m32exec.c b/polymer/eduke32/source/m32exec.c index 999d338e1..2ae3511f7 100644 --- a/polymer/eduke32/source/m32exec.c +++ b/polymer/eduke32/source/m32exec.c @@ -278,7 +278,7 @@ static int32_t X_DoSort(const int32_t *lv, const int32_t *rv) vm.flags |= VMFLAG_ERROR; \ continue; \ } \ - + int32_t X_DoExecute(int32_t once) { register int32_t tw = *insptr; @@ -358,15 +358,15 @@ skip_check: insptr += lCases*2; lCodeInsPtr = insptr; - //Bsprintf(g_szBuf,"lEnd= %d *lpDefault=%d",lEnd,*lpDefault); AddLog(g_szBuf); - //Bsprintf(g_szBuf,"Checking %d cases for %d",lCases, lValue); AddLog(g_szBuf); + //Bsprintf(g_szBuf,"lEnd= %d *lpDefault=%d",lEnd,*lpDefault); AddLog(g_szBuf); + //Bsprintf(g_szBuf,"Checking %d cases for %d",lCases, lValue); AddLog(g_szBuf); left = 0; right = lCases-1; while (!bMatched) { - //Bsprintf(g_szBuf,"Checking #%d Value= %d",lCheckCase, lpCases[lCheckCase*2]); AddLog(g_szBuf); + //Bsprintf(g_szBuf,"Checking #%d Value= %d",lCheckCase, lpCases[lCheckCase*2]); AddLog(g_szBuf); lCheckCase=(left+right)/2; - // initprintf("(%2d..%2d..%2d) [%2d..%2d..%2d]==%2d\n",left,lCheckCase,right,lpCases[left*2],lpCases[lCheckCase*2],lpCases[right*2],lValue); + // initprintf("(%2d..%2d..%2d) [%2d..%2d..%2d]==%2d\n",left,lCheckCase,right,lpCases[left*2],lpCases[lCheckCase*2],lpCases[right*2],lValue); if (lpCases[lCheckCase*2] > lValue) right = lCheckCase-1; else if (lpCases[lCheckCase*2] < lValue) @@ -374,10 +374,10 @@ skip_check: else if (lpCases[lCheckCase*2] == lValue) { //AddLog("Found Case Match"); - //Bsprintf(g_szBuf,"insptr=%d. lCheckCase=%d, offset=%d, &script[0]=%d", (int32_t)insptr,(int32_t)lCheckCase,lpCases[lCheckCase*2+1],(int32_t)&script[0]); AddLog(g_szBuf); + //Bsprintf(g_szBuf,"insptr=%d. lCheckCase=%d, offset=%d, &script[0]=%d", (int32_t)insptr,(int32_t)lCheckCase,lpCases[lCheckCase*2+1],(int32_t)&script[0]); AddLog(g_szBuf); // fake a 2-d Array insptr = lCodeInsPtr + lpCases[lCheckCase*2+1]; - //Bsprintf(g_szBuf,"insptr=%d. ", (int32_t)insptr); AddLog(g_szBuf); + //Bsprintf(g_szBuf,"insptr=%d. ", (int32_t)insptr); AddLog(g_szBuf); X_DoExecute(0); //AddLog("Done Executing Case"); bMatched=1; @@ -399,7 +399,7 @@ skip_check: // } } insptr = (instype *)(lCodeInsPtr + lEnd); - //Bsprintf(g_szBuf,"insptr=%d. ", (int32_t)insptr); AddLog(g_szBuf); + //Bsprintf(g_szBuf,"insptr=%d. ", (int32_t)insptr); AddLog(g_szBuf); //AddLog("Done Processing Switch"); continue; } @@ -478,7 +478,7 @@ skip_check: continue; } #if 0 - case CON_SETSPRITE: + case CON_SETSPRITE: insptr++; { // syntax [gs]etsprite[].x @@ -590,9 +590,9 @@ skip_check: if (vm.flags&VMFLAG_ERROR) continue; ssiz = (aGameArrays[si].dwFlags&GAMEARRAY_VARSIZE) ? - Gv_GetVarN(aGameArrays[si].size) : aGameArrays[si].size; + Gv_GetVarN(aGameArrays[si].size) : aGameArrays[si].size; dsiz = (aGameArrays[di].dwFlags&GAMEARRAY_VARSIZE) ? - Gv_GetVarN(aGameArrays[si].size) : aGameArrays[di].size; + Gv_GetVarN(aGameArrays[si].size) : aGameArrays[di].size; if (sidx > ssiz || didx > dsiz) continue; if ((sidx+numelts) > ssiz) numelts = ssiz-sidx; @@ -1233,8 +1233,8 @@ skip_check: case ITER_WALLSOFSECTOR: if (parm2 < 0 || parm2 >= MAXSECTORS) goto badindex; - for(jj=sector[parm2].wallptr, endwall=jj+sector[parm2].wallnum-1; - jj<=endwall && !vm.flags; jj++) + for (jj=sector[parm2].wallptr, endwall=jj+sector[parm2].wallnum-1; + jj<=endwall && !vm.flags; jj++) { Gv_SetVarX(var, jj); insptr = beg; @@ -1251,7 +1251,8 @@ skip_check: insptr = beg; X_DoExecute(1); jj = wall[jj].point2; - } while (jj != parm2 && !vm.flags); + } + while (jj != parm2 && !vm.flags); break; case ITER_RANGE: for (jj=0; jjx,vm.g_sp->y,vm.g_sp->z/*-((krand()&41)<<8)*/,vm.g_sp->sectnum, - pos.x, pos.y, pos.z /*-((krand()&41)<<8)*/, cursectnum); + pos.x, pos.y, pos.z /*-((krand()&41)<<8)*/, cursectnum); X_DoConditional(j); } continue; @@ -1537,7 +1538,7 @@ badindex: vm.flags |= VMFLAG_ERROR; } if ((tw==CON_DUPSPRITE && numsprites >= MAXSPRITES) || - (tw==CON_DUPSPRITE && spritesortcnt >= MAXSPRITESONSCREEN)) + (tw==CON_DUPSPRITE && spritesortcnt >= MAXSPRITESONSCREEN)) { OSD_Printf(CON_ERROR "Maximum number of sprites reached.\n",g_errorLineNum,keyw[g_tw]); vm.flags |= VMFLAG_ERROR; @@ -2216,7 +2217,7 @@ badindex: while (*insptr != -1 && numvals < 32) arg[numvals++] = Gv_GetVarX(*insptr++); - + insptr++; // skip the NOP i = 0; @@ -2299,7 +2300,7 @@ dodefault: // int32_t lType=*insptr++; int32_t lMaxDist = (tw==CON_FINDNEARSPRITE || tw==CON_FINDNEARSPRITE3D)? - *insptr++ : Gv_GetVarX(*insptr++); + *insptr++ : Gv_GetVarX(*insptr++); int32_t lVarID=*insptr++; int32_t lFound=-1, j, k = MAXSTATUS-1; diff --git a/polymer/eduke32/source/m32structures.c b/polymer/eduke32/source/m32structures.c index 6ed4b049d..215f4ac17 100644 --- a/polymer/eduke32/source/m32structures.c +++ b/polymer/eduke32/source/m32structures.c @@ -132,7 +132,7 @@ static int32_t __fastcall X_AccessSector(int32_t how, int32_t lVar1, int32_t lLa { int32_t lValue; int32_t i = (how&ACCESS_USEVARS) ? sprite[vm.g_i].sectnum : lVar1; - + if ((how&ACCESS_USEVARS) && lVar1 != g_iThisActorID) i = Gv_GetVarX(lVar1); @@ -344,14 +344,14 @@ static int32_t __fastcall X_AccessSprite(int32_t how, int32_t lVar1, int32_t lLa return lValue; } - badactor: +badactor: // OSD_Printf(CON_ERROR "tried to set %s on invalid target sprite (%d) from spr %d pic %d gv %s\n",g_errorLineNum,keyw[g_tw], // SpriteLabels[lLabelID].name,i,vm.g_i,vm.g_sp->picnum, // (lVar1>16)&0xffff; + if (!(id&MAXGAMEVARS)) + index = Gv_GetVarN(index); + + id &= (MAXGAMEARRAYS-1); + + if (aGameArrays[id].dwFlags & GAMEARRAY_VARSIZE) + siz = Gv_GetVarN(aGameArrays[id].size); + else siz = aGameArrays[id].size; + + if (index < 0 || index >= siz) { - register int32_t index; - int32_t siz; - - index = (id>>16)&0xffff; - if (!(id&MAXGAMEVARS)) - index = Gv_GetVarN(index); - - id &= (MAXGAMEARRAYS-1); - - if (aGameArrays[id].dwFlags & GAMEARRAY_VARSIZE) - siz = Gv_GetVarN(aGameArrays[id].size); - else siz = aGameArrays[id].size; - - if (index < 0 || index >= siz) - { - OSD_Printf(CON_ERROR "Gv_SetVarX(): invalid array index (%s[%d])\n",g_errorLineNum,keyw[g_tw],aGameArrays[id].szLabel,index); - vm.flags |= VMFLAG_ERROR; - return; - } - - switch (aGameArrays[id].dwFlags & GAMEARRAY_TYPEMASK) - { - case 0: - case GAMEARRAY_OFINT: - ((int32_t *)aGameArrays[id].vals)[index] = lValue; - return; - case GAMEARRAY_OFSHORT: - ((int16_t *)aGameArrays[id].vals)[index] = (int16_t)lValue; - return; - case GAMEARRAY_OFCHAR: - ((uint8_t *)aGameArrays[id].vals)[index] = (uint8_t)lValue; - return; - default: - OSD_Printf(CON_ERROR "Gv_SetVarX() (array): WTF??\n",g_errorLineNum,keyw[g_tw]); - vm.flags |= VMFLAG_ERROR; - return; - } + OSD_Printf(CON_ERROR "Gv_SetVarX(): invalid array index (%s[%d])\n",g_errorLineNum,keyw[g_tw],aGameArrays[id].szLabel,index); + vm.flags |= VMFLAG_ERROR; return; } - if (id&(MAXGAMEVARS<<3)) // struct shortcut vars + switch (aGameArrays[id].dwFlags & GAMEARRAY_TYPEMASK) { - register int32_t index, memberid; + case 0: + case GAMEARRAY_OFINT: + ((int32_t *)aGameArrays[id].vals)[index] = lValue; + return; + case GAMEARRAY_OFSHORT: + ((int16_t *)aGameArrays[id].vals)[index] = (int16_t)lValue; + return; + case GAMEARRAY_OFCHAR: + ((uint8_t *)aGameArrays[id].vals)[index] = (uint8_t)lValue; + return; + default: + OSD_Printf(CON_ERROR "Gv_SetVarX() (array): WTF??\n",g_errorLineNum,keyw[g_tw]); + vm.flags |= VMFLAG_ERROR; + return; + } + return; + } - index = (id>>16)&0x7fff; - if (!(id&MAXGAMEVARS)) - index = Gv_GetVarN(index); + if (id&(MAXGAMEVARS<<3)) // struct shortcut vars + { + register int32_t index, memberid; - memberid = (id>>2)&31; + index = (id>>16)&0x7fff; + if (!(id&MAXGAMEVARS)) + index = Gv_GetVarN(index); - switch (id&3) - { - case 0: //if (id == g_iSpriteVarID) - X_AccessSprite(1, index, memberid, lValue); - return; - case 1: //else if (id == g_iSectorVarID) + memberid = (id>>2)&31; + + switch (id&3) + { + case 0: //if (id == g_iSpriteVarID) + X_AccessSprite(1, index, memberid, lValue); + return; + case 1: //else if (id == g_iSectorVarID) // if (index == vm.g_i) index = sprite[vm.g_i].sectnum; - X_AccessSector(1, index, memberid, lValue); - return; - case 2: //else if (id == g_iWallVarID) - X_AccessWall(1, index, memberid, lValue); - return; - case 3: - X_AccessTsprite(1, index, memberid, lValue); - return; + X_AccessSector(1, index, memberid, lValue); + return; + case 2: //else if (id == g_iWallVarID) + X_AccessWall(1, index, memberid, lValue); + return; + case 3: + X_AccessTsprite(1, index, memberid, lValue); + return; // default: // OSD_Printf(CON_ERROR "Gv_SetVarX(): WTF??\n",g_errorLineNum,keyw[g_tw]); // return; - } } - - OSD_Printf(CON_ERROR "Gv_SetVarX(): invalid gamevar ID (%d)\n",g_errorLineNum,keyw[g_tw],id); - vm.flags |= VMFLAG_ERROR; - return; } + OSD_Printf(CON_ERROR "Gv_SetVarX(): invalid gamevar ID (%d)\n",g_errorLineNum,keyw[g_tw],id); + vm.flags |= VMFLAG_ERROR; + return; + } + switch (aGameVars[id].dwFlags & (GAMEVAR_USER_MASK|GAMEVAR_INTPTR|GAMEVAR_SHORTPTR|GAMEVAR_CHARPTR)) { @@ -589,7 +589,7 @@ static void Gv_AddSystemVars(void) Gv_NewVar("startposy",(intptr_t)&startposy, GAMEVAR_READONLY | GAMEVAR_INTPTR | GAMEVAR_SYSTEM); Gv_NewVar("startposz",(intptr_t)&startposz, GAMEVAR_READONLY | GAMEVAR_INTPTR | GAMEVAR_SYSTEM); Gv_NewVar("startang",(intptr_t)&startang, GAMEVAR_READONLY | GAMEVAR_SHORTPTR | GAMEVAR_SYSTEM); - Gv_NewVar("startsectnum",(intptr_t)&startsectnum, GAMEVAR_READONLY | GAMEVAR_SHORTPTR | GAMEVAR_SYSTEM); + Gv_NewVar("startsectnum",(intptr_t)&startsectnum, GAMEVAR_READONLY | GAMEVAR_SHORTPTR | GAMEVAR_SYSTEM); Gv_NewVar("mousxplc",(intptr_t)&mousxplc, GAMEVAR_READONLY | GAMEVAR_INTPTR | GAMEVAR_SYSTEM); Gv_NewVar("mousyplc",(intptr_t)&mousyplc, GAMEVAR_READONLY | GAMEVAR_INTPTR | GAMEVAR_SYSTEM); diff --git a/polymer/eduke32/source/menus.c b/polymer/eduke32/source/menus.c index 583231562..0ecf861c4 100644 --- a/polymer/eduke32/source/menus.c +++ b/polymer/eduke32/source/menus.c @@ -2430,32 +2430,32 @@ cheat_for_port_credits: #ifdef POLYMER else { - float ratios[] = { 0.0, 1.33, 1.66, 1.78, 1.85, 2.35 }; + float ratios[] = { 0.0, 1.33, 1.66, 1.78, 1.85, 2.35 }; - int32_t j = (sizeof(ratios)/sizeof(ratios[0])); + int32_t j = (sizeof(ratios)/sizeof(ratios[0])); - for (i = 0; i= j) - i = 0; - } - if (i == j) - Bsprintf(tempbuf,"Custom"); - else - { - if (i == 0) Bsprintf(tempbuf,"Auto"); - else Bsprintf(tempbuf,"%.2f:1",ratios[i]); + modval(0,j-1,(int32_t *)&i,1,probey==io); + if (x == io) + { + i++; + if (i >= j) + i = 0; + } + if (i == j) + Bsprintf(tempbuf,"Custom"); + else + { + if (i == 0) Bsprintf(tempbuf,"Auto"); + else Bsprintf(tempbuf,"%.2f:1",ratios[i]); - if (ratios[i] != pr_customaspect) - pr_customaspect = ratios[i]; - } - mgametextpal(d,yy,tempbuf, MENUHIGHLIGHT(io), 0); + if (ratios[i] != pr_customaspect) + pr_customaspect = ratios[i]; + } + mgametextpal(d,yy,tempbuf, MENUHIGHLIGHT(io), 0); } #endif @@ -2527,19 +2527,19 @@ cheat_for_port_credits: mgametextpal(d,yy, ud.config.useprecache ? "On" : "Off", enabled?MENUHIGHLIGHT(io):DISABLEDMENUSHADE, 0); break; case 7: + { + char *s[] = { "Off", "On", "Compress" }; + enabled = (glusetexcompr && usehightile); + if (enabled && x==io) { - char *s[] = { "Off", "On", "Compress" }; - enabled = (glusetexcompr && usehightile); - if (enabled && x==io) - { - glusetexcache++; - if (glusetexcache > 2) - glusetexcache = 0; - } - if (enabled) modval(0,2,(int32_t *)&glusetexcache,1,probey==io); - mgametextpal(d,yy, s[glusetexcache], enabled?MENUHIGHLIGHT(io):DISABLEDMENUSHADE, 0); + glusetexcache++; + if (glusetexcache > 2) + glusetexcache = 0; } - break; + if (enabled) modval(0,2,(int32_t *)&glusetexcache,1,probey==io); + mgametextpal(d,yy, s[glusetexcache], enabled?MENUHIGHLIGHT(io):DISABLEDMENUSHADE, 0); + } + break; case 8: enabled = usehightile; if (enabled && x==io) r_detailmapping = !r_detailmapping; diff --git a/polymer/eduke32/source/midi.c b/polymer/eduke32/source/midi.c index 376e74ea0..0465459a1 100644 --- a/polymer/eduke32/source/midi.c +++ b/polymer/eduke32/source/midi.c @@ -48,7 +48,7 @@ static const int32_t _MIDI_CommandLengths[ NUM_MIDI_CHANNELS ] = 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 1, 1, 2, 0 }; -static int32_t (*_MIDI_RerouteFunctions[ NUM_MIDI_CHANNELS ]) ( int32_t event, int32_t c1, int32_t c2 ); +static int32_t (*_MIDI_RerouteFunctions[ NUM_MIDI_CHANNELS ])(int32_t event, int32_t c1, int32_t c2); static track *_MIDI_TrackPtr = NULL; static int32_t _MIDI_TrackMemSize; @@ -62,12 +62,12 @@ static int32_t _MIDI_Division; static int32_t _MIDI_Tick = 0; static int32_t _MIDI_Beat = 1; static int32_t _MIDI_Measure = 1; -static unsigned _MIDI_Time; +static uint32_t _MIDI_Time; static int32_t _MIDI_BeatsPerMeasure; static int32_t _MIDI_TicksPerBeat; static int32_t _MIDI_TimeBase; static int32_t _MIDI_FPSecondsPerTick; -static unsigned _MIDI_TotalTime; +static uint32_t _MIDI_TotalTime; static int32_t _MIDI_TotalTicks; static int32_t _MIDI_TotalBeats; static int32_t _MIDI_TotalMeasures; diff --git a/polymer/eduke32/source/mpu401.c b/polymer/eduke32/source/mpu401.c index 0fd040fc8..ce702ab3b 100644 --- a/polymer/eduke32/source/mpu401.c +++ b/polymer/eduke32/source/mpu401.c @@ -123,7 +123,7 @@ void CALLBACK MPU_MIDICallback(HMIDIOUT handle, UINT uMsg, DWORD dwInstance, DWO { case MOM_DONE: midiOutUnprepareHeader((HMIDIOUT)handle, (MIDIHDR*)dwParam1, sizeof(MIDIHDR)); - for (i=0;i peers; - currentPeer < & g_netServer -> peers [g_netServer -> peerCount]; - ++ currentPeer) + currentPeer < & g_netServer -> peers [g_netServer -> peerCount]; + ++ currentPeer) { if (currentPeer -> state != ENET_PEER_STATE_CONNECTED) continue; enet_address_get_host_ip(¤tPeer->address, ipaddr, sizeof(ipaddr)); initprintf("%x %s %s\n", currentPeer->address.host, ipaddr, - g_player[(intptr_t)currentPeer->data].user_name); + g_player[(intptr_t)currentPeer->data].user_name); } return OSDCMD_OK; @@ -1224,19 +1224,19 @@ static int32_t osdcmd_kick(const osdfuncparm_t *parm) } for (currentPeer = g_netServer -> peers; - currentPeer < & g_netServer -> peers [g_netServer -> peerCount]; - ++ currentPeer) + currentPeer < & g_netServer -> peers [g_netServer -> peerCount]; + ++ currentPeer) { if (currentPeer -> state != ENET_PEER_STATE_CONNECTED) continue; - sscanf (parm->parms[0],"%" PRIxPTR "", &hexaddr); + sscanf(parm->parms[0],"%" PRIxPTR "", &hexaddr); if (currentPeer->address.host == hexaddr) { initprintf("Kicking %x (%s)\n", currentPeer->address.host, - g_player[(intptr_t)currentPeer->data].user_name); - enet_peer_disconnect (currentPeer, DISC_KICKED); + g_player[(intptr_t)currentPeer->data].user_name); + enet_peer_disconnect(currentPeer, DISC_KICKED); return OSDCMD_OK; } } @@ -1260,13 +1260,13 @@ static int32_t osdcmd_kickban(const osdfuncparm_t *parm) } for (currentPeer = g_netServer -> peers; - currentPeer < & g_netServer -> peers [g_netServer -> peerCount]; - ++ currentPeer) + currentPeer < & g_netServer -> peers [g_netServer -> peerCount]; + ++ currentPeer) { if (currentPeer -> state != ENET_PEER_STATE_CONNECTED) continue; - sscanf (parm->parms[0],"%" PRIxPTR "", &hexaddr); + sscanf(parm->parms[0],"%" PRIxPTR "", &hexaddr); if (currentPeer->address.host == hexaddr) { @@ -1275,8 +1275,8 @@ static int32_t osdcmd_kickban(const osdfuncparm_t *parm) enet_address_get_host_ip(¤tPeer->address, ipaddr, sizeof(ipaddr)); initprintf("Host %s is now banned.\n", ipaddr); initprintf("Kicking %x (%s)\n", currentPeer->address.host, - g_player[(intptr_t)currentPeer->data].user_name); - enet_peer_disconnect (currentPeer, DISC_BANNED); + g_player[(intptr_t)currentPeer->data].user_name); + enet_peer_disconnect(currentPeer, DISC_BANNED); return OSDCMD_OK; } } diff --git a/polymer/eduke32/source/player.c b/polymer/eduke32/source/player.c index 29645027d..e33686f8c 100644 --- a/polymer/eduke32/source/player.c +++ b/polymer/eduke32/source/player.c @@ -3322,11 +3322,11 @@ void getinput(int32_t snum) return; } -/* - if (numplayers > 1) - daang = myang; - else*/ - daang = p->ang; + /* + if (numplayers > 1) + daang = myang; + else*/ + daang = p->ang; momx = mulscale9(vel,sintable[(daang+2560)&2047]); momy = mulscale9(vel,sintable[(daang+2048)&2047]); @@ -3890,8 +3890,8 @@ void P_FragPlayer(int32_t snum) if (ud.obituaries) { Bsprintf(tempbuf,ScriptQuotes[FIRST_OBITUARY_QUOTE+(krand()%g_numObituaries)], - &g_player[p->frag_ps].user_name[0], - &g_player[snum].user_name[0]); + &g_player[p->frag_ps].user_name[0], + &g_player[snum].user_name[0]); G_AddUserQuote(tempbuf); } else krand(); @@ -4148,7 +4148,7 @@ void P_ProcessInput(int32_t snum) if ((numplayers < 2 || g_netServer) && p->dead_flag == 0) P_FragPlayer(snum); - + if (psectlotag == 2) { if (p->on_warping_sector == 0) @@ -5440,10 +5440,10 @@ SHOOTINCODE: } j = A_InsertSprite(p->cursectnum, - p->posx+(sintable[(p->ang+512)&2047]>>6), - p->posy+(sintable[p->ang&2047]>>6), - p->posz,aplWeaponShoots[p->curr_weapon][snum],-16,9,9, - p->ang,(k+(p->hbomb_hold_delay<<5)),i,pi,1); + p->posx+(sintable[(p->ang+512)&2047]>>6), + p->posy+(sintable[p->ang&2047]>>6), + p->posz,aplWeaponShoots[p->curr_weapon][snum],-16,9,9, + p->ang,(k+(p->hbomb_hold_delay<<5)),i,pi,1); lPipeBombControl=Gv_GetVarByLabel("PIPEBOMB_CONTROL", PIPEBOMB_REMOTE, -1, snum); @@ -5452,8 +5452,8 @@ SHOOTINCODE: int32_t lGrenadeLifetime=Gv_GetVarByLabel("GRENADE_LIFETIME", NAM_GRENADE_LIFETIME, -1, snum); int32_t lGrenadeLifetimeVar=Gv_GetVarByLabel("GRENADE_LIFETIME_VAR", NAM_GRENADE_LIFETIME_VAR, -1, snum); ActorExtra[j].temp_data[7]=lGrenadeLifetime - + mulscale(krand(),lGrenadeLifetimeVar, 14) - - lGrenadeLifetimeVar; + + mulscale(krand(),lGrenadeLifetimeVar, 14) + - lGrenadeLifetimeVar; ActorExtra[j].temp_data[6]=1; } else diff --git a/polymer/eduke32/source/premap.c b/polymer/eduke32/source/premap.c index a2d7f3021..81b50e9ba 100644 --- a/polymer/eduke32/source/premap.c +++ b/polymer/eduke32/source/premap.c @@ -1386,47 +1386,47 @@ static void resetpspritevars(char g) if (ud.recstat != 2) TRAVERSE_CONNECT(i) + { + aimmode[i] = g_player[i].ps->aim_mode; + autoaim[i] = g_player[i].ps->auto_aim; + weaponswitch[i] = g_player[i].ps->weaponswitch; + if ((g_netServer || ud.multimode > 1) && (GametypeFlags[ud.coop]&GAMETYPE_PRESERVEINVENTORYDEATH) && ud.last_level >= 0) { - aimmode[i] = g_player[i].ps->aim_mode; - autoaim[i] = g_player[i].ps->auto_aim; - weaponswitch[i] = g_player[i].ps->weaponswitch; - if ((g_netServer || ud.multimode > 1) && (GametypeFlags[ud.coop]&GAMETYPE_PRESERVEINVENTORYDEATH) && ud.last_level >= 0) + for (j=0; jammo_amount[j]; - tsbar[i].gotweapon[j] = g_player[i].ps->gotweapon[j]; - } - - 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].ammo_amount[j] = g_player[i].ps->ammo_amount[j]; + tsbar[i].gotweapon[j] = g_player[i].ps->gotweapon[j]; } + + 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; } + } P_ResetStatus(0); TRAVERSE_CONNECT(i) - if (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) + { + g_player[i].ps->aim_mode = aimmode[i]; + g_player[i].ps->auto_aim = autoaim[i]; + g_player[i].ps->weaponswitch = weaponswitch[i]; + if ((g_netServer || ud.multimode > 1) && (GametypeFlags[ud.coop]&GAMETYPE_PRESERVEINVENTORYDEATH) && ud.last_level >= 0) { - g_player[i].ps->aim_mode = aimmode[i]; - g_player[i].ps->auto_aim = autoaim[i]; - g_player[i].ps->weaponswitch = weaponswitch[i]; - if ((g_netServer || ud.multimode > 1) && (GametypeFlags[ud.coop]&GAMETYPE_PRESERVEINVENTORYDEATH) && ud.last_level >= 0) + for (j=0; jammo_amount[j] = tsbar[i].ammo_amount[j]; - g_player[i].ps->gotweapon[j] = tsbar[i].gotweapon[j]; - } - g_player[i].ps->curr_weapon = tsbar[i].curr_weapon; - g_player[i].ps->inven_icon = tsbar[i].inven_icon; - Bmemcpy(g_player[i].ps->inv_amount, tsbar[i].inv_amount, sizeof(tsbar[i].inv_amount)); + 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->curr_weapon = tsbar[i].curr_weapon; + g_player[i].ps->inven_icon = tsbar[i].inven_icon; + Bmemcpy(g_player[i].ps->inv_amount, tsbar[i].inv_amount, sizeof(tsbar[i].inv_amount)); } + } g_numPlayerSprites = 0; circ = 2048/ud.multimode; diff --git a/polymer/eduke32/source/sector.c b/polymer/eduke32/source/sector.c index 74537e6fa..11f52db41 100644 --- a/polymer/eduke32/source/sector.c +++ b/polymer/eduke32/source/sector.c @@ -192,7 +192,7 @@ inline int32_t G_CheckPlayerInSector(int32_t sect) { int32_t i; TRAVERSE_CONNECT(i) - if (sprite[g_player[i].ps->i].sectnum == sect) return i; + if (sprite[g_player[i].ps->i].sectnum == sect) return i; return -1; } @@ -3048,7 +3048,7 @@ void P_CheckSectors(int32_t snum) return; case -1: TRAVERSE_CONNECT(i) - g_player[i].ps->gm = MODE_EOL; + g_player[i].ps->gm = MODE_EOL; sector[p->cursectnum].lotag = 0; if (ud.from_bonus) { diff --git a/polymer/eduke32/source/sounds.c b/polymer/eduke32/source/sounds.c index ef8e771b5..d14c29c64 100644 --- a/polymer/eduke32/source/sounds.c +++ b/polymer/eduke32/source/sounds.c @@ -144,7 +144,7 @@ void S_MusicStartup(void) { MUSIC_SetVolume(ud.config.MusicVolume); } - + initprintf("S_MusicStartup(): failed initializing\n"); } } @@ -296,7 +296,7 @@ int32_t S_PlayMusic(const char *fn, const int32_t sel) if (MapInfo[sel].alt_musicfn != NULL) alt = (int32_t)(fn = MapInfo[sel].alt_musicfn); - + testfn = (char *) Bmalloc(strlen(fn) + 5); strcpy(testfn, fn); @@ -356,8 +356,8 @@ int32_t S_PlayMusic(const char *fn, const int32_t sel) else { if ((MusicVoice = FX_PlayLoopedAuto(MusicPtr, MusicLen, 0, 0, 0, ud.config.MusicVolume, - ud.config.MusicVolume, ud.config.MusicVolume, - FX_MUSIC_PRIORITY, MUSIC_ID)) >= FX_Ok) + ud.config.MusicVolume, ud.config.MusicVolume, + FX_MUSIC_PRIORITY, MUSIC_ID)) >= FX_Ok) MusicIsWaveform = 1; } return (alt != 0); @@ -567,12 +567,12 @@ int32_t S_PlaySound3D(int32_t num, int32_t i, const vec3_t *pos) if (g_sounds[num].num > 0) return -1; voice = FX_PlayLoopedAuto(g_sounds[num].ptr, g_sounds[num].soundsiz, 0, -1, - pitch,sndist>>6,sndist>>6,0,g_sounds[num].pr,(num * MAXSOUNDINSTANCES) + l); + pitch,sndist>>6,sndist>>6,0,g_sounds[num].pr,(num * MAXSOUNDINSTANCES) + l); } else { voice = FX_PlayAuto3D(g_sounds[ num ].ptr, g_sounds[num].soundsiz, pitch,sndang>>4,sndist>>6, g_sounds[num].pr, - (num * MAXSOUNDINSTANCES) + l); + (num * MAXSOUNDINSTANCES) + l); } if (voice >= FX_Ok) @@ -733,7 +733,7 @@ void S_Pan3D(void) k--; continue; } - + Bmemcpy(&s, &sprite[i], sizeof(vec3_t)); if (PN == APLAYER && sprite[i].yvel == screenpeek) diff --git a/polymer/eduke32/source/startgtk.game.c b/polymer/eduke32/source/startgtk.game.c index 3eab569af..5bae7e22e 100644 --- a/polymer/eduke32/source/startgtk.game.c +++ b/polymer/eduke32/source/startgtk.game.c @@ -1,8 +1,8 @@ #if defined(LINKED_GTK) - #include - #include +#include +#include #else - #include "dynamicgtk.h" +#include "dynamicgtk.h" #endif #include "duke3d.h" @@ -12,76 +12,79 @@ #define RDR_POLYMOST 3 // sould be defined elsewhere #define RDR_POLYMER 4 // sould be defined elsewhere -enum { - NONE, - ALL, - POPULATE_VIDEO, - POPULATE_CONFIG, - POPULATE_GAME, +enum +{ + NONE, + ALL, + POPULATE_VIDEO, + POPULATE_CONFIG, + POPULATE_GAME, }; -enum { - TAB_CONFIG, - TAB_GAME, - TAB_MESSAGES, +enum +{ + TAB_CONFIG, + TAB_GAME, + TAB_MESSAGES, }; -enum { - INPUT_KB, - INPUT_MOUSE, - INPUT_JOYSTICK, - INPUT_ALL, +enum +{ + INPUT_KB, + INPUT_MOUSE, + INPUT_JOYSTICK, + INPUT_ALL, }; static struct { - GtkWidget *startwin; - GtkWidget *hlayout; - GtkWidget *banner; - GtkWidget *vlayout; - GtkWidget *tabs; - GtkWidget *configtlayout; - GtkWidget *displayvlayout; - GtkWidget *vmode3dlabel; - GtkWidget *vmode3dcombo; - GtkWidget *fullscreencheck; - GtkWidget *polymercheck; - GtkWidget *inputdevlabel; - GtkWidget *inputdevcombo; - GtkWidget *custommodlabel; - GtkWidget *custommodcombo; - GtkWidget *emptyhlayout; - GtkWidget *autoloadcheck; - GtkWidget *alwaysshowcheck; - GtkWidget *configtab; - GtkWidget *gamevlayout; - GtkWidget *gamelabel; - GtkWidget *gamescroll; - GtkWidget *gamelist; - GtkWidget *gametab; - GtkWidget *messagesscroll; - GtkWidget *messagestext; - GtkWidget *messagestab; - GtkWidget *buttons; - GtkWidget *cancelbutton; - GtkWidget *cancelbuttonalign; - GtkWidget *cancelbuttonlayout; - GtkWidget *cancelbuttonicon; - GtkWidget *cancelbuttonlabel; - GtkWidget *startbutton; - GtkWidget *startbuttonalign; - GtkWidget *startbuttonlayout; - GtkWidget *startbuttonicon; - GtkWidget *startbuttonlabel; + GtkWidget *startwin; + GtkWidget *hlayout; + GtkWidget *banner; + GtkWidget *vlayout; + GtkWidget *tabs; + GtkWidget *configtlayout; + GtkWidget *displayvlayout; + GtkWidget *vmode3dlabel; + GtkWidget *vmode3dcombo; + GtkWidget *fullscreencheck; + GtkWidget *polymercheck; + GtkWidget *inputdevlabel; + GtkWidget *inputdevcombo; + GtkWidget *custommodlabel; + GtkWidget *custommodcombo; + GtkWidget *emptyhlayout; + GtkWidget *autoloadcheck; + GtkWidget *alwaysshowcheck; + GtkWidget *configtab; + GtkWidget *gamevlayout; + GtkWidget *gamelabel; + GtkWidget *gamescroll; + GtkWidget *gamelist; + GtkWidget *gametab; + GtkWidget *messagesscroll; + GtkWidget *messagestext; + GtkWidget *messagestab; + GtkWidget *buttons; + GtkWidget *cancelbutton; + GtkWidget *cancelbuttonalign; + GtkWidget *cancelbuttonlayout; + GtkWidget *cancelbuttonicon; + GtkWidget *cancelbuttonlabel; + GtkWidget *startbutton; + GtkWidget *startbuttonalign; + GtkWidget *startbuttonlayout; + GtkWidget *startbuttonicon; + GtkWidget *startbuttonlabel; } stwidgets; - + static struct { int32_t fullscreen; int32_t polymer; int32_t xdim3d, ydim3d, bpp3d; int32_t forcesetup; - int32_t autoload; + int32_t autoload; int32_t usemouse, usejoy; int32_t game; int32_t crcval; @@ -102,7 +105,7 @@ static void on_vmode3dcombo_changed(GtkComboBox *combobox, gpointer user_data) GtkTreeIter iter; int32_t val; UNREFERENCED_PARAMETER(user_data); - + if (!gtk_combo_box_get_active_iter(combobox, &iter)) return; if (!(data = gtk_combo_box_get_model(combobox))) return; gtk_tree_model_get(data, &iter, 1, &val, -1); @@ -122,18 +125,18 @@ static void on_polymercheck_toggled(GtkToggleButton *togglebutton, gpointer user UNREFERENCED_PARAMETER(user_data); if (gtk_toggle_button_get_active(togglebutton)) { - glrendmode = RDR_POLYMER; - settings.polymer = TRUE; - if (settings.bpp3d == 8) - { - settings.bpp3d = 32; - PopulateForm(POPULATE_VIDEO); - } + glrendmode = RDR_POLYMER; + settings.polymer = TRUE; + if (settings.bpp3d == 8) + { + settings.bpp3d = 32; + PopulateForm(POPULATE_VIDEO); + } } else { - glrendmode = RDR_POLYMOST; - settings.polymer = FALSE; + glrendmode = RDR_POLYMOST; + settings.polymer = FALSE; } } @@ -141,12 +144,12 @@ static void on_inputdevcombo_changed(GtkComboBox *combobox, gpointer user_data) { UNREFERENCED_PARAMETER(user_data); switch (gtk_combo_box_get_active(combobox)) - { - case 0: settings.usemouse = 0; settings.usejoy = 0; break; - case 1: settings.usemouse = 1; settings.usejoy = 0; break; - case 2: settings.usemouse = 0; settings.usejoy = 1; break; - case 3: settings.usemouse = 1; settings.usejoy = 1; break; - } + { + case 0: settings.usemouse = 0; settings.usejoy = 0; break; + case 1: settings.usemouse = 1; settings.usejoy = 0; break; + case 2: settings.usemouse = 0; settings.usejoy = 1; break; + case 3: settings.usemouse = 1; settings.usejoy = 1; break; + } } static void on_custommodcombo_changed(GtkComboBox *combobox, gpointer user_data) @@ -156,17 +159,17 @@ static void on_custommodcombo_changed(GtkComboBox *combobox, gpointer user_data) GtkTreePath *path; char *value; UNREFERENCED_PARAMETER(user_data); - - if (gtk_combo_box_get_active_iter (combobox, &iter)) + + if (gtk_combo_box_get_active_iter(combobox, &iter)) { - model = gtk_combo_box_get_model (combobox); - gtk_tree_model_get( model, &iter, 0,&value, -1 ); - path = gtk_tree_model_get_path(model, &iter); - - if (*gtk_tree_path_get_indices (path) == NONE) - settings.custommoddir = NULL; - else settings.custommoddir = value; - } + model = gtk_combo_box_get_model(combobox); + gtk_tree_model_get(model, &iter, 0,&value, -1); + path = gtk_tree_model_get_path(model, &iter); + + if (*gtk_tree_path_get_indices(path) == NONE) + settings.custommoddir = NULL; + else settings.custommoddir = value; + } } static void on_autoloadcheck_toggled(GtkToggleButton *togglebutton, gpointer user_data) @@ -203,7 +206,7 @@ static void on_gamelist_selection_changed(GtkTreeSelection *selection, gpointer GtkTreeModel *model; struct grpfile *fg; UNREFERENCED_PARAMETER(user_data); - + if (gtk_tree_selection_get_selected(selection, &model, &iter)) { gtk_tree_model_get(model, &iter, 2, (gpointer)&fg, -1); @@ -242,42 +245,42 @@ static void SetPage(int32_t n) if (n == TAB_CONFIG) n = TRUE; else n = FALSE; gtk_widget_set_sensitive(stwidgets.startbutton, n); gtk_container_foreach(GTK_CONTAINER(stwidgets.configtlayout), - (GtkCallback)gtk_widget_set_sensitive, - (gpointer)&n); + (GtkCallback)gtk_widget_set_sensitive, + (gpointer)&n); } static unsigned char GetModsDirNames(GtkListStore *list) { - char *homedir; - char pdir[BMAX_PATH]; - unsigned char iternumb = 0; - CACHE1D_FIND_REC *dirs = NULL; - GtkTreeIter iter; - - pathsearchmode = 1; + char *homedir; + char pdir[BMAX_PATH]; + unsigned char iternumb = 0; + CACHE1D_FIND_REC *dirs = NULL; + GtkTreeIter iter; + + pathsearchmode = 1; + + if ((homedir = Bgethomedir())) + { + Bsnprintf(pdir, sizeof(pdir), "%s/" ".eduke32", homedir); + dirs = klistpath(pdir, "*", CACHE1D_FIND_DIR); + for (dirs=dirs; dirs != NULL; dirs=dirs->next) + { + if ((Bstrcmp(dirs->name, "autoload") == 0) || + (Bstrcmp(dirs->name, "..") == 0) || + (Bstrcmp(dirs->name, ".") == 0)) + continue; + else + { + gtk_list_store_append(list, &iter); + gtk_list_store_set(list, &iter, 0,dirs->name, -1); + iternumb++; + } + } + } - if ((homedir = Bgethomedir())) - { - Bsnprintf(pdir, sizeof(pdir), "%s/" ".eduke32", homedir); - dirs = klistpath(pdir, "*", CACHE1D_FIND_DIR); - for (dirs=dirs; dirs != NULL; dirs=dirs->next) - { - if ((Bstrcmp(dirs->name, "autoload") == 0) || - (Bstrcmp(dirs->name, "..") == 0) || - (Bstrcmp(dirs->name, ".") == 0)) - continue; - else - { - gtk_list_store_append(list, &iter); - gtk_list_store_set(list, &iter, 0,dirs->name, -1); - iternumb++; - } - } - } - klistfree(dirs); dirs = NULL; - + return iternumb; } @@ -289,12 +292,12 @@ static void PopulateForm(unsigned char pgs) GtkListStore *modes3d; GtkTreeIter iter; char buf[64]; - + mode3d = checkvideomode(&settings.xdim3d, &settings.ydim3d, settings.bpp3d, settings.fullscreen, 1); if (mode3d < 0) { int32_t i, cd[] = { 32, 24, 16, 15, 8, 0 }; - + for (i=0; cd[i];) { if (cd[i] >= settings.bpp3d) i++; else break; } for (; cd[i]; i++) { @@ -304,7 +307,7 @@ static void PopulateForm(unsigned char pgs) break; } } - + modes3d = GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(stwidgets.vmode3dcombo))); gtk_list_store_clear(modes3d); @@ -323,81 +326,82 @@ static void PopulateForm(unsigned char pgs) g_signal_handlers_unblock_by_func(stwidgets.vmode3dcombo, on_vmode3dcombo_changed, NULL); } } - } - + } + if ((pgs == ALL) || (pgs == POPULATE_CONFIG)) - { + { GtkListStore *devlist, *modsdir; GtkTreeIter iter; GtkTreePath *path; char *value; unsigned char i, r = 0; - const char *availabledev[] = { - "Keyboard only", - "Keyboard and mouse", - "Keyboard and joystick", - "All supported devices" - }; - + const char *availabledev[] = + { + "Keyboard only", + "Keyboard and mouse", + "Keyboard and joystick", + "All supported devices" + }; + // populate input devices combo - devlist = GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(stwidgets.inputdevcombo))); - gtk_list_store_clear(devlist); - - for (i=0; i<(int32_t)G_N_ELEMENTS(availabledev); i++) - { - gtk_list_store_append(devlist, &iter); + devlist = GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(stwidgets.inputdevcombo))); + gtk_list_store_clear(devlist); + + for (i=0; i<(int32_t)G_N_ELEMENTS(availabledev); i++) + { + gtk_list_store_append(devlist, &iter); gtk_list_store_set(devlist, &iter, 0,availabledev[i], -1); } - switch (settings.usemouse) - { - case 0: if (settings.usejoy) - gtk_combo_box_set_active (GTK_COMBO_BOX (stwidgets.inputdevcombo), INPUT_JOYSTICK); - else - gtk_combo_box_set_active (GTK_COMBO_BOX (stwidgets.inputdevcombo), INPUT_KB); - break; - case 1: if (settings.usejoy) - gtk_combo_box_set_active (GTK_COMBO_BOX (stwidgets.inputdevcombo), INPUT_ALL); - else - gtk_combo_box_set_active (GTK_COMBO_BOX (stwidgets.inputdevcombo), INPUT_MOUSE); - break; - } - - // populate custom mod combo - modsdir = GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(stwidgets.custommodcombo))); - gtk_list_store_clear(modsdir); - - gtk_list_store_append(modsdir, &iter); + switch (settings.usemouse) + { + case 0: if (settings.usejoy) + gtk_combo_box_set_active(GTK_COMBO_BOX(stwidgets.inputdevcombo), INPUT_JOYSTICK); + else + gtk_combo_box_set_active(GTK_COMBO_BOX(stwidgets.inputdevcombo), INPUT_KB); + break; + case 1: if (settings.usejoy) + gtk_combo_box_set_active(GTK_COMBO_BOX(stwidgets.inputdevcombo), INPUT_ALL); + else + gtk_combo_box_set_active(GTK_COMBO_BOX(stwidgets.inputdevcombo), INPUT_MOUSE); + break; + } + + // populate custom mod combo + modsdir = GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(stwidgets.custommodcombo))); + gtk_list_store_clear(modsdir); + + gtk_list_store_append(modsdir, &iter); gtk_list_store_set(modsdir, &iter, 0,"None", -1); - r = GetModsDirNames(modsdir); - - for(i=0; i<=r; i++) - { - path = gtk_tree_path_new_from_indices( i, -1 ); - gtk_tree_model_get_iter( GTK_TREE_MODEL(modsdir), &iter, path ); - gtk_tree_model_get( GTK_TREE_MODEL(modsdir), &iter, 0,&value, -1 ); - - if (Bstrcmp(settings.custommoddir, "/") == 0) - { - gtk_combo_box_set_active (GTK_COMBO_BOX (stwidgets.custommodcombo), NONE); - settings.custommoddir = NULL; + r = GetModsDirNames(modsdir); - break; - } - if (Bstrcmp(settings.custommoddir, value) == 0) - { - gtk_combo_box_set_active_iter (GTK_COMBO_BOX (stwidgets.custommodcombo), - &iter); + for (i=0; i<=r; i++) + { + path = gtk_tree_path_new_from_indices(i, -1); + gtk_tree_model_get_iter(GTK_TREE_MODEL(modsdir), &iter, path); + gtk_tree_model_get(GTK_TREE_MODEL(modsdir), &iter, 0,&value, -1); + + if (Bstrcmp(settings.custommoddir, "/") == 0) + { + gtk_combo_box_set_active(GTK_COMBO_BOX(stwidgets.custommodcombo), NONE); + settings.custommoddir = NULL; + + break; + } + if (Bstrcmp(settings.custommoddir, value) == 0) + { + gtk_combo_box_set_active_iter(GTK_COMBO_BOX(stwidgets.custommodcombo), + &iter); + + break; + } + } - break; - } - } - // populate check buttons - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(stwidgets.fullscreencheck), settings.fullscreen); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(stwidgets.polymercheck), settings.polymer); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(stwidgets.autoloadcheck), settings.autoload); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(stwidgets.fullscreencheck), settings.fullscreen); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(stwidgets.polymercheck), settings.polymer); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(stwidgets.autoloadcheck), settings.autoload); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(stwidgets.alwaysshowcheck), settings.forcesetup); - } + } if ((pgs == ALL) || (pgs == POPULATE_GAME)) { @@ -476,17 +480,17 @@ static GtkWidget *create_window(void) stwidgets.tabs = gtk_notebook_new(); gtk_box_pack_start(GTK_BOX(stwidgets.vlayout), stwidgets.tabs, TRUE, TRUE, 0); gtk_container_set_border_width(GTK_CONTAINER(stwidgets.tabs), 4); - + // layout table of config page - stwidgets.configtlayout = gtk_table_new(6, 3, FALSE); - gtk_container_add (GTK_CONTAINER (stwidgets.tabs), stwidgets.configtlayout); - - // 3D video mode LabelText - stwidgets.vmode3dlabel = gtk_label_new_with_mnemonic("_Video mode:"); - gtk_misc_set_alignment (GTK_MISC(stwidgets.vmode3dlabel), 0.3, 0); - gtk_table_attach (GTK_TABLE(stwidgets.configtlayout), stwidgets.vmode3dlabel, 0,1, 0,1, GTK_FILL, 0, 4, 0); - - // 3D video mode combo + stwidgets.configtlayout = gtk_table_new(6, 3, FALSE); + gtk_container_add(GTK_CONTAINER(stwidgets.tabs), stwidgets.configtlayout); + + // 3D video mode LabelText + stwidgets.vmode3dlabel = gtk_label_new_with_mnemonic("_Video mode:"); + gtk_misc_set_alignment(GTK_MISC(stwidgets.vmode3dlabel), 0.3, 0); + gtk_table_attach(GTK_TABLE(stwidgets.configtlayout), stwidgets.vmode3dlabel, 0,1, 0,1, GTK_FILL, 0, 4, 0); + + // 3D video mode combo { GtkListStore *list = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_INT); GtkCellRenderer *cell; @@ -498,25 +502,25 @@ static GtkWidget *create_window(void) gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(stwidgets.vmode3dcombo), cell, FALSE); gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(stwidgets.vmode3dcombo), cell, "text", 0, NULL); } - gtk_table_attach (GTK_TABLE(stwidgets.configtlayout), stwidgets.vmode3dcombo, 1,2, 0,1, GTK_EXPAND | GTK_FILL, 0, 4, 0); + gtk_table_attach(GTK_TABLE(stwidgets.configtlayout), stwidgets.vmode3dcombo, 1,2, 0,1, GTK_EXPAND | GTK_FILL, 0, 4, 0); // Fullscreen checkbox - stwidgets.displayvlayout = gtk_vbox_new(TRUE, 0); - gtk_table_attach (GTK_TABLE(stwidgets.configtlayout), stwidgets.displayvlayout, 2,3, 0,1, GTK_FILL, 0, 4, 0); - stwidgets.fullscreencheck = gtk_check_button_new_with_mnemonic("_Fullscreen"); - gtk_box_pack_start(GTK_BOX(stwidgets.displayvlayout), stwidgets.fullscreencheck, FALSE, FALSE, 0); - - // Polymer checkbox - stwidgets.polymercheck = gtk_check_button_new_with_mnemonic("_Polymer"); - gtk_box_pack_start(GTK_BOX(stwidgets.displayvlayout), stwidgets.polymercheck, FALSE, FALSE, 0); + stwidgets.displayvlayout = gtk_vbox_new(TRUE, 0); + gtk_table_attach(GTK_TABLE(stwidgets.configtlayout), stwidgets.displayvlayout, 2,3, 0,1, GTK_FILL, 0, 4, 0); + stwidgets.fullscreencheck = gtk_check_button_new_with_mnemonic("_Fullscreen"); + gtk_box_pack_start(GTK_BOX(stwidgets.displayvlayout), stwidgets.fullscreencheck, FALSE, FALSE, 0); - // Input devices LabelText + // Polymer checkbox + stwidgets.polymercheck = gtk_check_button_new_with_mnemonic("_Polymer"); + gtk_box_pack_start(GTK_BOX(stwidgets.displayvlayout), stwidgets.polymercheck, FALSE, FALSE, 0); + + // Input devices LabelText stwidgets.inputdevlabel = gtk_label_new_with_mnemonic("_Input devices:"); - gtk_misc_set_alignment(GTK_MISC(stwidgets.inputdevlabel), 0.3, 0); - gtk_table_attach (GTK_TABLE(stwidgets.configtlayout), stwidgets.inputdevlabel, 0,1, 1,2, GTK_FILL, 0, 4, 0); - - // Input devices combo - { + gtk_misc_set_alignment(GTK_MISC(stwidgets.inputdevlabel), 0.3, 0); + gtk_table_attach(GTK_TABLE(stwidgets.configtlayout), stwidgets.inputdevlabel, 0,1, 1,2, GTK_FILL, 0, 4, 0); + + // Input devices combo + { GtkListStore *list = gtk_list_store_new(1, G_TYPE_STRING); GtkCellRenderer *cell; @@ -527,15 +531,15 @@ static GtkWidget *create_window(void) gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(stwidgets.inputdevcombo), cell, FALSE); gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(stwidgets.inputdevcombo), cell, "text", 0, NULL); } - gtk_table_attach (GTK_TABLE(stwidgets.configtlayout), stwidgets.inputdevcombo, 1,2, 1,2, GTK_EXPAND | GTK_FILL, 0, 4, 0); - - // Custom mod LabelText + gtk_table_attach(GTK_TABLE(stwidgets.configtlayout), stwidgets.inputdevcombo, 1,2, 1,2, GTK_EXPAND | GTK_FILL, 0, 4, 0); + + // Custom mod LabelText stwidgets.custommodlabel = gtk_label_new_with_mnemonic("Custom _Mod:"); - gtk_misc_set_alignment(GTK_MISC(stwidgets.custommodlabel), 0.3, 0); - gtk_table_attach (GTK_TABLE(stwidgets.configtlayout), stwidgets.custommodlabel, 0,1, 2,3, GTK_FILL, 0, 4, 7); - - // Custom mod combo - { + gtk_misc_set_alignment(GTK_MISC(stwidgets.custommodlabel), 0.3, 0); + gtk_table_attach(GTK_TABLE(stwidgets.configtlayout), stwidgets.custommodlabel, 0,1, 2,3, GTK_FILL, 0, 4, 7); + + // Custom mod combo + { GtkListStore *list = gtk_list_store_new(1, G_TYPE_STRING); GtkCellRenderer *cell; @@ -546,19 +550,19 @@ static GtkWidget *create_window(void) gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(stwidgets.custommodcombo), cell, FALSE); gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(stwidgets.custommodcombo), cell, "text", 0, NULL); } - gtk_table_attach (GTK_TABLE(stwidgets.configtlayout), stwidgets.custommodcombo, 1,2, 2,3, GTK_EXPAND | GTK_FILL, 0, 4, 7); - - // Empty horizontal layout - stwidgets.emptyhlayout = gtk_hbox_new(TRUE, 0); - gtk_table_attach (GTK_TABLE(stwidgets.configtlayout), stwidgets.emptyhlayout, 0,3, 3,4, 0, GTK_EXPAND | GTK_FILL, 4, 0); - + gtk_table_attach(GTK_TABLE(stwidgets.configtlayout), stwidgets.custommodcombo, 1,2, 2,3, GTK_EXPAND | GTK_FILL, 0, 4, 7); + + // Empty horizontal layout + stwidgets.emptyhlayout = gtk_hbox_new(TRUE, 0); + gtk_table_attach(GTK_TABLE(stwidgets.configtlayout), stwidgets.emptyhlayout, 0,3, 3,4, 0, GTK_EXPAND | GTK_FILL, 4, 0); + // Autoload checkbox - stwidgets.autoloadcheck = gtk_check_button_new_with_mnemonic("_Enable \"autoload\" folder"); - gtk_table_attach (GTK_TABLE(stwidgets.configtlayout), stwidgets.autoloadcheck, 0,3, 4,5, GTK_FILL, 0, 2, 2); - - // Always show config checkbox + stwidgets.autoloadcheck = gtk_check_button_new_with_mnemonic("_Enable \"autoload\" folder"); + gtk_table_attach(GTK_TABLE(stwidgets.configtlayout), stwidgets.autoloadcheck, 0,3, 4,5, GTK_FILL, 0, 2, 2); + + // Always show config checkbox stwidgets.alwaysshowcheck = gtk_check_button_new_with_mnemonic("_Always show this window at startup"); - gtk_table_attach (GTK_TABLE(stwidgets.configtlayout), stwidgets.alwaysshowcheck, 0,3, 5,6, GTK_FILL, 0, 2, 2); + gtk_table_attach(GTK_TABLE(stwidgets.configtlayout), stwidgets.alwaysshowcheck, 0,3, 5,6, GTK_FILL, 0, 2, 2); // Configuration tab stwidgets.configtab = gtk_label_new("Configuration"); @@ -601,7 +605,7 @@ static GtkWidget *create_window(void) gtk_tree_view_append_column(GTK_TREE_VIEW(stwidgets.gamelist), col); } gtk_container_add(GTK_CONTAINER(stwidgets.gamescroll), stwidgets.gamelist); - + gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(stwidgets.gamelist), FALSE); gtk_tree_view_set_enable_search(GTK_TREE_VIEW(stwidgets.gamelist), FALSE); @@ -668,34 +672,34 @@ static GtkWidget *create_window(void) gtk_box_pack_start(GTK_BOX(stwidgets.startbuttonlayout), stwidgets.startbuttonlabel, FALSE, FALSE, 0); // Wire up the signals - g_signal_connect((gpointer) stwidgets.startwin, "delete_event", + g_signal_connect((gpointer) stwidgets.startwin, "delete_event", G_CALLBACK(on_startwin_delete_event), NULL); - g_signal_connect((gpointer) stwidgets.vmode3dcombo, "changed", + g_signal_connect((gpointer) stwidgets.vmode3dcombo, "changed", G_CALLBACK(on_vmode3dcombo_changed), NULL); - g_signal_connect((gpointer) stwidgets.fullscreencheck, "toggled", + g_signal_connect((gpointer) stwidgets.fullscreencheck, "toggled", G_CALLBACK(on_fullscreencheck_toggled), NULL); - g_signal_connect((gpointer) stwidgets.polymercheck, "toggled", + g_signal_connect((gpointer) stwidgets.polymercheck, "toggled", G_CALLBACK(on_polymercheck_toggled), NULL); - g_signal_connect((gpointer) stwidgets.inputdevcombo, "changed", + g_signal_connect((gpointer) stwidgets.inputdevcombo, "changed", G_CALLBACK(on_inputdevcombo_changed), NULL); - g_signal_connect((gpointer) stwidgets.custommodcombo, "changed", + g_signal_connect((gpointer) stwidgets.custommodcombo, "changed", G_CALLBACK(on_custommodcombo_changed), NULL); - g_signal_connect((gpointer) stwidgets.autoloadcheck, "toggled", + g_signal_connect((gpointer) stwidgets.autoloadcheck, "toggled", G_CALLBACK(on_autoloadcheck_toggled), NULL); - g_signal_connect((gpointer) stwidgets.alwaysshowcheck, "toggled", + g_signal_connect((gpointer) stwidgets.alwaysshowcheck, "toggled", G_CALLBACK(on_alwaysshowcheck_toggled), NULL); - g_signal_connect((gpointer) stwidgets.cancelbutton, "clicked", + g_signal_connect((gpointer) stwidgets.cancelbutton, "clicked", G_CALLBACK(on_cancelbutton_clicked), NULL); - g_signal_connect((gpointer) stwidgets.startbutton, "clicked", + g_signal_connect((gpointer) stwidgets.startbutton, "clicked", G_CALLBACK(on_startbutton_clicked), NULL); { @@ -834,8 +838,8 @@ int32_t startwin_run(void) else settings.autoload = TRUE; if (glrendmode == RDR_POLYMER) { - if (settings.bpp3d == 8) settings.bpp3d = 32; - settings.polymer = TRUE; + if (settings.bpp3d == 8) settings.bpp3d = 32; + settings.polymer = TRUE; } PopulateForm(ALL); @@ -845,7 +849,7 @@ int32_t startwin_run(void) if (retval) // launch the game with these parameters { int32_t i; - + ud.config.ScreenWidth = settings.xdim3d; ud.config.ScreenHeight = settings.ydim3d; ud.config.ScreenBPP = settings.bpp3d; @@ -858,7 +862,7 @@ int32_t startwin_run(void) if (settings.custommoddir != NULL) Bstrcpy(g_modDir, settings.custommoddir); else Bsprintf(g_modDir, "/"); - + if (settings.autoload) ud.config.NoAutoLoad = FALSE; else ud.config.NoAutoLoad = TRUE;