diff --git a/polymer/eduke32/Makefile b/polymer/eduke32/Makefile index 800073ab8..2fc10acfc 100644 --- a/polymer/eduke32/Makefile +++ b/polymer/eduke32/Makefile @@ -198,8 +198,6 @@ else GAMEOBJS+= $(OBJ)/game_icon.$o $(OBJ)/sdlmusic.$o EDITOROBJS+= $(OBJ)/build_icon.$o - else - GAMEOBJS+= $(OBJ)/audiolib_musicstub.$o endif endif @@ -248,15 +246,6 @@ ifeq (1,$(RELEASE)) endif endif -duke3d_w32$(EXESUFFIX): $(OBJ)/wrapper.$o - $(LINK_STATUS) - if $(CC) $(CFLAGS) $(OURCFLAGS) -o $@ $^ -Wl; then $(LINK_OK); else $(LINK_FAILED); fi -ifeq (1,$(RELEASE)) - ifeq (0,$(DEBUGANYWAY)) - $(STRIP) duke3d_w32$(EXESUFFIX) - endif -endif - include Makefile.deps .PHONY: enginelib editorlib diff --git a/polymer/eduke32/Makefile.deps b/polymer/eduke32/Makefile.deps index 5c10af199..8bfff662b 100644 --- a/polymer/eduke32/Makefile.deps +++ b/polymer/eduke32/Makefile.deps @@ -46,8 +46,6 @@ $(OBJ)/mathutil.$o: $(SRC)/jmact/mathutil.c $(OBJ)/scriplib.$o: $(SRC)/jmact/scriplib.c $(SRC)/jmact/scriplib.h $(SRC)/jmact/util_lib.h $(SRC)/jmact/_scrplib.h $(EINC)/compat.h # jAudioLib objects -$(OBJ)/audiolib_fxstub.$o: $(SRC)/jaudiolib/audiolib_fxstub.c $(SRC)/jaudiolib/fx_man.h -$(OBJ)/audiolib_musicstub.$o: $(SRC)/audiolib_musicstub.c $(JAUDIOLIBDIR)/include/music.h $(OBJ)/mv_mix.$o: $(SRC)/jaudiolib/mv_mix.nasm $(OBJ)/mv_mix16.$o: $(SRC)/jaudiolib/mv_mix16.nasm diff --git a/polymer/eduke32/Makefile.msvc b/polymer/eduke32/Makefile.msvc index 806c357de..dde77a171 100644 --- a/polymer/eduke32/Makefile.msvc +++ b/polymer/eduke32/Makefile.msvc @@ -142,10 +142,6 @@ mapster32$(EXESUFFIX): $(EDITOROBJS) $(EOBJ)\$(ENGINELIB) $(EOBJ)\$(EDITORLIB) $ $(LINK) /OUT:$@ /SUBSYSTEM:WINDOWS /LIBPATH:$(DXROOT)\lib\x86" /LIBPATH:$(PLATFORMSDK)\lib" /LIBPATH:$(MSSDKROOT)\lib" $(flags_link) /MAP $** $(LIBS) $(MT) -manifest $(RSRC)\manifest.build.xml -hashupdate -outputresource:$@ -out:$@.manifest -duke3d_w32$(EXESUFFIX): $(OBJ)/wrapper.$o - $(LINK) /OUT:$@ /SUBSYSTEM:WINDOWS /LIBPATH:$(DXROOT)\lib\x86" /LIBPATH:$(PLATFORMSDK)\lib" /LIBPATH:$(MSSDKROOT)\lib" $(flags_link) /MAP $** $(LIBS) - $(MT) -manifest $@.manifest -outputresource:$@ - !include Makefile.deps enginelib editorlib: AlwaysBuild diff --git a/polymer/eduke32/build/Makefile.shared b/polymer/eduke32/build/Makefile.shared index 8b3243215..6e8cf5b18 100644 --- a/polymer/eduke32/build/Makefile.shared +++ b/polymer/eduke32/build/Makefile.shared @@ -3,8 +3,8 @@ ENGINELIB=libengine.a EDITORLIB=libbuild.a -# SDLCONFIG = /usr/local/bin/sdl-config -SDLCONFIG = sdl-config +SDLCONFIG = /usr/local/bin/sdl-config +# SDLCONFIG = sdl-config ifeq ($(wildcard $(SDLCONFIG)),$(SDLCONFIG)) SDLROOT = /usr/local diff --git a/polymer/eduke32/build/src/nedmalloc.c b/polymer/eduke32/build/src/nedmalloc.c index baa7aeead..73be86dbe 100644 --- a/polymer/eduke32/build/src/nedmalloc.c +++ b/polymer/eduke32/build/src/nedmalloc.c @@ -60,7 +60,7 @@ DEALINGS IN THE SOFTWARE. #if defined(_WIN32) #include #endif -#ifdef __linux__ +#if defined(__linux__) || defined(__FreeBSD__) /* Sadly we can't include as it causes a redefinition error */ extern size_t malloc_usable_size(void *); #endif @@ -215,10 +215,10 @@ size_t (*sysblksize)(void *)= #ifdef WIN32 /* This is the MSVCRT equivalent */ _msize; -#elif defined(__linux__) +#elif defined(__linux__) || defined(__FreeBSD__) /* This is the glibc/ptmalloc2/dlmalloc equivalent. */ malloc_usable_size; -#elif defined(__FreeBSD__) || defined(__APPLE__) +#elif defined(__APPLE__) /* This is the BSD libc equivalent. */ malloc_size; #else diff --git a/polymer/eduke32/build/src/winlayer.c b/polymer/eduke32/build/src/winlayer.c index cb6a72c8c..b8dbb1726 100644 --- a/polymer/eduke32/build/src/winlayer.c +++ b/polymer/eduke32/build/src/winlayer.c @@ -1259,7 +1259,7 @@ static BOOL CALLBACK InitDirectInput_enum(LPCDIDEVICEINSTANCE lpddi, LPVOID pvRe break; default: // d = "OTHER"; break; - return DIENUM_STOP; + return DIENUM_CONTINUE; } initprintf(" * %s: %s\n", d, lpddi->tszProductName); diff --git a/polymer/eduke32/source/actors.c b/polymer/eduke32/source/actors.c index ef940bb55..ec57e7669 100644 --- a/polymer/eduke32/source/actors.c +++ b/polymer/eduke32/source/actors.c @@ -1238,7 +1238,7 @@ ACTOR_STATIC void G_MoveFX(void) } if (x >= ht && T1 == 1) { - T1 = 0; + // T1 = 0; S_StopEnvSound(s->lotag,i); } } @@ -6798,9 +6798,9 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3 { q = sprite[sprite[j].owner].sectnum; sector[sprite[j].sectnum].floorpal = sector[sprite[j].sectnum].ceilingpal = - sector[q].floorpal; + sector[q].floorpal; sector[sprite[j].sectnum].floorshade = sector[sprite[j].sectnum].ceilingshade = - sector[q].floorshade; + sector[q].floorshade; ActorExtra[sprite[j].owner].temp_data[0] = 2; } @@ -6826,11 +6826,11 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3 { q = sprite[l].sectnum; sector[q].floorshade = - sector[q].ceilingshade = - sprite[sprite[l].owner].shade; + sector[q].ceilingshade = + sprite[sprite[l].owner].shade; sector[q].floorpal = - sector[q].ceilingpal = - sprite[sprite[l].owner].pal; + sector[q].ceilingpal = + sprite[sprite[l].owner].pal; } break; diff --git a/polymer/eduke32/source/audiolib_musicstub.c b/polymer/eduke32/source/audiolib_musicstub.c deleted file mode 100644 index 06f9c4e4a..000000000 --- a/polymer/eduke32/source/audiolib_musicstub.c +++ /dev/null @@ -1,510 +0,0 @@ -//------------------------------------------------------------------------- -/* -Duke Nukem Copyright (C) 1996, 2003 3D Realms Entertainment - -This file is part of Duke Nukem 3D version 1.5 - Atomic Edition - -Duke Nukem 3D is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - Dummy AudioLib stub implementation by Jonathon Fowler (jonof@edgenetwk.com) -*/ -//------------------------------------------------------------------------- - -#include "music.h" - - -#define TRUE ( 1 == 1 ) -#define FALSE ( !TRUE ) - - -int32_t MUSIC_ErrorCode = MUSIC_Ok; - - -/*--------------------------------------------------------------------- - Function: MUSIC_ErrorString - - Returns a pointer to the error message associated with an error - number. A -1 returns a pointer the current error. ----------------------------------------------------------------------*/ - -char *MUSIC_ErrorString -( - int32_t ErrorNumber -) - -{ - char *ErrorString; - - switch (ErrorNumber) - { - case MUSIC_Warning : - case MUSIC_Error : - ErrorString = MUSIC_ErrorString(MUSIC_ErrorCode); - break; - - case MUSIC_Ok : - ErrorString = "Music ok."; - break; - - case MUSIC_ASSVersion : - ErrorString = "Apogee Sound System Version " - "Programmed by Jim Dose\n" - "(c) Copyright 1996 James R. Dose. All Rights Reserved.\n"; - break; - - case MUSIC_SoundCardError : - break; - - case MUSIC_MPU401Error : - ErrorString = "Could not detect MPU-401."; - break; - - case MUSIC_InvalidCard : - ErrorString = "Invalid Music device."; - break; - - case MUSIC_MidiError : - ErrorString = "Error playing MIDI file."; - break; - - case MUSIC_TaskManError : - ErrorString = "TaskMan error."; - break; - - case MUSIC_DPMI_Error : - ErrorString = "DPMI Error in MUSIC."; - break; - - default : - ErrorString = "Unknown Music error code."; - break; - } - - return(ErrorString); -} - - -/*--------------------------------------------------------------------- - Function: MUSIC_Init - - Selects which sound device to use. ----------------------------------------------------------------------*/ - -int32_t MUSIC_Init -( - int32_t SoundCard, - int32_t Address -) - -{ - int32_t i; - int32_t status; - - status = MUSIC_Ok; - - return(status); -} - - -/*--------------------------------------------------------------------- - Function: MUSIC_Shutdown - - Terminates use of sound device. ----------------------------------------------------------------------*/ - -int32_t MUSIC_Shutdown -( - void -) - -{ - int32_t status; - - status = MUSIC_Ok; - - - return(status); -} - - -/*--------------------------------------------------------------------- - Function: MUSIC_SetMaxFMMidiChannel - - Sets the maximum MIDI channel that FM cards respond to. ----------------------------------------------------------------------*/ - -void MUSIC_SetMaxFMMidiChannel -( - int32_t channel -) - -{ -} - - -/*--------------------------------------------------------------------- - Function: MUSIC_SetVolume - - Sets the volume of music playback. ----------------------------------------------------------------------*/ - -void MUSIC_SetVolume -( - int32_t volume -) - -{ -} - - -/*--------------------------------------------------------------------- - Function: MUSIC_SetMidiChannelVolume - - Sets the volume of music playback on the specified MIDI channel. ----------------------------------------------------------------------*/ - -void MUSIC_SetMidiChannelVolume -( - int32_t channel, - int32_t volume -) - -{ -} - - -/*--------------------------------------------------------------------- - Function: MUSIC_ResetMidiChannelVolumes - - Sets the volume of music playback on all MIDI channels to full volume. ----------------------------------------------------------------------*/ - -void MUSIC_ResetMidiChannelVolumes -( - void -) - -{ -} - - -/*--------------------------------------------------------------------- - Function: MUSIC_GetVolume - - Returns the volume of music playback. ----------------------------------------------------------------------*/ - -int32_t MUSIC_GetVolume -( - void -) - -{ - return(0); -} - - -/*--------------------------------------------------------------------- - Function: MUSIC_SetLoopFlag - - Set whether the music will loop or end when it reaches the end of - the song. ----------------------------------------------------------------------*/ - -void MUSIC_SetLoopFlag -( - int32_t loopflag -) - -{ -} - - -/*--------------------------------------------------------------------- - Function: MUSIC_SongPlaying - - Returns whether there is a song playing. ----------------------------------------------------------------------*/ - -int32_t MUSIC_SongPlaying -( - void -) - -{ - return(0); -} - - -/*--------------------------------------------------------------------- - Function: MUSIC_Continue - - Continues playback of a paused song. ----------------------------------------------------------------------*/ - -void MUSIC_Continue -( - void -) - -{ -} - - -/*--------------------------------------------------------------------- - Function: MUSIC_Pause - - Pauses playback of a song. ----------------------------------------------------------------------*/ - -void MUSIC_Pause -( - void -) - -{ -} - - -/*--------------------------------------------------------------------- - Function: MUSIC_StopSong - - Stops playback of current song. ----------------------------------------------------------------------*/ - -int32_t MUSIC_StopSong -( - void -) - -{ - return(MUSIC_Ok); -} - - -/*--------------------------------------------------------------------- - Function: MUSIC_PlaySong - - Begins playback of MIDI song. ----------------------------------------------------------------------*/ - -int32_t MUSIC_PlaySong -( - uint8_t *song, - int32_t loopflag -) - -{ - return(MUSIC_Ok); -} - - -/*--------------------------------------------------------------------- - Function: MUSIC_SetContext - - Sets the song context. ----------------------------------------------------------------------*/ - -void MUSIC_SetContext -( - int32_t context -) - -{ -} - - -/*--------------------------------------------------------------------- - Function: MUSIC_GetContext - - Returns the current song context. ----------------------------------------------------------------------*/ - -int32_t MUSIC_GetContext -( - void -) - -{ -} - - -/*--------------------------------------------------------------------- - Function: MUSIC_SetSongTick - - Sets the position of the song pointer. ----------------------------------------------------------------------*/ - -void MUSIC_SetSongTick -( - uint32_t PositionInTicks -) - -{ -} - - -/*--------------------------------------------------------------------- - Function: MUSIC_SetSongTime - - Sets the position of the song pointer. ----------------------------------------------------------------------*/ - -void MUSIC_SetSongTime -( - uint32_t milliseconds -) - -{ -} - - -/*--------------------------------------------------------------------- - Function: MUSIC_SetSongPosition - - Sets the position of the song pointer. ----------------------------------------------------------------------*/ - -void MUSIC_SetSongPosition -( - int32_t measure, - int32_t beat, - int32_t tick -) - -{ -} - - -/*--------------------------------------------------------------------- - Function: MUSIC_GetSongPosition - - Returns the position of the song pointer. ----------------------------------------------------------------------*/ - -void MUSIC_GetSongPosition -( - songposition *pos -) - -{ -} - - -/*--------------------------------------------------------------------- - Function: MUSIC_GetSongLength - - Returns the length of the song. ----------------------------------------------------------------------*/ - -void MUSIC_GetSongLength -( - songposition *pos -) - -{ -} - - - - - - -/*--------------------------------------------------------------------- - Function: MUSIC_FadeVolume - - Fades music volume from current level to another over a specified - period of time. ----------------------------------------------------------------------*/ - -int32_t MUSIC_FadeVolume -( - int32_t tovolume, - int32_t milliseconds -) - -{ - return(MUSIC_Ok); -} - - -/*--------------------------------------------------------------------- - Function: MUSIC_FadeActive - - Returns whether the fade routine is active. ----------------------------------------------------------------------*/ - -int32_t MUSIC_FadeActive -( - void -) - -{ - return(0); -} - - -/*--------------------------------------------------------------------- - Function: MUSIC_StopFade - - Stops fading the music. ----------------------------------------------------------------------*/ - -void MUSIC_StopFade -( - void -) - -{ -} - - -/*--------------------------------------------------------------------- - Function: MUSIC_RerouteMidiChannel - - Sets callback function to reroute MIDI commands from specified - function. ----------------------------------------------------------------------*/ - -void MUSIC_RerouteMidiChannel -( - int32_t channel, - int32_t (*function)(int32_t event, int32_t c1, int32_t c2) -) - -{ -} - - -/*--------------------------------------------------------------------- - Function: MUSIC_RegisterTimbreBank - - Halts playback of all sounds. ----------------------------------------------------------------------*/ - -void MUSIC_RegisterTimbreBank -( - uint8_t *timbres -) - -{ -} - - -void MUSIC_Update(void) -{ -} - diff --git a/polymer/eduke32/source/funct.h b/polymer/eduke32/source/funct.h index 65673cb24..0dc75eb5a 100644 --- a/polymer/eduke32/source/funct.h +++ b/polymer/eduke32/source/funct.h @@ -42,7 +42,7 @@ extern int32_t A_PlaySound(uint32_t num,int32_t i); extern void S_StopSound(int32_t num); extern void S_StopEnvSound(int32_t num,int32_t i); extern void S_Pan3D(void); -extern void S_TestSoundCallback(uint32_t num); +extern void S_Callback(uint32_t num); extern void S_ClearSoundLocks(void); extern int32_t A_CallSound(int32_t sn,int32_t whatsprite); extern int32_t G_CheckActivatorMotion(int32_t lotag); diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index a9a3104a2..ef21f3ea2 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -67,6 +67,12 @@ extern int32_t G_GetVersionFromWebsite(char *buffer); static int32_t usecwd = 0; #endif /* _WIN32 */ +/* +this should be lower than the MTU size by at least the size of the UDP and ENet headers +or else fragmentation will occur +*/ +#define SYNCPACKETSIZE 1408 + ENetHost * g_netServer = NULL; ENetHost * g_netClient = NULL; ENetPeer * g_netClientPeer = NULL; @@ -318,6 +324,7 @@ void P_SetGamePalette(DukePlayer_t *player, uint8_t *pal, int32_t set) player->palette = pal; } +// FIXME: this function sucks. int32_t gametext_z(int32_t small, int32_t starttile, int32_t x,int32_t y,const char *t,int32_t s,int32_t p,int32_t orientation,int32_t x1, int32_t y1, int32_t x2, int32_t y2, int32_t z) { int32_t ac,newx,oldx=x; @@ -609,7 +616,6 @@ void Net_Connect(const 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) @@ -786,6 +792,7 @@ void Net_SendUserMapName(void) enet_host_broadcast(g_netServer, CHAN_GAMESTATE, enet_packet_create(packbuf, j, ENET_PACKET_FLAG_RELIABLE)); } +// FIXME: change all of the game starting support code to be fully server controlled void Net_NewGame(int32_t volume, int32_t level) { packbuf[0] = PACKET_NEW_GAME; @@ -813,18 +820,16 @@ static int32_t spritecrc[MAXSPRITES], lastupdate[MAXSPRITES], sectcrc[MAXSECTORS static int32_t wallcrc[MAXWALLS], lastwallupdate[MAXWALLS]; static int32_t peractorvals[MAXGAMEVARS][MAXSPRITES], perplayervals[MAXGAMEVARS][MAXPLAYERS]; +// sends a simple crc32 of the current password, verified by the server before the connection can continue static void Net_SendChallenge(void) { - int32_t l; - uint32_t crc; + int32_t l = 1; + uint32_t crc = crc32once((uint8_t *)g_netPassword, Bstrlen(g_netPassword)); if (!g_netClientPeer) return; - crc = crc32once((uint8_t *)g_netPassword, Bstrlen(g_netPassword)); - buf[0] = PACKET_AUTH; - l = 1; - *(uint32_t *)&buf[l] = crc; + *(uint32_t *)&buf[1] = crc; l += sizeof(int32_t); buf[l++] = myconnectindex; @@ -872,10 +877,12 @@ void P_Disconnected(int32_t i) } Bstrcpy(ScriptQuotes[116],buf); - g_player[myconnectindex].ps->ftq = 116, g_player[myconnectindex].ps->fta = 180; + g_player[myconnectindex].ps->ftq = 116; + g_player[myconnectindex].ps->fta = 180; } } +// sync a connecting player up with the current game state void Net_SyncPlayer(ENetEvent * event) { int32_t i, j; @@ -886,10 +893,8 @@ void Net_SyncPlayer(ENetEvent * event) if (!g_player[i].playerquitflag) break; - // no slots empty from players quitting, so open a new one - if (i == -1) - i = playerswhenstarted++; - event->peer->data = (void *) ((intptr_t) i); + // open a new slot if necessary + event->peer->data = (void *)((intptr_t) (i = (i == -1 ? playerswhenstarted++ : i))); clearbufbyte(&g_player[i].playerquitflag,1,0x01010101); g_player[i].movefifoend = 1; @@ -946,12 +951,17 @@ void Net_SyncPlayer(ENetEvent * event) G_SaveMapState(g_multiMapState); j = qlz_compress((char *)g_multiMapState, buf, sizeof(mapstate_t), state_compress); - while (j > 1024) + + // all of these packets are SYNCPACKETSIZE + while (j >= SYNCPACKETSIZE) { - enet_peer_send(event->peer, CHAN_SYNC, enet_packet_create((char *)(buf)+qlz_size_compressed(buf)-j, 1024, ENET_PACKET_FLAG_RELIABLE)); - j -= 1024; + enet_peer_send(event->peer, CHAN_SYNC, + enet_packet_create((char *)(buf)+qlz_size_compressed(buf)-j, SYNCPACKETSIZE, ENET_PACKET_FLAG_RELIABLE)); + j -= SYNCPACKETSIZE; } - enet_peer_send(event->peer, CHAN_SYNC, enet_packet_create((char *)(buf)+qlz_size_compressed(buf)-j, j, ENET_PACKET_FLAG_RELIABLE)); + // ...except for this one. A non-SYNCPACKETSIZE packet on CHAN_SYNC doubles as the signal that the transfer is done. + enet_peer_send(event->peer, CHAN_SYNC, + enet_packet_create((char *)(buf)+qlz_size_compressed(buf)-j, j, ENET_PACKET_FLAG_RELIABLE)); Bfree(buf); Bfree(g_multiMapState); g_multiMapState = NULL; @@ -1231,22 +1241,17 @@ process: } 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); + Bstrncpy(recbuf, (char *)packbuf+2, packbufleng-2); recbuf[packbufleng-2] = 0; G_AddUserQuote(recbuf); S_PlaySound(EXITMENUSOUND); - pus = NUMPAGES; - pub = NUMPAGES; + pus = pub = NUMPAGES; break; @@ -1564,8 +1569,7 @@ void Net_ParseClientPacket(ENetEvent * event) return; case PACKET_MESSAGE: - //slaves in M/S mode only send to master - Bstrcpy(recbuf,(char *)packbuf+2); + Bstrncpy(recbuf, (char *)packbuf+2, packbufleng-2); recbuf[packbufleng-2] = 0; G_AddUserQuote(recbuf); @@ -1630,8 +1634,7 @@ void Net_ParseClientPacket(ENetEvent * event) 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]; + for (j=i; i-j<10; i++) g_player[other].wchoice[i-j] = packbuf[i]; break; @@ -1855,7 +1858,7 @@ void Net_GetPackets(void) event.peer -> data, event.channelID); - // mapstate transfer from the server... all packets but the last are exactly 1 kB + // mapstate transfer from the server... all packets but the last are SYNCPACKETSIZE if (event.channelID == CHAN_SYNC) { static int32_t datasiz = 0; @@ -1871,10 +1874,10 @@ void Net_GetPackets(void) buf = Bcalloc(1, sizeof(mapstate_t)<<1); } - if (buf && event.packet->dataLength == 1024) + if (buf && event.packet->dataLength == SYNCPACKETSIZE) { Bmemcpy((char *)(buf)+datasiz, event.packet->data, event.packet->dataLength); - datasiz += 1024; + datasiz += SYNCPACKETSIZE; } // last packet of mapstate sequence else if (buf) @@ -2116,7 +2119,8 @@ void Net_UpdateClients(void) { l = crc32once((uint8_t *)&sprite[i], sizeof(spritetype)); - if (!lastupdate[i] || spritecrc[i] != l) + // only send STAT_MISC sprites at spawn time and let the client handle it from there + if (!lastupdate[i] || (spritecrc[i] != l && sprite[i].statnum != STAT_MISC)) { int32_t jj = 0; diff --git a/polymer/eduke32/source/gamedef.c b/polymer/eduke32/source/gamedef.c index 86fb3fce7..9c26412c1 100644 --- a/polymer/eduke32/source/gamedef.c +++ b/polymer/eduke32/source/gamedef.c @@ -39,7 +39,7 @@ char g_szScriptFileName[BMAX_PATH] = "(none)"; // file we're currently compilin static char g_szCurrentBlockName[256] = "(none)", g_szLastBlockName[256] = "NULL"; int32_t g_totalLines,g_lineNumber; -static int32_t g_checkingIfElse,g_processingState; +static int32_t g_checkingIfElse, g_processingState, g_lastKeyword = -1; char g_szBuf[1024]; intptr_t *g_caseScriptPtr=NULL; // the pointer to the start of the case table in a switch statement @@ -1993,7 +1993,7 @@ static int32_t C_CountCaseStatements() static int32_t C_ParseCommand(void) { - int32_t i, j=0, k=0, done, tw; + int32_t i, j=0, k=0, done, tw, otw = g_lastKeyword; char *temptextptr; intptr_t *tempscrptr = NULL; @@ -2015,7 +2015,7 @@ static int32_t C_ParseCommand(void) //Bsprintf(g_szBuf,"PC(): '%.25s'",textptr); //AddLog(g_szBuf); } - tw = C_GetNextKeyword(); + g_lastKeyword = tw = C_GetNextKeyword(); // Bsprintf(tempbuf,"%s",keyw[tw]); // AddLog(tempbuf); @@ -4677,8 +4677,7 @@ repeatcase: //Bsprintf(g_szBuf,"case3: %.12s",textptr); //AddLog(g_szBuf); - j = C_GetKeyword(); - if (j == CON_CASE) + if (C_GetKeyword() == CON_CASE) { //AddLog("Found Repeat Case"); C_GetNextKeyword(); // eat 'case' @@ -4691,8 +4690,7 @@ repeatcase: { //Bsprintf(g_szBuf,"case5 '%.25s'",textptr); //AddLog(g_szBuf); - j = C_GetKeyword(); - if (j == CON_CASE) + if (C_GetKeyword() == CON_CASE) { //AddLog("Found Repeat Case"); C_GetNextKeyword(); // eat 'case' @@ -5651,6 +5649,13 @@ repeatcase: case CON_BREAK: if (g_checkingSwitch) { + if (otw == CON_BREAK) + { + C_ReportError(-1); + initprintf("%s:%d: error: duplicate `break'.\n",g_szScriptFileName, g_lineNumber); + g_numCompilerErrors++; + } + //Bsprintf(g_szBuf," * (L%d) case Break statement.\n",g_lineNumber); //AddLog(g_szBuf); return 1; diff --git a/polymer/eduke32/source/gameexec.c b/polymer/eduke32/source/gameexec.c index 50a9e4fbe..539777b3b 100644 --- a/polymer/eduke32/source/gameexec.c +++ b/polymer/eduke32/source/gameexec.c @@ -1615,7 +1615,7 @@ skip_check: insptr++; { int32_t i = Gv_GetVarX(*insptr++), - f=Gv_GetVarX(*insptr++); + f=Gv_GetVarX(*insptr++); int32_t j=Gv_GetVarX(*insptr++); if ((i<0 || i>=MAXQUOTES) /* && g_scriptSanityChecks */) OSD_Printf(CON_ERROR "invalid quote ID %d\n",g_errorLineNum,keyw[g_tw],i); diff --git a/polymer/eduke32/source/global.c b/polymer/eduke32/source/global.c index 2054c6f28..1820f1f36 100644 --- a/polymer/eduke32/source/global.c +++ b/polymer/eduke32/source/global.c @@ -165,7 +165,7 @@ char szPlayerName[32]; int32_t g_damageCameras,g_freezerSelfDamage=0,g_tripbombLaserMode=0; int32_t g_gameQuit = 0,everyothertime; int32_t g_numFreezeBounces=3,g_rpgBlastRadius,g_pipebombBlastRadius,g_tripbombBlastRadius, - g_shrinkerBlastRadius,g_morterBlastRadius,g_bouncemineBlastRadius,g_seenineBlastRadius; + g_shrinkerBlastRadius,g_morterBlastRadius,g_bouncemineBlastRadius,g_seenineBlastRadius; DukeStatus_t sbar; int32_t mymaxlag, otherminlag, bufferjitter = 1; diff --git a/polymer/eduke32/source/menus.c b/polymer/eduke32/source/menus.c index 6700a6d83..fe0fad53f 100644 --- a/polymer/eduke32/source/menus.c +++ b/polymer/eduke32/source/menus.c @@ -3829,8 +3829,9 @@ cheat_for_port_credits: else if (function == 2) { static char *directions[] = - { "UP", "RIGHT", "DOWN", "LEFT" - }; + { + "UP", "RIGHT", "DOWN", "LEFT" + }; if (whichkey < 2*joynumbuttons) Bsprintf(tempbuf,"TO %s%s", (whichkey&1)?"DOUBLE-CLICKED ":"", getjoyname(1,whichkey>>1)); else @@ -4094,8 +4095,9 @@ cheat_for_port_credits: else { static char *directions[] = - { "Up", "Right", "Down", "Left" - }; + { + "Up", "Right", "Down", "Left" + }; Bsprintf(tempbuf, "Hat %s", directions[(l+m)-2*joynumbuttons]); x = ud.config.JoystickFunctions[joynumbuttons + ((l+m)-2*joynumbuttons)][0]; } diff --git a/polymer/eduke32/source/osdcmds.c b/polymer/eduke32/source/osdcmds.c index 0559187fd..2f95df02a 100644 --- a/polymer/eduke32/source/osdcmds.c +++ b/polymer/eduke32/source/osdcmds.c @@ -418,7 +418,7 @@ static int32_t osdcmd_restartvid(const osdfuncparm_t *parm) static int32_t osdcmd_vidmode(const osdfuncparm_t *parm) { int32_t newbpp = ud.config.ScreenBPP, newwidth = ud.config.ScreenWidth, - newheight = ud.config.ScreenHeight, newfs = ud.config.ScreenMode; + newheight = ud.config.ScreenHeight, newfs = ud.config.ScreenMode; if (parm->numparms < 1 || parm->numparms > 4) return OSDCMD_SHOWHELP; switch (parm->numparms) diff --git a/polymer/eduke32/source/player.c b/polymer/eduke32/source/player.c index e33686f8c..dbec3273b 100644 --- a/polymer/eduke32/source/player.c +++ b/polymer/eduke32/source/player.c @@ -3553,7 +3553,7 @@ int16_t WeaponPickupSprites[MAX_WEAPONS] = { KNEE__STATIC, FIRSTGUNSPRITE__STATI void P_DropWeapon(DukePlayer_t *p) { int32_t snum = sprite[p->i].yvel, - cw = aplWeaponWorksLike[p->curr_weapon][snum]; + cw = aplWeaponWorksLike[p->curr_weapon][snum]; if (cw < 1 || cw >= MAX_WEAPONS) return; diff --git a/polymer/eduke32/source/savegame.c b/polymer/eduke32/source/savegame.c index 84a5fed7a..229ed4cfa 100644 --- a/polymer/eduke32/source/savegame.c +++ b/polymer/eduke32/source/savegame.c @@ -959,7 +959,7 @@ static int32_t ds_getcnt(const dataspec_t *sp) { switch (sp->flags&DS_CNTMASK) { - case 0: return sp->cnt; + case 0: return sp->cnt; case DS_CNT16: return *((int16_t *)sp->cnt); case DS_CNT32: return *((int32_t *)sp->cnt); default: return -1; @@ -1007,7 +1007,7 @@ static uint8_t *writespecdata(const dataspec_t *spec, FILE *fil, uint8_t *dump) if (fil) { if (((sp->flags&DS_CNTMASK)==0 && sp->size*cnt<=(int32_t)savegame_comprthres) - || (sp->flags&DS_CMP)) + || (sp->flags&DS_CMP)) fwrite(ptr, sp->size, cnt, fil); else dfwrite((void *)ptr, sp->size, cnt, fil); @@ -1090,7 +1090,7 @@ static int32_t readspecdata(const dataspec_t *spec, int32_t fil, uint8_t **dumpv OSD_Printf("rsd: %s: read %d, expected %d!\n", ((sp->flags&DS_CNTMASK)==0 && sp->size*cnt<=(int32_t)savegame_comprthres)? "UNCOMP":"COMPR", i, j); - + if (i==-1) perror("read"); // *(int32_t *)0 = 1; @@ -1119,7 +1119,7 @@ static void docmpsd(const void *ptr, void *dump, uint32_t size, uint32_t cnt, ui uint8_t *retdiff = *diffvar; // Hail to the C preprocessor, baby! - #define CPSINGLEVAL(Datbits) \ +#define CPSINGLEVAL(Datbits) \ if (VAL(Datbits, ptr) != VAL(Datbits, dump)) \ { \ VAL(Datbits, retdiff) = VAL(Datbits, dump) = VAL(Datbits, ptr); \ @@ -1135,7 +1135,7 @@ static void docmpsd(const void *ptr, void *dump, uint32_t size, uint32_t cnt, ui case 1: CPSINGLEVAL(8); return; } - #define CPELTS(Idxbits, Datbits) do \ +#define CPELTS(Idxbits, Datbits) do \ { \ for (i=0; iflags!=DS_END; spec++) + for (; spec->flags!=DS_END; spec++) n += (spec->flags&(DS_STRING|DS_CMP|DS_NOCHK|DS_SAVEFN|DS_LOADFN) ? 0 : 1); return n; } @@ -1266,7 +1266,7 @@ static int32_t applydiff(const dataspec_t *spec, uint8_t **dumpvar, uint8_t **di } // ---------- - #define CPSINGLEVAL(Datbits) \ +#define CPSINGLEVAL(Datbits) \ VAL(Datbits, dumptr) = VAL(Datbits, diffptr); \ diffptr += BYTES(Datbits); \ dumptr += BYTES(Datbits) @@ -1282,7 +1282,7 @@ static int32_t applydiff(const dataspec_t *spec, uint8_t **dumpvar, uint8_t **di } } - #define CPELTS(Idxbits, Datbits) do \ +#define CPELTS(Idxbits, Datbits) do \ { \ UINT(Idxbits) idx; \ goto readidx_##Idxbits##_##Datbits; \ @@ -1296,7 +1296,7 @@ readidx_##Idxbits##_##Datbits: \ } while ((int##Idxbits##_t)idx != -1); \ } while (0) - #define CPDATA(Datbits) do \ +#define CPDATA(Datbits) do \ { \ uint32_t nelts=(sp->size*cnt)/BYTES(Datbits); \ if (nelts>65536) \ @@ -1318,9 +1318,9 @@ readidx_##Idxbits##_##Datbits: \ dumptr += sp->size*cnt; // ---------- - #undef CPELTS - #undef CPSINGLEVAL - #undef CPDATA +#undef CPELTS +#undef CPSINGLEVAL +#undef CPDATA } *diffvar = diffptr; @@ -1383,8 +1383,8 @@ static void sv_restload(); static uint8_t savegame_bitmap[MAXSPRITES>>3][3]; static uint32_t savegame_bitptrsize; static uint8_t savegame_quotedef[MAXQUOTES>>3]; -static char (*savegame_quotes)[MAXQUOTELEN]; -static char (*savegame_quoteredefs)[MAXQUOTELEN]; +static char(*savegame_quotes)[MAXQUOTELEN]; +static char(*savegame_quoteredefs)[MAXQUOTELEN]; static uint8_t savegame_restdata[SVARDATALEN]; static const dataspec_t svgm_udnetw[] = @@ -1776,16 +1776,16 @@ uint32_t sv_writediff(FILE *fil) int32_t sv_readdiff(int32_t fil) { uint8_t *p=svsnapshot, *d=svdiff, i=0; //, tbuf[4]; - int32_t diffsiz; + int32_t diffsiz; #if 0 // handled by the caller - if (kread(fil, tbuf, 4)!=4) - return -1; - if (Bmemcmp(tbuf, "dIfF", 4)) - return 4; + if (kread(fil, tbuf, 4)!=4) + return -1; + if (Bmemcmp(tbuf, "dIfF", 4)) + return 4; #endif - if (kread(fil, &diffsiz, sizeof(uint32_t))!=sizeof(uint32_t)) - return -1; + if (kread(fil, &diffsiz, sizeof(uint32_t))!=sizeof(uint32_t)) + return -1; if (savegame_diffcompress) { if (kdfread(svdiff, 1, diffsiz, fil) != diffsiz) // cnt and sz swapped @@ -1797,20 +1797,20 @@ int32_t sv_readdiff(int32_t fil) return -2; } - if (applydiff(svgm_udnetw, &p, &d)) return -3; - if (applydiff(svgm_secwsp, &p, &d)) return -4; - if (applydiff(svgm_script, &p, &d)) return -5; - if (applydiff(svgm_anmisc, &p, &d)) return -6; - if (applydiff(svgm_vars, &p, &d)) return -7; + if (applydiff(svgm_udnetw, &p, &d)) return -3; + if (applydiff(svgm_secwsp, &p, &d)) return -4; + if (applydiff(svgm_script, &p, &d)) return -5; + if (applydiff(svgm_anmisc, &p, &d)) return -6; + if (applydiff(svgm_vars, &p, &d)) return -7; - if (p!=svsnapshot+svsnapsiz) - i|=1; - if (d!=svdiff+diffsiz) - i|=2; - if (i) - OSD_Printf("sv_readdiff: p=%p, svsnapshot+svsnapsiz=%p; d=%p, svdiff+diffsiz=%p", - p, svsnapshot+svsnapsiz, d, svdiff+diffsiz); - return i; + if (p!=svsnapshot+svsnapsiz) + i|=1; + if (d!=svdiff+diffsiz) + i|=2; + if (i) + OSD_Printf("sv_readdiff: p=%p, svsnapshot+svsnapsiz=%p; d=%p, svdiff+diffsiz=%p", + p, svsnapshot+svsnapsiz, d, svdiff+diffsiz); + return i; } // SVGM data description @@ -1913,8 +1913,8 @@ static void sv_postactordata() intptr_t j=(intptr_t)&script[0]; #if POLYMER - if (getrendermode() == 4) - polymer_resetlights(); + if (getrendermode() == 4) + polymer_resetlights(); #endif for (i=0; i 0) l++; - if (g_sounds[num].m&1) + if (l < MAXSOUNDINSTANCES) { - if (g_sounds[num].num > 0) return -1; + if (g_sounds[num].m&1) + { + 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); + 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); + } + else + { + voice = FX_PlayAuto3D(g_sounds[ num ].ptr, g_sounds[num].soundsiz, pitch,sndang>>4,sndist>>6, g_sounds[num].pr, + (num * MAXSOUNDINSTANCES) + l); + } + + if (voice >= FX_Ok) + { + g_sounds[num].SoundOwner[l].i = i; + g_sounds[num].SoundOwner[l].voice = voice; + g_sounds[num].num++; + } + else g_soundlocks[num]--; } else { - voice = FX_PlayAuto3D(g_sounds[ num ].ptr, g_sounds[num].soundsiz, pitch,sndang>>4,sndist>>6, g_sounds[num].pr, - (num * MAXSOUNDINSTANCES) + l); + g_soundlocks[num]--; + return -1; } - - if (voice >= FX_Ok) - { - g_sounds[num].SoundOwner[l].i = i; - g_sounds[num].SoundOwner[l].voice = voice; - g_sounds[num].num++; - } - else g_soundlocks[num]--; } return (voice); } @@ -655,45 +663,37 @@ int32_t A_PlaySound(uint32_t num, int32_t i) void S_StopSound(int32_t num) { - if (num >= 0 && num < MAXSOUNDS) + if (num >= 0 && num < MAXSOUNDS && g_sounds[num].num > 0) { - if (g_sounds[num].num > 0) - { - int32_t j=MAXSOUNDINSTANCES-1; + int32_t j=MAXSOUNDINSTANCES-1; - for (; j>=0; j--) + for (; j>=0; j--) + { + if (g_sounds[num].SoundOwner[j].voice) { - if (g_sounds[num].SoundOwner[j].voice) - { - FX_StopSound(g_sounds[num].SoundOwner[j].voice); - g_sounds[num].SoundOwner[j].voice = 0; - } - // S_TestSoundCallback(num); + FX_StopSound(g_sounds[num].SoundOwner[j].voice); + // g_sounds[num].SoundOwner[j].voice = 0; } + // S_Callback(num); } } } void S_StopEnvSound(int32_t num,int32_t i) { - if (num >= 0 && num < MAXSOUNDS) + if (num >= 0 && num < MAXSOUNDS && g_sounds[num].num > 0) { - if (g_sounds[num].num > 0) - { - int32_t j=MAXSOUNDINSTANCES-1; + int32_t j=MAXSOUNDINSTANCES-1; - for (; j>=0; j--) + for (; j>=0; j--) + { + if (g_sounds[num].SoundOwner[j].i == i && g_sounds[num].SoundOwner[j].voice) { - if (g_sounds[num].SoundOwner[j].i == i) - { - if (g_sounds[num].SoundOwner[j].voice) - { - FX_StopSound(g_sounds[num].SoundOwner[j].voice); - g_sounds[num].SoundOwner[j].voice = 0; - } -// S_TestSoundCallback(num); - } + // OSD_Printf("stopping sound %d index %d spr %d\n",num,j,i); + FX_StopSound(g_sounds[num].SoundOwner[j].voice); + // g_sounds[num].SoundOwner[j].voice = 0; } + // S_Callback(num); } } } @@ -730,7 +730,7 @@ void S_Pan3D(void) if (i < 0 || i >= MAXSPRITES || g_sounds[j].SoundOwner[k].voice < 1) { // OSD_Printf(OSD_ERROR "S_Pan3D(): INTERNAL ERROR: invalid id %d!\n",i); - k--; +// k--; continue; } @@ -788,7 +788,7 @@ void S_Pan3D(void) while (j--); } -void S_TestSoundCallback(uint32_t num) +void S_Callback(uint32_t num) { if ((int32_t)num == MUSIC_ID) return; @@ -809,9 +809,11 @@ void S_TestSoundCallback(uint32_t num) { int32_t i = g_sounds[num].SoundOwner[j].i; - // OSD_Printf("removing sound %d index %d from spr %d\n",num,j,i); if (sprite[i].picnum == MUSICANDSFX && sector[sprite[i].sectnum].lotag < 3 && sprite[i].lotag < 999) + { + // OSD_Printf("removing sound %d index %d from spr %d\n",num,j,i); ActorExtra[i].temp_data[0] = 0; + } g_sounds[num].SoundOwner[j].i = -1; g_sounds[num].SoundOwner[j].voice = 0; diff --git a/polymer/eduke32/source/sounds_mapster32.c b/polymer/eduke32/source/sounds_mapster32.c index 42dfaf1a2..ad5ad9d42 100644 --- a/polymer/eduke32/source/sounds_mapster32.c +++ b/polymer/eduke32/source/sounds_mapster32.c @@ -55,7 +55,7 @@ int32_t backflag,g_numEnvSoundsPlaying; void MUSIC_Update(void) {} // needed when linking -void S_TestSoundCallback(uint32_t); +void S_Callback(uint32_t); extern void initprintf(const char *f, ...); /* @@ -91,7 +91,7 @@ int32_t S_SoundStartup(void) { FX_SetVolume(FXVolume); FX_SetReverseStereo(ReverseStereo); - status = FX_SetCallBack(S_TestSoundCallback); + status = FX_SetCallBack(S_Callback); } if (status != FX_Ok) @@ -360,7 +360,7 @@ void S_StopSound(int32_t num) if (g_sounds[num].num > 0) { FX_StopSound(g_sounds[num].SoundOwner[g_sounds[num].num-1].voice); - S_TestSoundCallback(num); + S_Callback(num); } } @@ -444,7 +444,7 @@ void S_Pan3D(void) } } -void S_TestSoundCallback(uint32_t num) +void S_Callback(uint32_t num) { int32_t i,j,k; diff --git a/polymer/eduke32/source/wrapper.c b/polymer/eduke32/source/wrapper.c deleted file mode 100644 index e50076542..000000000 --- a/polymer/eduke32/source/wrapper.c +++ /dev/null @@ -1,75 +0,0 @@ -// this is a wrapper to launch EDuke32 properly from Dukester X 1.5 -// gcc -o duke3d_w32.exe wrapper.c - -#include -#include -#include - -#define ISWS(x) ((x == ' ') || (x == '\t') || (x == '\r') || (x == '\n')) - -int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nCmdShow) -{ - int i=0,j=0; - char CmdLine[1024], sCmdLine[1024], szFileName[255]; - LPTSTR szCmdLine; - - FILE * fp=fopen("wrapper.log","w"); - STARTUPINFO si; - PROCESS_INFORMATION pi; - - UNREFERENCED_PARAMETER(hInstance); - UNREFERENCED_PARAMETER(hPrevInst); - UNREFERENCED_PARAMETER(nCmdShow); - - strcpy(sCmdLine,lpCmdLine); - szFileName[0] = '\0'; - - while (sCmdLine[i] == ' ') i++; - while (i < (signed)strlen(sCmdLine)) - { - if (sCmdLine[i] == '-' && sCmdLine[i+1] == 'n' && sCmdLine[i+2] == 'e' && sCmdLine[i+3] == 't') - { - CmdLine[i-1] = '\0'; - i += 5; - while (sCmdLine[i] != ' ' && i < (signed)strlen(sCmdLine)) - { - szFileName[j] = sCmdLine[i]; - j++,i++; - } - szFileName[j] = '\0'; - break; - } - else CmdLine[i] = sCmdLine[i]; - i++; - CmdLine[i] = '\0'; - } - - if (szFileName[0] != '\0' && CmdLine[0] != '\0') Bsprintf(sCmdLine,"eduke32.exe %s -rmnet %s",CmdLine,szFileName); - else if (CmdLine[0] != '\0') Bsprintf(sCmdLine,"eduke32.exe %s",CmdLine); - else Bsprintf(sCmdLine,"eduke32.exe"); - - szCmdLine = sCmdLine; - - fprintf(fp,"EDuke32 wrapper for Dukester X v0.02\n"); - fprintf(fp,"Copyright (c) 2006 EDuke32 team\n\n"); - fprintf(fp,"Args passed to wrapper: %s\n",lpCmdLine); - fprintf(fp,"Final command line: %s",szCmdLine); - - fclose(fp); - - ZeroMemory(&si,sizeof(si)); - ZeroMemory(&pi,sizeof(pi)); - si.cb = sizeof(si); - - printf("Launching EDuke32...\n\nPlease leave this window open for the entire duration of your game."); - - if (!CreateProcess(NULL,szCmdLine,NULL,NULL,0,0,NULL,NULL,&si,&pi)) - { - MessageBox(0,"Failed to start eduke32.exe.", "Failure starting game", MB_OK|MB_ICONSTOP); - return 1; - } - else WaitForSingleObject(pi.hProcess,INFINITE); - - return 0; -} -