opentnl-cvs Mailing List for Torque Network Library (Page 20)
Brought to you by:
mark_frohnmayer,
s_alanet
You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
(141) |
May
(232) |
Jun
(103) |
Jul
(36) |
Aug
(35) |
Sep
(19) |
Oct
(20) |
Nov
|
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
|
Feb
(26) |
Mar
(2) |
Apr
(84) |
May
(5) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Mark F. <mar...@us...> - 2004-05-13 19:21:58
|
Update of /cvsroot/opentnl/tnl/exe In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21928/exe Modified Files: level3.txt level4.txt Log Message: Made some fixes to Vector class updated barrier code to not break on vector resize updated levels 3 and 4 to remove duplicate barrier makers Index: level3.txt =================================================================== RCS file: /cvsroot/opentnl/tnl/exe/level3.txt,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** level3.txt 4 May 2004 18:24:51 -0000 1.6 --- level3.txt 13 May 2004 19:21:48 -0000 1.7 *************** *** 13,17 **** BarrierMaker 4 4 5 4 5 5 5.5 5 BarrierMaker 8 3 7 3 7 5 - BarrierMaker 4 3.5 5 3.5 5 3 4 3.5 BarrierMaker 4 2.5 4.5 2.5 4.5 2 5 2 BarrierMaker 6 5 5.5 3 6.5 3 6 5 --- 13,16 ---- *************** *** 31,35 **** BarrierMaker 4 12 5 12 5 11 5.5 11 BarrierMaker 8 13 7 13 7 11 - BarrierMaker 4 12.5 5 12.5 5 13 4 12.5 BarrierMaker 4 13.5 4.5 13.5 4.5 14 5 14 BarrierMaker 6 11 5.5 13 6.5 13 6 11 --- 30,33 ---- Index: level4.txt =================================================================== RCS file: /cvsroot/opentnl/tnl/exe/level4.txt,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** level4.txt 4 May 2004 19:46:33 -0000 1.1 --- level4.txt 13 May 2004 19:21:49 -0000 1.2 *************** *** 16,20 **** BarrierMaker 4 4 5 4 5 5 5.5 5 BarrierMaker 8 3 7 3 7 5 - BarrierMaker 4 3.5 5 3.5 5 3 4 3.5 BarrierMaker 4 2.5 4.5 2.5 4.5 2 5 2 BarrierMaker 6 5 5.5 3 6.5 3 6 5 --- 16,19 ---- *************** *** 32,36 **** BarrierMaker 8 12 7 12 7 11 6.5 11 BarrierMaker 4 13 5 13 5 11 - BarrierMaker 8 12.5 7 12.5 7 13 8 12.5 BarrierMaker 8 13.5 7.5 13.5 7.5 14 7 14 BarrierMaker 6 11 6.5 13 5.5 13 6 11 --- 31,34 ---- |
From: Mark F. <mar...@us...> - 2004-05-13 01:46:09
|
Update of /cvsroot/opentnl/tnl/zap In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3940/zap Modified Files: UICredits.h gameConnection.cpp main.cpp masterConnection.cpp sfx.cpp zap.dsp Log Message: Fixed simulated lag parameters in zap Updated VC6 project files Index: gameConnection.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/gameConnection.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** gameConnection.cpp 12 May 2004 19:35:12 -0000 1.12 --- gameConnection.cpp 13 May 2004 01:45:52 -0000 1.13 *************** *** 360,364 **** void GameConnection::onConnectTimedOut() { ! if(this == gClientGame->getConnectionToServer()) gMainMenuUserInterface.activate(); } --- 360,364 ---- void GameConnection::onConnectTimedOut() { ! if(gClientGame && this == gClientGame->getConnectionToServer()) gMainMenuUserInterface.activate(); } Index: main.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/main.cpp,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** main.cpp 12 May 2004 19:35:12 -0000 1.29 --- main.cpp 13 May 2004 01:45:52 -0000 1.30 *************** *** 54,57 **** --- 54,59 ---- U32 gMaxPlayers = 128; U32 gJoystickType = 0; + U32 gSimulatedPing = 0; + F32 gSimulatedPacketLoss = 0; const char *gMasterAddressString = "IP:master.opentnl.org:29005"; *************** *** 327,330 **** --- 329,333 ---- theConnection->setPlayerName(name); + theConnection->setSimulatedNetParams(gSimulatedPacketLoss, gSimulatedPing); if(local) *************** *** 423,426 **** --- 426,439 ---- gJoystickType = atoi(argv[i+1]); } + else if(!stricmp(argv[i], "-loss")) + { + if(hasAdditionalArg) + gSimulatedPacketLoss = atof(argv[i+1]); + } + else if(!stricmp(argv[i], "-lag")) + { + if(hasAdditionalArg) + gSimulatedPing = atoi(argv[i+1]); + } else if(!stricmp(argv[i], "-jsave")) { Index: sfx.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/sfx.cpp,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** sfx.cpp 10 May 2004 22:34:24 -0000 1.19 --- sfx.cpp 13 May 2004 01:45:52 -0000 1.20 *************** *** 40,43 **** --- 40,44 ---- static LPDIRECTSOUNDCAPTUREBUFFER captureBuffer = NULL; static bool recording = false; + static bool captureInit = false; enum { *************** *** 52,61 **** return true; ! if(!capture) { ! DirectSoundCaptureCreate8(NULL, &capture, NULL); ! if(!capture) ! return false; } if(!captureBuffer) --- 53,63 ---- return true; ! if(!captureInit) { ! captureInit = true; ! DirectSoundCaptureCreate8(NULL, &capture, NULL); } + if(!capture) + return false; if(!captureBuffer) *************** *** 77,81 **** --- 79,86 ---- if (FAILED(hr = capture->CreateCaptureBuffer(&dscbd, &captureBuffer, NULL))) + { + captureBuffer = NULL; return false; + } } recording = true; *************** *** 139,142 **** --- 144,149 ---- { recording = false; + if(!captureBuffer) + return; captureBuffer->Stop(); if(captureBuffer) Index: masterConnection.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/masterConnection.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** masterConnection.cpp 24 Apr 2004 23:52:33 -0000 1.6 --- masterConnection.cpp 13 May 2004 01:45:52 -0000 1.7 *************** *** 37,40 **** --- 37,42 ---- { + extern U32 gSimulatedPing; + extern F32 gSimulatedPacketLoss; extern bool gQuit; *************** *** 160,163 **** --- 162,166 ---- name = "Playa"; + conn->setSimulatedNetParams(gSimulatedPacketLoss, gSimulatedPing); conn->setPlayerName(name); gClientGame->setConnectionToServer(conn); Index: UICredits.h =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/UICredits.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** UICredits.h 30 Apr 2004 21:36:05 -0000 1.3 --- UICredits.h 13 May 2004 01:45:51 -0000 1.4 *************** *** 50,58 **** { //typedef CreditsFX Parent; enum Credits { MaxCreditLen = 32, CreditSpace = 200, }; ! struct ProjectInfo { char titleBuf[MaxCreditLen+1]; --- 50,59 ---- { //typedef CreditsFX Parent; + public: enum Credits { MaxCreditLen = 32, CreditSpace = 200, }; ! private: struct ProjectInfo { char titleBuf[MaxCreditLen+1]; Index: zap.dsp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/zap.dsp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** zap.dsp 30 Apr 2004 07:05:23 -0000 1.4 --- zap.dsp 13 May 2004 01:45:52 -0000 1.5 *************** *** 43,47 **** # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c ! # ADD CPP /nologo /W3 /GR /GX /O2 /I "../tnl" /I "../glut" /I "../openal" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" --- 43,47 ---- # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c ! # ADD CPP /nologo /W3 /GR /GX /O2 /I "../tnl" /I "../glut" /I "../openal" /I "c:/dxsdk/include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" *************** *** 51,55 **** LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 ! # ADD LINK32 dinput.lib dinput8.lib dxguid.lib ../openal/alut.lib ../openal/openal32.lib wsock32.lib opengl32.lib glu32.lib ../glut/glut32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"../exe/zap.exe" !ELSEIF "$(CFG)" == "zap - Win32 Debug" --- 51,55 ---- LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 ! # ADD LINK32 dsound.lib dinput.lib dinput8.lib dxguid.lib ../openal/alut.lib ../openal/openal32.lib wsock32.lib opengl32.lib glu32.lib ../glut/glut32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"../exe/zap.exe" /libpath:"c:/dxsdk/lib" !ELSEIF "$(CFG)" == "zap - Win32 Debug" *************** *** 67,71 **** # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c ! # ADD CPP /nologo /W3 /Gm /GR /GX /ZI /Od /I "../tnl" /I "../glut" /I "../openal" /D "TNL_DEBUG" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" --- 67,71 ---- # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c ! # ADD CPP /nologo /W3 /Gm /GR /GX /ZI /Od /I "../tnl" /I "../glut" /I "../openal" /I "c:/dxsdk/include" /D "TNL_DEBUG" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" *************** *** 75,79 **** LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept ! # ADD LINK32 dinput.lib dinput8.lib dxguid.lib ../openal/alut.lib ../openal/openal32.lib wsock32.lib opengl32.lib glu32.lib ../glut/glut32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /out:"../exe/zapd.exe" /pdbtype:sept !ENDIF --- 75,79 ---- LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept ! # ADD LINK32 dsound.lib dinput.lib dinput8.lib dxguid.lib ../openal/alut.lib ../openal/openal32.lib wsock32.lib opengl32.lib glu32.lib ../glut/glut32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /out:"../exe/zapd.exe" /pdbtype:sept /libpath:"c:/dxsdk/lib" !ENDIF *************** *** 161,164 **** --- 161,180 ---- # Begin Source File + SOURCE=.\gsm.h + # End Source File + # Begin Source File + + SOURCE=.\gsm_decode.c + # End Source File + # Begin Source File + + SOURCE=.\gsm_encode.c + # End Source File + # Begin Source File + + SOURCE=.\gsm_state.c + # End Source File + # Begin Source File + SOURCE=.\item.cpp # End Source File *************** *** 169,172 **** --- 185,200 ---- # Begin Source File + SOURCE=.\lpc10.h + # End Source File + # Begin Source File + + SOURCE=.\lpc10dec.c + # End Source File + # Begin Source File + + SOURCE=.\lpc10enc.c + # End Source File + # Begin Source File + SOURCE=.\main.cpp # End Source File *************** *** 261,264 **** --- 289,300 ---- # Begin Source File + SOURCE=.\UICredits.cpp + # End Source File + # Begin Source File + + SOURCE=.\UiCredits.h + # End Source File + # Begin Source File + SOURCE=.\UIGame.cpp # End Source File *************** *** 293,303 **** # Begin Source File ! SOURCE=.\UICredits.cpp ! #End Source File ! #Begin Source File ! SOURCE=.\UiCredits.h ! #End Source File ! #Begin Source File SOURCE=.\winJoystick.cpp --- 329,339 ---- # Begin Source File ! SOURCE=.\voiceCodec.cpp ! # End Source File ! # Begin Source File ! SOURCE=.\voiceCodec.h ! # End Source File ! # Begin Source File SOURCE=.\winJoystick.cpp |
From: Mark F. <mar...@us...> - 2004-05-13 01:46:09
|
Update of /cvsroot/opentnl/tnl/tnl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3940/tnl Modified Files: netConnection.cpp tnl.dsp tnlTypes.h Log Message: Fixed simulated lag parameters in zap Updated VC6 project files Index: tnlTypes.h =================================================================== RCS file: /cvsroot/opentnl/tnl/tnl/tnlTypes.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** tnlTypes.h 10 May 2004 22:34:23 -0000 1.5 --- tnlTypes.h 13 May 2004 01:45:50 -0000 1.6 *************** *** 399,408 **** } ! inline U32 readU32FromBuffer(const U8 *buffer) { ! return (U32(buffer[0]) << 24) | ! (U32(buffer[1]) << 16) | ! (U32(buffer[2]) << 8 ) | ! (U32(buffer[3])); } --- 399,408 ---- } ! inline U32 readU32FromBuffer(const U8 *buf) { ! return (U32(buf[0]) << 24) | ! (U32(buf[1]) << 16) | ! (U32(buf[2]) << 8 ) | ! U32(buf[3]); } *************** *** 416,420 **** { return (U16(buffer[0]) << 8) | ! (U16(buffer[1])); } --- 416,420 ---- { return (U16(buffer[0]) << 8) | ! U16(buffer[1]); } Index: tnl.dsp =================================================================== RCS file: /cvsroot/opentnl/tnl/tnl/tnl.dsp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** tnl.dsp 20 Apr 2004 04:27:18 -0000 1.1 --- tnl.dsp 13 May 2004 01:45:50 -0000 1.2 *************** *** 179,182 **** --- 179,186 ---- # Begin Source File + SOURCE=.\journal.cpp + # End Source File + # Begin Source File + SOURCE=.\log.cpp # End Source File *************** *** 271,274 **** --- 275,290 ---- # Begin Source File + SOURCE=.\tnlJournal.h + # End Source File + # Begin Source File + + SOURCE=.\tnlMethodDispatch.cpp + # End Source File + # Begin Source File + + SOURCE=.\tnlMethodDispatch.h + # End Source File + # Begin Source File + SOURCE=.\types.h # End Source File Index: netConnection.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/tnl/netConnection.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** netConnection.cpp 12 May 2004 01:37:59 -0000 1.3 --- netConnection.cpp 13 May 2004 01:45:50 -0000 1.4 *************** *** 225,228 **** --- 225,234 ---- void NetConnection::readRawPacket(BitStream *bstream) { + if(mSimulatedPacketLoss && Random::readF() < mSimulatedPacketLoss) + { + TNLLogMessageV(LogNetConnection, ("NetConnection %s: RECVDROP - %d", mNetAddress.toString(), getLastSendSequence())); + return; + } + mErrorBuffer[0] = 0; if(readPacketHeader(bstream)) |
From: Mark F. <mar...@us...> - 2004-05-12 22:31:06
|
Update of /cvsroot/opentnl/tnl/zap In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31239/zap Modified Files: UIGame.cpp UINameEntry.cpp gsm_state.c Log Message: Fixed some mac bugs Index: UINameEntry.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/UINameEntry.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** UINameEntry.cpp 11 May 2004 18:26:24 -0000 1.2 --- UINameEntry.cpp 12 May 2004 22:30:54 -0000 1.3 *************** *** 75,79 **** if(key == '\r') onAccept(); ! else if(key == 8) { // backspace key --- 75,79 ---- if(key == '\r') onAccept(); ! else if(key == 8 || key == 127) { // backspace key *************** *** 93,99 **** for(U32 i = MaxNameLen - 1; i > cursorPos; i--) buffer[i] = buffer[i-1]; - buffer[cursorPos] = key; if(cursorPos < MaxNameLen-1) cursorPos++; } } --- 93,101 ---- for(U32 i = MaxNameLen - 1; i > cursorPos; i--) buffer[i] = buffer[i-1]; if(cursorPos < MaxNameLen-1) + { + buffer[cursorPos] = key; cursorPos++; + } } } Index: UIGame.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/UIGame.cpp,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** UIGame.cpp 12 May 2004 21:08:25 -0000 1.24 --- UIGame.cpp 12 May 2004 22:30:54 -0000 1.25 *************** *** 419,423 **** if(key == '\r') issueChat(); ! else if(key == 8) { // backspace key --- 419,423 ---- if(key == '\r') issueChat(); ! else if(key == 8 || key == 127) { // backspace key Index: gsm_state.c =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/gsm_state.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** gsm_state.c 9 May 2004 20:44:07 -0000 1.1 --- gsm_state.c 12 May 2004 22:30:54 -0000 1.2 *************** *** 28,32 **** */ ! #ifndef MACOSX #include <malloc.h> #endif --- 28,32 ---- */ ! #if !defined( MACOSX ) && !defined (__APPLE__) #include <malloc.h> #endif |
From: Mark F. <mar...@us...> - 2004-05-12 22:31:06
|
Update of /cvsroot/opentnl/tnl/tnl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31239/tnl Modified Files: tnlMethodDispatch.cpp Log Message: Fixed some mac bugs Index: tnlMethodDispatch.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/tnl/tnlMethodDispatch.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** tnlMethodDispatch.cpp 12 May 2004 22:13:27 -0000 1.3 --- tnlMethodDispatch.cpp 12 May 2004 22:30:54 -0000 1.4 *************** *** 443,447 **** if(!argList[i].isVector) { ! bstream->read(((S8 *) intArg) + 3); } else --- 443,447 ---- if(!argList[i].isVector) { ! bstream->read(((S8 *) arg) + 3); } else *************** *** 453,457 **** if(!argList[i].isVector) { ! bstream->read(((U8 *) intArg) + 3); } else --- 453,457 ---- if(!argList[i].isVector) { ! bstream->read(((U8 *) arg) + 3); } else *************** *** 463,467 **** if(!argList[i].isVector) { ! bstream->read(((S16 *) intArg) + 1); } else --- 463,467 ---- if(!argList[i].isVector) { ! bstream->read(((S16 *) arg) + 1); } else *************** *** 473,477 **** if(!argList[i].isVector) { ! bstream->read(((U16 *) intArg) + 1); } else --- 473,477 ---- if(!argList[i].isVector) { ! bstream->read(((U16 *) arg) + 1); } else |
From: Mark F. <mar...@us...> - 2004-05-12 22:31:05
|
Update of /cvsroot/opentnl/tnl/osx/tnl.xcode In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31239/osx/tnl.xcode Modified Files: project.pbxproj Log Message: Fixed some mac bugs Index: project.pbxproj =================================================================== RCS file: /cvsroot/opentnl/tnl/osx/tnl.xcode/project.pbxproj,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** project.pbxproj 8 May 2004 00:19:07 -0000 1.6 --- project.pbxproj 12 May 2004 22:30:53 -0000 1.7 *************** *** 98,101 **** --- 98,221 ---- //1D3 //1D4 + 1DC6ED430652D22A00BDEE0B = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.cpp.cpp; + name = journal.cpp; + path = ../tnl/journal.cpp; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + 1DC6ED440652D22A00BDEE0B = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + name = tnlJournal.h; + path = ../tnl/tnlJournal.h; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + 1DC6ED450652D22A00BDEE0B = { + fileRef = 1DC6ED430652D22A00BDEE0B; + isa = PBXBuildFile; + settings = { + }; + }; + 1DC6ED460652D22A00BDEE0B = { + fileRef = 1DC6ED440652D22A00BDEE0B; + isa = PBXBuildFile; + settings = { + }; + }; + 1DC6ED470652D24B00BDEE0B = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + name = gsm_decode.c; + path = ../zap/gsm_decode.c; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + 1DC6ED480652D24B00BDEE0B = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + name = gsm_encode.c; + path = ../zap/gsm_encode.c; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + 1DC6ED490652D24B00BDEE0B = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + name = gsm_state.c; + path = ../zap/gsm_state.c; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + 1DC6ED4A0652D24B00BDEE0B = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + name = gsm.h; + path = ../zap/gsm.h; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + 1DC6ED4B0652D24B00BDEE0B = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.cpp.cpp; + name = voiceCodec.cpp; + path = ../zap/voiceCodec.cpp; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + 1DC6ED4C0652D24B00BDEE0B = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + name = voiceCodec.h; + path = ../zap/voiceCodec.h; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + 1DC6ED4D0652D24B00BDEE0B = { + fileRef = 1DC6ED470652D24B00BDEE0B; + isa = PBXBuildFile; + settings = { + }; + }; + 1DC6ED4E0652D24B00BDEE0B = { + fileRef = 1DC6ED480652D24B00BDEE0B; + isa = PBXBuildFile; + settings = { + }; + }; + 1DC6ED4F0652D24B00BDEE0B = { + fileRef = 1DC6ED490652D24B00BDEE0B; + isa = PBXBuildFile; + settings = { + }; + }; + 1DC6ED500652D24B00BDEE0B = { + fileRef = 1DC6ED4A0652D24B00BDEE0B; + isa = PBXBuildFile; + settings = { + }; + }; + 1DC6ED510652D24B00BDEE0B = { + fileRef = 1DC6ED4B0652D24B00BDEE0B; + isa = PBXBuildFile; + settings = { + }; + }; + 1DC6ED520652D24B00BDEE0B = { + fileRef = 1DC6ED4C0652D24B00BDEE0B; + isa = PBXBuildFile; + settings = { + }; + }; 1DC82046064C5C9000F61B0E = { fileEncoding = 30; *************** *** 544,547 **** --- 664,669 ---- 6649E0EE05FD022100B3DD8B = { children = ( + 1DC6ED430652D22A00BDEE0B, + 1DC6ED440652D22A00BDEE0B, 1DC82046064C5C9000F61B0E, 1DC82047064C5C9000F61B0E, *************** *** 1842,1845 **** --- 1964,1969 ---- DBAFF4AA06471AAE00683BA4, 1DC8204D064C5CBC00F61B0E, + 1DC6ED500652D24B00BDEE0B, + 1DC6ED520652D24B00BDEE0B, ); isa = PBXHeadersBuildPhase; *************** *** 1880,1883 **** --- 2004,2011 ---- 1DC8204E064C5CBC00F61B0E, 1DC8204F064C5CBC00F61B0E, + 1DC6ED4D0652D24B00BDEE0B, + 1DC6ED4E0652D24B00BDEE0B, + 1DC6ED4F0652D24B00BDEE0B, + 1DC6ED510652D24B00BDEE0B, ); isa = PBXSourcesBuildPhase; *************** *** 2314,2317 **** --- 2442,2451 ---- 6692C0E606247C3B00D5ADFE = { children = ( + 1DC6ED470652D24B00BDEE0B, + 1DC6ED480652D24B00BDEE0B, + 1DC6ED490652D24B00BDEE0B, + 1DC6ED4A0652D24B00BDEE0B, + 1DC6ED4B0652D24B00BDEE0B, + 1DC6ED4C0652D24B00BDEE0B, 1DC8204A064C5CBC00F61B0E, 1DC8204B064C5CBC00F61B0E, *************** *** 3519,3522 **** --- 3653,3657 ---- 66BA0C8105FD107700D882FA, 1DC82049064C5C9000F61B0E, + 1DC6ED460652D22A00BDEE0B, ); isa = PBXHeadersBuildPhase; *************** *** 3550,3553 **** --- 3685,3689 ---- DB9525E4063610C200B8795E, 1DC82048064C5C9000F61B0E, + 1DC6ED450652D22A00BDEE0B, ); isa = PBXSourcesBuildPhase; |
From: Mark F. <mar...@us...> - 2004-05-12 22:13:45
|
Update of /cvsroot/opentnl/tnl/tnl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27611/tnl Modified Files: tnlMethodDispatch.cpp Log Message: Fixed (hopefully) issue on big endian hardware with RPCs of < 32 bit types Index: tnlMethodDispatch.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/tnl/tnlMethodDispatch.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** tnlMethodDispatch.cpp 8 May 2004 00:19:08 -0000 1.2 --- tnlMethodDispatch.cpp 12 May 2004 22:13:27 -0000 1.3 *************** *** 247,259 **** --- 247,287 ---- { case TypeS8: + #ifdef TNL_BIG_ENDIAN + if(!argList[i].isVector) + { + bstream.write(((S8 *) intArg)[3]); + } + else + #endif bstream.write(*((S8 *) intArg)); break; case TypeU8: + #ifdef TNL_BIG_ENDIAN + if(!argList[i].isVector) + { + bstream.write(((U8 *) intArg)[3]); + } + else + #endif bstream.write(*((U8 *) intArg)); break; case TypeS16: + #ifdef TNL_BIG_ENDIAN + if(!argList[i].isVector) + { + bstream.write(((S16 *) intArg)[1]); + } + else + #endif bstream.write(*((S16 *) intArg)); break; case TypeU16: + #ifdef TNL_BIG_ENDIAN + if(!argList[i].isVector) + { + bstream.write(((U16 *) intArg)[1]); + } + else + #endif bstream.write(*((U16 *) intArg)); break; *************** *** 412,424 **** --- 440,480 ---- { case TypeS8: + #ifdef TNL_BIG_ENDIAN + if(!argList[i].isVector) + { + bstream->read(((S8 *) intArg) + 3); + } + else + #endif bstream->read((S8 *) arg); break; case TypeU8: + #ifdef TNL_BIG_ENDIAN + if(!argList[i].isVector) + { + bstream->read(((U8 *) intArg) + 3); + } + else + #endif bstream->read((U8 *) arg); break; case TypeS16: + #ifdef TNL_BIG_ENDIAN + if(!argList[i].isVector) + { + bstream->read(((S16 *) intArg) + 1); + } + else + #endif bstream->read((S16 *) arg); break; case TypeU16: + #ifdef TNL_BIG_ENDIAN + if(!argList[i].isVector) + { + bstream->read(((U16 *) intArg) + 1); + } + else + #endif bstream->read((S16 *) arg); break; |
From: Mark F. <mar...@us...> - 2004-05-12 21:16:21
|
Update of /cvsroot/opentnl/tnl/zap In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14538/zap Modified Files: Makefile Log Message: Modified files for Linux compile ---------------------------------------------------------------------- Index: Makefile =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/Makefile,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Makefile 8 May 2004 00:26:31 -0000 1.6 --- Makefile 12 May 2004 21:16:11 -0000 1.7 *************** *** 36,41 **** --- 36,45 ---- teleporter.o\ barrier.o\ + voiceCodec.o\ lpc10dec.o\ lpc10enc.o\ + gsm_decode.o\ + gsm_encode.o\ + gsm_state.o\ main.o *************** *** 50,54 **** default: $(OBJECTS_ZAP) ! $(CC) -o zap $(OBJECTS_ZAP) ../tnl/libtnl.a ../libtomcrypt/libtomcrypt.a ../openal/linux/libopenal.a -lpthread -lstdc++ -lGL -lGLU -lglut -lm ../master/masterInterface.o: --- 54,58 ---- default: $(OBJECTS_ZAP) ! $(CC) -o ../exe/zap $(OBJECTS_ZAP) ../tnl/libtnl.a ../libtomcrypt/libtomcrypt.a ../openal/linux/libopenal.a -lpthread -lstdc++ -lGL -lGLU -lglut -lm ../master/masterInterface.o: *************** *** 56,59 **** clean: ! rm -f $(OBJECTS_ZAP) zap --- 60,63 ---- clean: ! rm -f $(OBJECTS_ZAP) ../exe/zap |
From: Mark F. <mar...@us...> - 2004-05-12 21:16:21
|
Update of /cvsroot/opentnl/tnl/tnl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14538/tnl Modified Files: Makefile Log Message: Modified files for Linux compile ---------------------------------------------------------------------- Index: Makefile =================================================================== RCS file: /cvsroot/opentnl/tnl/tnl/Makefile,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Makefile 8 May 2004 00:26:31 -0000 1.4 --- Makefile 12 May 2004 21:16:11 -0000 1.5 *************** *** 32,36 **** rpc.o\ symmetricCipher.o\ ! tnlMessageDispatch.o\ udp.o\ vector.o\ --- 32,37 ---- rpc.o\ symmetricCipher.o\ ! tnlMethodDispatch.o\ ! journal.o\ udp.o\ vector.o\ |
From: Ben G. <s_a...@us...> - 2004-05-12 21:08:42
|
Update of /cvsroot/opentnl/tnl/zap In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12876/zap Modified Files: UIGame.cpp ship.cpp ship.h winJoystick.cpp Log Message: Fixed trail emission issues. Relative mouse control turns off mouse locking. Index: ship.h =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/ship.h,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** ship.h 11 May 2004 18:26:25 -0000 1.16 --- ship.h 12 May 2004 21:08:25 -0000 1.17 *************** *** 78,81 **** --- 78,82 ---- SFXHandle mTurboNoise; + U32 mSparkElapsed; S32 mLastTrailPoint[TrailCount]; fxTrail mTrail[TrailCount]; *************** *** 97,101 **** void burnEnergy(U32 dT); ! void emitMovementSparks(); void emitShipExplosion(Point pos); --- 98,102 ---- void burnEnergy(U32 dT); ! void emitMovementSparks(U32 deltaT); void emitShipExplosion(Point pos); Index: UIGame.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/UIGame.cpp,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** UIGame.cpp 9 May 2004 20:41:05 -0000 1.23 --- UIGame.cpp 12 May 2004 21:08:25 -0000 1.24 *************** *** 136,146 **** #ifdef TNL_OS_WIN32 ! F32 len = mMousePoint.len(); ! checkMousePos(windowWidth * 100 / canvasWidth, ! windowHeight * 100 / canvasHeight); ! ! if(len > 100) ! realMousePoint *= 100 / len; #endif --- 136,148 ---- #ifdef TNL_OS_WIN32 + if(!OptionsMenuUserInterface::controlsRelative) + { + F32 len = mMousePoint.len(); + checkMousePos(windowWidth * 100 / canvasWidth, + windowHeight * 100 / canvasHeight); ! if(len > 100) ! realMousePoint *= 100 / len; ! } #endif Index: winJoystick.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/winJoystick.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** winJoystick.cpp 12 May 2004 01:56:42 -0000 1.9 --- winJoystick.cpp 12 May 2004 21:08:25 -0000 1.10 *************** *** 33,36 **** --- 33,37 ---- #include "point.h" #include "UI.h" + #include "UIMenus.h" #include "tnlJournal.h" *************** *** 43,46 **** --- 44,50 ---- void checkMousePos(S32 maxdx, S32 maxdy) { + if(OptionsMenuUserInterface::controlsRelative) + return; + char windowName[256]; Index: ship.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/ship.cpp,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** ship.cpp 12 May 2004 19:35:12 -0000 1.27 --- ship.cpp 12 May 2004 21:08:25 -0000 1.28 *************** *** 254,263 **** return; - //mMoveState[RenderState] = mMoveState[ActualState]; updateInterpolation(theMove->time); lastMove = *theMove; // Emit some particles ! emitMovementSparks(); for(U32 i=0; i<TrailCount; i++) --- 254,262 ---- return; updateInterpolation(theMove->time); lastMove = *theMove; // Emit some particles ! emitMovementSparks(theMove->time); for(U32 i=0; i<TrailCount; i++) *************** *** 276,280 **** updateInterpolation(deltaT); // Emit some particles ! emitMovementSparks(); for(U32 i=0; i<TrailCount; i++) --- 275,279 ---- updateInterpolation(deltaT); // Emit some particles ! emitMovementSparks(deltaT); for(U32 i=0; i<TrailCount; i++) *************** *** 642,651 **** } ! void Ship::emitMovementSparks() { ! // Do nothing if we're under 0.001 vel if(hasExploded || mMoveState[ActualState].vel.len() < 0.1) return; Point corners[3]; Point shipDirs[3]; --- 641,655 ---- } ! void Ship::emitMovementSparks(U32 deltaT) { ! // Do nothing if we're under 0.1 vel if(hasExploded || mMoveState[ActualState].vel.len() < 0.1) return; + mSparkElapsed += deltaT; + + if(mSparkElapsed <= 32) + return; + Point corners[3]; Point shipDirs[3]; *************** *** 751,755 **** { // shoot some sparks... ! if(th >= 1*TNL::Random::readF() * velDir.len()) { Point chaos(TNL::Random::readF(),TNL::Random::readF()); --- 755,759 ---- { // shoot some sparks... ! if(th >= 0.2*velDir.len()) { Point chaos(TNL::Random::readF(),TNL::Random::readF()); *************** *** 758,762 **** //interp give us some nice enginey colors... Color dim(1, 0, 0); ! Color light(1, 1, 0); Color thrust; --- 762,766 ---- //interp give us some nice enginey colors... Color dim(1, 0, 0); ! Color light(1, 1, mTurbo ? 1.f : 0.f); Color thrust; |
From: Mark F. <mar...@us...> - 2004-05-12 20:45:27
|
Update of /cvsroot/opentnl/tnl/zap In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7095/zap Modified Files: game.h gameConnection.h Log Message: Updated game version to RC5 Added more pending moves Index: gameConnection.h =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/gameConnection.h,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** gameConnection.h 12 May 2004 19:35:12 -0000 1.10 --- gameConnection.h 12 May 2004 20:45:17 -0000 1.11 *************** *** 162,166 **** // move management enum { ! MaxPendingMoves = 31, }; Vector<Move> pendingMoves; --- 162,166 ---- // move management enum { ! MaxPendingMoves = 63, }; Vector<Move> pendingMoves; Index: game.h =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/game.h,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** game.h 12 May 2004 19:36:35 -0000 1.19 --- game.h 12 May 2004 20:45:16 -0000 1.20 *************** *** 212,216 **** extern void endGame(); ! #define ZAP_GAME_STRING "ZAP 1.2.0 rc 4" }; --- 212,216 ---- extern void endGame(); ! #define ZAP_GAME_STRING "ZAP 1.2.0 rc 5" }; |
From: Mark F. <mar...@us...> - 2004-05-12 19:36:44
|
Update of /cvsroot/opentnl/tnl/zap In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22917/zap Modified Files: game.h Log Message: Updated game version string to rc4 Index: game.h =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/game.h,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** game.h 12 May 2004 02:28:06 -0000 1.18 --- game.h 12 May 2004 19:36:35 -0000 1.19 *************** *** 212,216 **** extern void endGame(); ! #define ZAP_GAME_STRING "ZAP 1.2.0 rc 3" }; --- 212,216 ---- extern void endGame(); ! #define ZAP_GAME_STRING "ZAP 1.2.0 rc 4" }; |
Update of /cvsroot/opentnl/tnl/zap In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22462/zap Modified Files: ZAP.vcproj gameConnection.cpp gameConnection.h gameObject.cpp gameObject.h item.cpp main.cpp projectile.cpp projectile.h ship.cpp Log Message: Fixed bug in connection string table causing strings to never be sent in compressed form Added bandwidth usage logging per net class Substantially reduced object update size in Zap Index: main.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/main.cpp,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** main.cpp 12 May 2004 01:38:00 -0000 1.28 --- main.cpp 12 May 2004 19:35:12 -0000 1.29 *************** *** 351,354 **** --- 351,355 ---- endGame(); SFXObject::shutdown(); + NetClassRep::logBitUsage(); } *************** *** 500,504 **** glTranslatef(400, 300, 0); ! atexit(endGame); glutMainLoop(); --- 501,505 ---- glTranslatef(400, 300, 0); ! atexit(onExit); glutMainLoop(); Index: projectile.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/projectile.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** projectile.cpp 5 May 2004 09:50:35 -0000 1.9 --- projectile.cpp 12 May 2004 19:35:12 -0000 1.10 *************** *** 51,58 **** U32 Projectile::packUpdate(GhostConnection *connection, U32 updateMask, BitStream *stream) { ! stream->write(pos.x); ! stream->write(pos.y); ! stream->write(velocity.x); ! stream->write(velocity.y); S32 index = -1; if(mShooter.isValid()) --- 51,57 ---- U32 Projectile::packUpdate(GhostConnection *connection, U32 updateMask, BitStream *stream) { ! ((GameConnection *) connection)->writeCompressedPoint(pos, stream); ! writeCompressedVelocity(velocity, CompressedVelocityMax, stream); ! S32 index = -1; if(mShooter.isValid()) *************** *** 66,73 **** void Projectile::unpackUpdate(GhostConnection *connection, BitStream *stream) { ! stream->read(&pos.x); ! stream->read(&pos.y); ! stream->read(&velocity.x); ! stream->read(&velocity.y); if(stream->readFlag()) --- 65,70 ---- void Projectile::unpackUpdate(GhostConnection *connection, BitStream *stream) { ! ((GameConnection *) connection)->readCompressedPoint(pos, stream); ! readCompressedVelocity(velocity, CompressedVelocityMax, stream); if(stream->readFlag()) Index: gameConnection.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/gameConnection.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** gameConnection.cpp 11 May 2004 18:26:25 -0000 1.11 --- gameConnection.cpp 12 May 2004 19:35:12 -0000 1.12 *************** *** 78,81 **** --- 78,82 ---- for(; firstMoveIndex < ((GamePacketNotify *) notify)->firstUnsentMoveIndex; firstMoveIndex++) pendingMoves.erase(U32(0)); + mServerPosition = ((GamePacketNotify *) notify)->lastControlObjectPosition; Parent::packetReceived(notify); } *************** *** 127,130 **** --- 128,134 ---- } ((GamePacketNotify *) notify)->firstUnsentMoveIndex = firstMoveIndex + pendingMoves.size(); + if(controlObject.isValid()) + ((GamePacketNotify *) notify)->lastControlObjectPosition = controlObject->getActualPos(); + highSendIndex[0] = highSendIndex[1]; highSendIndex[1] = highSendIndex[2]; *************** *** 133,142 **** else { if(bstream->writeFlag(getControlCRC() != mLastClientControlCRC)) { ! S32 ghostIndex = -1; ! if(controlObject.isValid()) ! ghostIndex = getGhostIndex(controlObject); ! if(bstream->writeFlag(ghostIndex != -1)) { bstream->writeInt(ghostIndex, GhostConnection::GhostIdBitSize); --- 137,154 ---- else { + S32 ghostIndex = -1; + if(controlObject.isValid()) + { + ghostIndex = getGhostIndex(controlObject); + mServerPosition = controlObject->getActualPos(); + } + + // we only compress points relative if we know that the + // remote side has a copy of the control object already + mCompressPointsRelative = bstream->writeFlag(ghostIndex != -1); + if(bstream->writeFlag(getControlCRC() != mLastClientControlCRC)) { ! if(ghostIndex != -1) { bstream->writeInt(ghostIndex, GhostConnection::GhostIdBitSize); *************** *** 176,190 **** else { if(bstream->readFlag()) { ! if(bstream->readFlag()) { U32 ghostIndex = bstream->readInt(GhostConnection::GhostIdBitSize); controlObject = (GameObject *) resolveGhost(ghostIndex); controlObject->readControlState(bstream); for(S32 i = 0; i < pendingMoves.size(); i++) - { controlObject->processClientMove(&pendingMoves[i], true); - } } else --- 188,207 ---- else { + bool controlObjectValid = bstream->readFlag(); + + mCompressPointsRelative = controlObjectValid; + + // CRC mismatch... if(bstream->readFlag()) { ! if(controlObjectValid) { U32 ghostIndex = bstream->readInt(GhostConnection::GhostIdBitSize); controlObject = (GameObject *) resolveGhost(ghostIndex); controlObject->readControlState(bstream); + mServerPosition = controlObject->getActualPos(); + for(S32 i = 0; i < pendingMoves.size(); i++) controlObject->processClientMove(&pendingMoves[i], true); } else *************** *** 195,198 **** --- 212,269 ---- } + void GameConnection::writeCompressedPoint(Point &p, BitStream *stream) + { + if(!mCompressPointsRelative) + { + stream->write(p.x); + stream->write(p.y); + return; + } + + Point delta = p - mServerPosition; + S32 dx = S32(delta.x + Game::PlayerHorizScopeDistance); + S32 dy = S32(delta.y + Game::PlayerVertScopeDistance); + + U32 maxx = Game::PlayerHorizScopeDistance * 2; + U32 maxy = Game::PlayerVertScopeDistance * 2; + + if(stream->writeFlag(dx >= 0 && dx <= maxx && dy >= 0 && dy <= maxy)) + { + stream->writeRangedU32(dx, 0, maxx); + stream->writeRangedU32(dy, 0, maxy); + } + else + { + stream->write(p.x); + stream->write(p.y); + } + } + + void GameConnection::readCompressedPoint(Point &p, BitStream *stream) + { + if(!mCompressPointsRelative) + { + stream->read(&p.x); + stream->read(&p.y); + return; + } + if(stream->readFlag()) + { + U32 maxx = Game::PlayerHorizScopeDistance * 2; + U32 maxy = Game::PlayerVertScopeDistance * 2; + + S32 dx = S32(stream->readRangedU32(0, maxx)) - Game::PlayerHorizScopeDistance; + S32 dy = S32(stream->readRangedU32(0, maxy)) - Game::PlayerVertScopeDistance; + + Point delta(dx, dy); + p = mServerPosition + delta; + } + else + { + stream->read(&p.x); + stream->read(&p.y); + } + } + void GameConnection::writeConnectRequest(BitStream *stream) { Index: gameObject.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/gameObject.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** gameObject.cpp 23 Apr 2004 01:49:46 -0000 1.2 --- gameObject.cpp 12 May 2004 19:35:12 -0000 1.3 *************** *** 209,212 **** --- 209,251 ---- } + void GameObject::writeCompressedVelocity(Point &vel, U32 max, BitStream *stream) + { + F32 len = vel.len(); + if(stream->writeFlag(len == 0)) + return; + + if(stream->writeFlag(len > max)) + { + stream->write(vel.x); + stream->write(vel.y); + } + else + { + F32 theta = atan2(vel.x, vel.y); + stream->writeFloat(theta * FloatInverse2Pi, 10); + stream->writeRangedU32(len, 0, max); + } + } + + void GameObject::readCompressedVelocity(Point &vel, U32 max, BitStream *stream) + { + if(stream->readFlag()) + { + vel.x = vel.y = 0; + return; + } + else if(stream->readFlag()) + { + stream->read(&vel.x); + stream->read(&vel.y); + } + else + { + F32 theta = stream->readFloat(10) * Float2Pi; + F32 magnitude = stream->readRangedU32(0, max); + vel.set(sin(theta) * magnitude, cos(theta) * magnitude); + } + } + void GameObject::processArguments(S32 argc, const char**argv) { Index: ZAP.vcproj =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/ZAP.vcproj,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** ZAP.vcproj 12 May 2004 01:38:00 -0000 1.16 --- ZAP.vcproj 12 May 2004 19:35:11 -0000 1.17 *************** *** 88,92 **** LinkIncremental="1" GenerateDebugInformation="TRUE" ! SubSystem="2" OptimizeReferences="2" EnableCOMDATFolding="2" --- 88,92 ---- LinkIncremental="1" GenerateDebugInformation="TRUE" ! SubSystem="1" OptimizeReferences="2" EnableCOMDATFolding="2" Index: projectile.h =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/projectile.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** projectile.h 23 Apr 2004 01:49:46 -0000 1.3 --- projectile.h 12 May 2004 19:35:12 -0000 1.4 *************** *** 38,41 **** --- 38,45 ---- { public: + enum { + CompressedVelocityMax = 2047, + }; + Point pos; Point velocity; Index: gameConnection.h =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/gameConnection.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** gameConnection.h 12 May 2004 02:54:46 -0000 1.9 --- gameConnection.h 12 May 2004 19:35:12 -0000 1.10 *************** *** 31,34 **** --- 31,36 ---- #include "../tnl/tnlGhostConnection.h" + #include "point.h" + using namespace TNL; // some angle conversion functions: *************** *** 169,172 **** --- 171,176 ---- StringTableEntry playerName; U32 mLastClientControlCRC; + Point mServerPosition; + bool mCompressPointsRelative; U32 firstMoveIndex; *************** *** 198,201 **** --- 202,206 ---- { U32 firstUnsentMoveIndex; + Point lastControlObjectPosition; GamePacketNotify() { firstUnsentMoveIndex = 0; } }; *************** *** 219,222 **** --- 224,230 ---- void onConnectionTerminated(const char *reason); + void writeCompressedPoint(Point &p, BitStream *stream); + void readCompressedPoint(Point &p, BitStream *stream); + void onConnectTimedOut(); Index: gameObject.h =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/gameObject.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** gameObject.h 3 May 2004 22:06:16 -0000 1.5 --- gameObject.h 12 May 2004 19:35:12 -0000 1.6 *************** *** 112,115 **** --- 112,118 ---- virtual void readControlState(BitStream *stream); + void writeCompressedVelocity(Point &vel, U32 max, BitStream *stream); + void readCompressedVelocity(Point &vel, U32 max, BitStream *stream); + virtual Point getRenderPos(); virtual Point getActualPos(); Index: item.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/item.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** item.cpp 30 Apr 2004 20:27:41 -0000 1.6 --- item.cpp 12 May 2004 19:35:12 -0000 1.7 *************** *** 168,175 **** if(stream->writeFlag(updateMask & PositionMask)) { ! stream->write(mMoveState[RenderState].pos.x); ! stream->write(mMoveState[RenderState].pos.y); ! stream->write(mMoveState[RenderState].vel.x); ! stream->write(mMoveState[RenderState].vel.y); stream->writeFlag(updateMask & WarpPositionMask); } --- 168,173 ---- if(stream->writeFlag(updateMask & PositionMask)) { ! ((GameConnection *) connection)->writeCompressedPoint(mMoveState[RenderState].pos, stream); ! writeCompressedVelocity(mMoveState[RenderState].vel, 511, stream); stream->writeFlag(updateMask & WarpPositionMask); } *************** *** 196,203 **** if(stream->readFlag()) { ! stream->read(&mMoveState[ActualState].pos.x); ! stream->read(&mMoveState[ActualState].pos.y); ! stream->read(&mMoveState[ActualState].vel.x); ! stream->read(&mMoveState[ActualState].vel.y); //posSegments.push_back(mMoveState[ActualState].pos); positionChanged = true; --- 194,199 ---- if(stream->readFlag()) { ! ((GameConnection *) connection)->readCompressedPoint(mMoveState[ActualState].pos, stream); ! readCompressedVelocity(mMoveState[ActualState].vel, 511, stream); //posSegments.push_back(mMoveState[ActualState].pos); positionChanged = true; Index: ship.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/ship.cpp,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** ship.cpp 11 May 2004 18:26:25 -0000 1.26 --- ship.cpp 12 May 2004 19:35:12 -0000 1.27 *************** *** 409,412 **** --- 409,414 ---- U32 Ship::packUpdate(GhostConnection *connection, U32 updateMask, BitStream *stream) { + GameConnection *gameConnection = (GameConnection *) connection; + if(stream->writeFlag(updateMask & InitialMask)) { *************** *** 441,445 **** bool shouldWritePosition = (updateMask & InitialMask) || ! ((GameConnection *)connection)->controlObject != (GameObject *) this; if(!shouldWritePosition) --- 443,447 ---- bool shouldWritePosition = (updateMask & InitialMask) || ! gameConnection->controlObject != (GameObject *) this; if(!shouldWritePosition) *************** *** 452,460 **** if(stream->writeFlag(updateMask & PositionMask)) { ! stream->write(mMoveState[RenderState].pos.x); ! stream->write(mMoveState[RenderState].pos.y); ! stream->write(mMoveState[RenderState].vel.x); ! stream->write(mMoveState[RenderState].vel.y); ! stream->writeFlag(updateMask & WarpPositionMask); } --- 454,459 ---- if(stream->writeFlag(updateMask & PositionMask)) { ! gameConnection->writeCompressedPoint(mMoveState[RenderState].pos, stream); ! writeCompressedVelocity(mMoveState[RenderState].vel, TurboMaxVelocity + 1, stream); stream->writeFlag(updateMask & WarpPositionMask); } *************** *** 506,514 **** if(stream->readFlag()) { ! stream->read(&mMoveState[ActualState].pos.x); ! stream->read(&mMoveState[ActualState].pos.y); ! stream->read(&mMoveState[ActualState].vel.x); ! stream->read(&mMoveState[ActualState].vel.y); ! //posSegments.push_back(mMoveState[ActualState].pos); positionChanged = true; interpolate = !stream->readFlag(); --- 505,510 ---- if(stream->readFlag()) { ! ((GameConnection *) connection)->readCompressedPoint(mMoveState[ActualState].pos, stream); ! readCompressedVelocity(mMoveState[ActualState].vel, TurboMaxVelocity + 1, stream); positionChanged = true; interpolate = !stream->readFlag(); |
From: Mark F. <mar...@us...> - 2004-05-12 19:35:25
|
Update of /cvsroot/opentnl/tnl/tnl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22462/tnl Modified Files: connectionStringTable.cpp eventConnection.cpp ghostConnection.cpp netBase.cpp tnlNetBase.h Log Message: Fixed bug in connection string table causing strings to never be sent in compressed form Added bandwidth usage logging per net class Substantially reduced object update size in Zap Index: tnlNetBase.h =================================================================== RCS file: /cvsroot/opentnl/tnl/tnl/tnlNetBase.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** tnlNetBase.h 20 Apr 2004 04:27:18 -0000 1.1 --- tnlNetBase.h 12 May 2004 19:35:11 -0000 1.2 *************** *** 197,200 **** --- 197,205 ---- char *mClassName; ///< The unmangled name of the class. + U32 mInitialUpdateBitsUsed; ///< Number of bits used on initial updates of objects of this class. + U32 mPartialUpdateBitsUsed; ///< Number of bits used on partial updates of objects of this class. + U32 mInitialUpdateCount; ///< Number of objects of this class constructed over a connection. + U32 mPartialUpdateCount; ///< Number of objects of this class updated over a connection. + /// Next declared NetClassRep. /// *************** *** 231,234 **** --- 236,253 ---- const char *getClassName() const; ///< Returns the string class name. + /// Records bits used in the initial update of objects of this class. + void addInitialUpdate(U32 bitCount) + { + mInitialUpdateCount++; + mInitialUpdateBitsUsed += bitCount; + } + + /// Records bits used in a partial update of an object of this class. + void addPartialUpdate(U32 bitCount) + { + mPartialUpdateCount++; + mPartialUpdateBitsUsed += bitCount; + } + virtual Object *create() const = 0; ///< Creates an instance of the class this represents. *************** *** 252,255 **** --- 271,276 ---- static void initialize(); + /// Logs the bit usage information of all the NetClassReps + static void logBitUsage(); }; Index: connectionStringTable.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/tnl/connectionStringTable.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** connectionStringTable.cpp 20 Apr 2004 04:27:18 -0000 1.1 --- connectionStringTable.cpp 12 May 2004 19:35:11 -0000 1.2 *************** *** 100,104 **** entry->stringTableEntry = sendEntry; ! entry->string = entry->string; entry->nextInPacket = NULL; --- 100,104 ---- entry->stringTableEntry = sendEntry; ! entry->string = sendEntry->string; entry->nextInPacket = NULL; Index: eventConnection.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/tnl/eventConnection.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** eventConnection.cpp 20 Apr 2004 04:27:18 -0000 1.1 --- eventConnection.cpp 12 May 2004 19:35:11 -0000 1.2 *************** *** 304,318 **** prevSeq = ev->mSeqCount; - S32 start = bstream->getBitPosition(); if(mConnectionParameters.mDebugObjectSizes) bstream->advanceBitPosition(BitStreamPosBitSize); S32 classId = ev->mEvent->getClassId(getNetClassGroup()); bstream->writeInt(classId, mEventClassBitSize); ev->mEvent->pack(this, bstream); TNLLogMessageV(LogEventConnection, ("EventConnection %s: WroteEvent %s - %d bits", getNetAddressString(), ev->mEvent->getDebugName(), bstream->getBitPosition() - start)); if(mConnectionParameters.mDebugObjectSizes) ! bstream->writeIntAt(bstream->getBitPosition(), BitStreamPosBitSize, start); } for(EventNote *ev = packQueueHead; ev; ev = ev->mNextEvent) --- 304,321 ---- prevSeq = ev->mSeqCount; if(mConnectionParameters.mDebugObjectSizes) bstream->advanceBitPosition(BitStreamPosBitSize); + S32 start = bstream->getBitPosition(); + S32 classId = ev->mEvent->getClassId(getNetClassGroup()); bstream->writeInt(classId, mEventClassBitSize); ev->mEvent->pack(this, bstream); + + ev->mEvent->getClassRep()->addInitialUpdate(bstream->getBitPosition() - start); TNLLogMessageV(LogEventConnection, ("EventConnection %s: WroteEvent %s - %d bits", getNetAddressString(), ev->mEvent->getDebugName(), bstream->getBitPosition() - start)); if(mConnectionParameters.mDebugObjectSizes) ! bstream->writeIntAt(bstream->getBitPosition(), BitStreamPosBitSize, start - BitStreamPosBitSize); } for(EventNote *ev = packQueueHead; ev; ev = ev->mNextEvent) Index: netBase.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/tnl/netBase.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** netBase.cpp 20 Apr 2004 04:27:18 -0000 1.1 --- netBase.cpp 12 May 2004 19:35:11 -0000 1.2 *************** *** 28,31 **** --- 28,32 ---- #include "tnlNetBase.h" #include "tnlVector.h" + #include "tnlLog.h" namespace TNL *************** *** 44,48 **** NetClassRep::NetClassRep() { ! } --- 45,52 ---- NetClassRep::NetClassRep() { ! mInitialUpdateCount = 0; ! mInitialUpdateBitsUsed = 0; ! mPartialUpdateCount = 0; ! mPartialUpdateBitsUsed = 0; } *************** *** 120,126 **** --- 124,142 ---- } mInitialized = true; + } + void NetClassRep::logBitUsage() + { + logprintf("Net Class Bit Usage:"); + for(NetClassRep *walk = mClassLinkList; walk; walk = walk->mNextClass) + { + if(walk->mInitialUpdateCount) + logprintf("%s (Initial) - Count: %d Avg Size: %g", walk->mClassName, walk->mInitialUpdateCount, walk->mInitialUpdateBitsUsed / F32(walk->mInitialUpdateCount)); + if(walk->mPartialUpdateCount) + logprintf("%s (Partial) - Count: %d Avg Size: %g", walk->mClassName, walk->mPartialUpdateCount, walk->mPartialUpdateBitsUsed / F32(walk->mPartialUpdateCount)); + } } + Object::Object() { Index: ghostConnection.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/tnl/ghostConnection.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ghostConnection.cpp 6 May 2004 00:33:38 -0000 1.5 --- ghostConnection.cpp 12 May 2004 19:35:11 -0000 1.6 *************** *** 407,411 **** continue; - //S32 startPos = bstream->getCurPos(); bstream->writeFlag(true); --- 407,410 ---- *************** *** 439,447 **** { bstream->writeFlag(false); ! S32 startPos = bstream->getBitPosition(); if(mConnectionParameters.mDebugObjectSizes) bstream->advanceBitPosition(BitStreamPosBitSize); if(walk->flags & GhostInfo::NotYetGhosted) { --- 438,448 ---- { bstream->writeFlag(false); ! bool isInitialUpdate = false; if(mConnectionParameters.mDebugObjectSizes) bstream->advanceBitPosition(BitStreamPosBitSize); + S32 startPos = bstream->getBitPosition(); + if(walk->flags & GhostInfo::NotYetGhosted) { *************** *** 452,455 **** --- 453,457 ---- walk->flags |= GhostInfo::Ghosting; upd->ghostInfoFlags = GhostInfo::Ghosting; + isInitialUpdate = true; } *************** *** 457,462 **** U32 retMask = walk->obj->packUpdate(this, updateMask, bstream); if(mConnectionParameters.mDebugObjectSizes) ! bstream->writeIntAt(bstream->getBitPosition(), BitStreamPosBitSize, startPos); TNLLogMessageV(LogGhostConnection, ("GhostConnection %s GHOST %d", walk->obj->getClassName(), bstream->getBitPosition() - 16 - startPos)); --- 459,469 ---- U32 retMask = walk->obj->packUpdate(this, updateMask, bstream); + if(isInitialUpdate) + walk->obj->getClassRep()->addInitialUpdate(bstream->getBitPosition() - startPos); + else + walk->obj->getClassRep()->addPartialUpdate(bstream->getBitPosition() - startPos); + if(mConnectionParameters.mDebugObjectSizes) ! bstream->writeIntAt(bstream->getBitPosition(), BitStreamPosBitSize, startPos - BitStreamPosBitSize); TNLLogMessageV(LogGhostConnection, ("GhostConnection %s GHOST %d", walk->obj->getClassName(), bstream->getBitPosition() - 16 - startPos)); *************** *** 469,474 **** upd->mask = updateMask & ~retMask; - - //PacketStream::getStats()->addBits(PacketStats::Send, bstream->getCurPos() - startPos, walk->obj->getPersistTag()); } walk->updateSkipCount = 0; --- 476,479 ---- |
From: Mark F. <mar...@us...> - 2004-05-12 02:55:11
|
Update of /cvsroot/opentnl/tnl/zap In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10363/zap Modified Files: gameConnection.h Log Message: Updated readme and game version Index: gameConnection.h =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/gameConnection.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** gameConnection.h 11 May 2004 18:26:25 -0000 1.8 --- gameConnection.h 12 May 2004 02:54:46 -0000 1.9 *************** *** 221,224 **** --- 221,226 ---- void onConnectTimedOut(); + bool isDataToTransmit() { return true; } + TNL_DECLARE_NETCONNECTION(GameConnection); TNL_DECLARE_RPC(c2sRequestCommanderMap, ()); |
From: Mark F. <mar...@us...> - 2004-05-12 02:28:16
|
Update of /cvsroot/opentnl/tnl/zap In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5750/zap Modified Files: game.h gameLoader.cpp Log Message: Updated readme and game version Index: game.h =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/game.h,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** game.h 11 May 2004 18:26:25 -0000 1.17 --- game.h 12 May 2004 02:28:06 -0000 1.18 *************** *** 212,216 **** extern void endGame(); ! #define ZAP_GAME_STRING "ZAP 1.2.0 rc 2" }; --- 212,216 ---- extern void endGame(); ! #define ZAP_GAME_STRING "ZAP 1.2.0 rc 3" }; Index: gameLoader.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/gameLoader.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** gameLoader.cpp 20 Apr 2004 04:27:20 -0000 1.1 --- gameLoader.cpp 12 May 2004 02:28:06 -0000 1.2 *************** *** 166,170 **** --- 166,173 ---- FILE *f = fopen(file, "r"); if(!f) + { + logprintf("Unable to open level file %s!!", file); return; + } char fileData[32768]; |
From: Mark F. <mar...@us...> - 2004-05-12 02:28:14
|
Update of /cvsroot/opentnl/tnl/exe In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5750/exe Modified Files: README.txt Log Message: Updated readme and game version Index: README.txt =================================================================== RCS file: /cvsroot/opentnl/tnl/exe/README.txt,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** README.txt 8 May 2004 00:50:22 -0000 1.9 --- README.txt 12 May 2004 02:28:05 -0000 1.10 *************** *** 16,19 **** --- 16,20 ---- excellent HawkVoice library. - Added more sounds + - Added journaling capabilities for debugging purposes Controls: *************** *** 81,84 **** --- 82,88 ---- joystickType argument can be either 0 or 1. If the right stick doesn't aim shots properly with 0, try 1. + -jsave [journalName] saves the log of the play session to the specified + journal file. + -jplay [journalName] replays a saved journal. Credits: |
From: Mark F. <mar...@us...> - 2004-05-12 01:56:52
|
Update of /cvsroot/opentnl/tnl/zap In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31749/zap Modified Files: winJoystick.cpp Log Message: Added joystick move journaling Updated macros for when journaling is compiled out Index: winJoystick.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/winJoystick.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** winJoystick.cpp 9 May 2004 22:17:28 -0000 1.8 --- winJoystick.cpp 12 May 2004 01:56:42 -0000 1.9 *************** *** 33,36 **** --- 33,37 ---- #include "point.h" #include "UI.h" + #include "tnlJournal.h" namespace Zap *************** *** 117,208 **** } ! void JoystickUpdateMove( Move *theMove ) { ! DIJOYSTATE2 js; // DInput joystick state ! if(!gJoystick) ! return; ! if(FAILED(gJoystick->Poll() ) ) ! { ! HRESULT hr; ! hr = gJoystick->Acquire(); ! ! while( hr == DIERR_INPUTLOST ) ! hr = gJoystick->Acquire(); ! return; ! } ! // Get the input's device state ! if(FAILED(gJoystick->GetDeviceState( sizeof(DIJOYSTATE2), &js ) ) ) ! return; // The device should have been acquired during the Poll() ! S32 x = js.lX; ! F32 deadZone = 8192.0f; ! F32 controls[4]; ! controls[0] = F32( js.lX ) - 32768.0f; ! controls[1] = F32( js.lY ) - 32768.0f; ! if(gJoystickType == 0) ! { controls[2] = F32( js.lRz ) - 32768.0f; controls[3] = F32( js.rglSlider[0] ) - 32768.0f; ! } ! else if(gJoystickType == 1) ! { controls[3] = F32( js.lZ ) - 32768.0f; controls[2] = F32( js.lRz ) - 32768.0f; ! } ! for(U32 i = 0; i < 4; i++) ! { ! if(controls[i] < -deadZone) ! controls[i] = -(-controls[i] - deadZone) / F32(32768.0f - deadZone); ! else if(controls[i] > deadZone) ! controls[i] = (controls[i] - deadZone) / F32(32768.0f - deadZone); ! else ! controls[i] = 0; ! } ! if(controls[0] < 0) ! { ! theMove->left = -controls[0]; ! theMove->right = 0; ! } ! else ! { ! theMove->left = 0; ! theMove->right = controls[0]; ! } ! if(controls[1] < 0) ! { ! theMove->up = -controls[1]; ! theMove->down = 0; ! } ! else ! { ! theMove->down = controls[1]; ! theMove->up = 0; ! } ! Point p(controls[2], controls[3]); ! if(p.len() > 0.1) ! { ! theMove->angle = atan2(p.x, p.y); ! theMove->fire = true; ! } ! else ! theMove->fire = false; - static bool buttonDown[12] = { 0, }; // check the state of the buttons: for( U32 i = 0; i < 12; i++ ) { ! bool buttonPressed = (js.rgbButtons[i] & 0x80) != 0; ! if(buttonPressed && !buttonDown[i]) UserInterface::current->onControllerButtonDown(i); ! else if(!buttonPressed && buttonDown[i]) UserInterface::current->onControllerButtonUp(i); ! buttonDown[i] = buttonPressed; } } --- 118,252 ---- } ! ! static bool updateMoveInternal( Move *theMove, bool buttonPressed[12] ) { ! DIJOYSTATE2 js; // DInput joystick state ! if(!gJoystick) ! return false; ! if(FAILED(gJoystick->Poll() ) ) ! { ! HRESULT hr; ! hr = gJoystick->Acquire(); ! ! while( hr == DIERR_INPUTLOST ) ! hr = gJoystick->Acquire(); ! return false; ! } ! // Get the input's device state ! if(FAILED(gJoystick->GetDeviceState( sizeof(DIJOYSTATE2), &js ) ) ) ! return false; // The device should have been acquired during the Poll() ! S32 x = js.lX; ! F32 deadZone = 8192.0f; ! F32 controls[4]; ! controls[0] = F32( js.lX ) - 32768.0f; ! controls[1] = F32( js.lY ) - 32768.0f; ! if(gJoystickType == 0) ! { controls[2] = F32( js.lRz ) - 32768.0f; controls[3] = F32( js.rglSlider[0] ) - 32768.0f; ! } ! else if(gJoystickType == 1) ! { controls[3] = F32( js.lZ ) - 32768.0f; controls[2] = F32( js.lRz ) - 32768.0f; ! } ! for(U32 i = 0; i < 4; i++) ! { ! if(controls[i] < -deadZone) ! controls[i] = -(-controls[i] - deadZone) / F32(32768.0f - deadZone); ! else if(controls[i] > deadZone) ! controls[i] = (controls[i] - deadZone) / F32(32768.0f - deadZone); ! else ! controls[i] = 0; ! } ! if(controls[0] < 0) ! { ! theMove->left = -controls[0]; ! theMove->right = 0; ! } ! else ! { ! theMove->left = 0; ! theMove->right = controls[0]; ! } ! if(controls[1] < 0) ! { ! theMove->up = -controls[1]; ! theMove->down = 0; ! } ! else ! { ! theMove->down = controls[1]; ! theMove->up = 0; ! } ! Point p(controls[2], controls[3]); ! if(p.len() > 0.1) ! { ! theMove->angle = atan2(p.x, p.y); ! theMove->fire = true; ! } ! else ! theMove->fire = false; // check the state of the buttons: for( U32 i = 0; i < 12; i++ ) + buttonPressed[i] = (js.rgbButtons[i] & 0x80) != 0; + + return true; + } + + static bool updateMoveInternalJournaled( Move *theMove, bool buttonPressed[12] ) + { + TNL_JOURNAL_READ_BLOCK(3000, + BitStream *readStream = Journal::getReadStream(); + if(!readStream->readFlag()) + return false; + + Move aMove; + aMove.unpack(readStream); + *theMove = aMove; + for(U32 i = 0; i < 12; i++) + buttonPressed[i] = readStream->readFlag(); + return true; + ) + + bool ret = updateMoveInternal(theMove, buttonPressed); + + TNL_JOURNAL_WRITE_BLOCK(3000, + BitStream *writeStream = Journal::getWriteStream(); + if(writeStream->writeFlag(ret)) + { + Move dummy; + theMove->pack(writeStream, &dummy); + for(U32 i = 0;i < 12; i++) + writeStream->writeFlag(buttonPressed[i]); + } + ) + return ret; + } + + void JoystickUpdateMove( Move *theMove ) + { + static bool buttonDown[12] = { 0, }; + bool buttonPressed[12]; + + if(!updateMoveInternalJournaled( theMove, buttonPressed )) + return; + + for(U32 i = 0; i < 12; i++) { ! if(buttonPressed[i] && !buttonDown[i]) UserInterface::current->onControllerButtonDown(i); ! else if(!buttonPressed[i] && buttonDown[i]) UserInterface::current->onControllerButtonUp(i); ! buttonDown[i] = buttonPressed[i]; } } |
From: Mark F. <mar...@us...> - 2004-05-12 01:56:52
|
Update of /cvsroot/opentnl/tnl/tnl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31749/tnl Modified Files: tnlJournal.h Log Message: Added joystick move journaling Updated macros for when journaling is compiled out Index: tnlJournal.h =================================================================== RCS file: /cvsroot/opentnl/tnl/tnl/tnlJournal.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** tnlJournal.h 12 May 2004 01:37:59 -0000 1.4 --- tnlJournal.h 12 May 2004 01:56:42 -0000 1.5 *************** *** 172,177 **** void className::func args ! #define TNL_JOURNAL_WRITE_BLOCK(x) ! #define TNL_JOURNAL_READ_BLOCK(x) #endif --- 172,177 ---- void className::func args ! #define TNL_JOURNAL_WRITE_BLOCK(blockType, x) ! #define TNL_JOURNAL_READ_BLOCK(blockType, x) #endif |
From: Mark F. <mar...@us...> - 2004-05-12 01:38:09
|
Update of /cvsroot/opentnl/tnl/tnl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28526/tnl Modified Files: journal.cpp netConnection.cpp platform.cpp tnl.vcproj tnlJournal.h udp.cpp Log Message: Made Zap master connection client adaptive Added buncha stuff to journaling Fixed nasty netConnection bug (thanks, Journaling!) Index: platform.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/tnl/platform.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** platform.cpp 11 May 2004 02:45:26 -0000 1.3 --- platform.cpp 12 May 2004 01:37:59 -0000 1.4 *************** *** 143,147 **** U32 tickCount; TNL_JOURNAL_READ_BLOCK ! ( TNL_JOURNAL_READ( (&tickCount) ); return tickCount; --- 143,147 ---- U32 tickCount; TNL_JOURNAL_READ_BLOCK ! ( 2001, TNL_JOURNAL_READ( (&tickCount) ); return tickCount; *************** *** 151,155 **** TNL_JOURNAL_WRITE_BLOCK ! ( TNL_JOURNAL_WRITE( (tickCount) ); ) --- 151,155 ---- TNL_JOURNAL_WRITE_BLOCK ! ( 2001, TNL_JOURNAL_WRITE( (tickCount) ); ) *************** *** 197,201 **** S64 currentTime; TNL_JOURNAL_READ_BLOCK ! ( TNL_JOURNAL_READ( (¤tTime) ); return currentTime; --- 197,201 ---- S64 currentTime; TNL_JOURNAL_READ_BLOCK ! ( 2003, TNL_JOURNAL_READ( (¤tTime) ); return currentTime; *************** *** 205,209 **** TNL_JOURNAL_WRITE_BLOCK ! ( TNL_JOURNAL_WRITE( (currentTime) ); ) --- 205,209 ---- TNL_JOURNAL_WRITE_BLOCK ! ( 2003, TNL_JOURNAL_WRITE( (currentTime) ); ) *************** *** 216,220 **** F64 timerValue; TNL_JOURNAL_READ_BLOCK ! ( TNL_JOURNAL_READ( (&timerValue) ); return timerValue; --- 216,220 ---- F64 timerValue; TNL_JOURNAL_READ_BLOCK ! ( 2002, TNL_JOURNAL_READ( (&timerValue) ); return timerValue; *************** *** 224,228 **** TNL_JOURNAL_WRITE_BLOCK ! ( TNL_JOURNAL_WRITE( (timerValue) ); ) --- 224,228 ---- TNL_JOURNAL_WRITE_BLOCK ! ( 2002, TNL_JOURNAL_WRITE( (timerValue) ); ) Index: tnlJournal.h =================================================================== RCS file: /cvsroot/opentnl/tnl/tnl/tnlJournal.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** tnlJournal.h 11 May 2004 18:26:24 -0000 1.3 --- tnlJournal.h 12 May 2004 01:37:59 -0000 1.4 *************** *** 32,36 **** #define TNL_ENABLE_JOURNALING ! namespace TNL { --- 32,36 ---- #define TNL_ENABLE_JOURNALING ! //#define TNL_ENABLE_BIG_JOURNALS namespace TNL { *************** *** 48,51 **** --- 48,54 ---- static Journal *mJournal; static U32 mWritePosition; + static U32 mReadBreakBitPos; + static U32 mBreakBlockIndex; + static U32 mBlockIndex; public: enum Mode *************** *** 58,61 **** --- 61,66 ---- static Mode mCurrentMode; static bool mInsideEntrypoint; + static void checkReadPosition(); + static void syncWriteStream(); public: Journal(); *************** *** 68,76 **** static Mode getCurrentMode() { return mCurrentMode; } static Journal *get() { return mJournal; } - static void checkReadPosition(); - static void syncWriteStream(); static BitStream *getReadStream() { return &mReadStream; } static BitStream *getWriteStream() { return &mWriteStream; } static bool isInEntrypoint() { return mInsideEntrypoint; } }; --- 73,82 ---- static Mode getCurrentMode() { return mCurrentMode; } static Journal *get() { return mJournal; } static BitStream *getReadStream() { return &mReadStream; } static BitStream *getWriteStream() { return &mWriteStream; } static bool isInEntrypoint() { return mInsideEntrypoint; } + + static void beginBlock(U32 blockId, bool writeBlock); + static void endBlock(U32 blockId, bool writeBlock); }; *************** *** 113,139 **** void FN_CDECL className::func##_body args ! #define TNL_JOURNAL_WRITE_BLOCK(x) \ ! { \ ! if(TNL::Journal::getCurrentMode() == TNL::Journal::Record && TNL::Journal::isInEntrypoint()) \ ! { \ ! x \ ! } \ ! TNL::Journal::syncWriteStream(); \ ! } ! ! class JournalReadChecker { public: ! ~JournalReadChecker() { ! TNL::Journal::checkReadPosition(); } }; ! #define TNL_JOURNAL_READ_BLOCK(x) \ { \ ! if(TNL::Journal::isInEntrypoint()) { \ ! TNL::JournalReadChecker dummy; \ ! if(TNL::Journal::getCurrentMode() == TNL::Journal::Playback) \ { \ x \ --- 119,156 ---- void FN_CDECL className::func##_body args ! class JournalToken { + bool mWriting; + U32 mBlockType; public: ! JournalToken(U32 blockType, bool writing) { ! mWriting = writing; ! mBlockType = blockType; ! TNL::Journal::beginBlock(mBlockType, mWriting); ! } ! ! ~JournalToken() ! { ! TNL::Journal::endBlock(mBlockType, mWriting); } }; ! #define TNL_JOURNAL_WRITE_BLOCK(blockType, x) \ { \ ! if(TNL::Journal::getCurrentMode() == TNL::Journal::Record && TNL::Journal::isInEntrypoint()) \ ! { \ ! TNL::JournalToken dummy(blockType, true); \ ! { \ ! x \ ! } \ ! } \ ! } ! ! #define TNL_JOURNAL_READ_BLOCK(blockType, x) \ ! { \ ! if(TNL::Journal::getCurrentMode() == TNL::Journal::Playback && TNL::Journal::isInEntrypoint()) \ ! { \ ! TNL::JournalToken dummy(blockType, false); \ { \ x \ Index: udp.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/tnl/udp.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** udp.cpp 11 May 2004 02:45:26 -0000 1.3 --- udp.cpp 12 May 2004 01:37:59 -0000 1.4 *************** *** 191,195 **** Socket::Socket(const Address &bindAddress, U32 sendBufferSize, U32 recvBufferSize, bool acceptsBroadcast, bool nonblockingIO) { ! TNL_JOURNAL_READ_BLOCK( TNL_JOURNAL_READ( (&mPlatformSocket) ); return; --- 191,195 ---- Socket::Socket(const Address &bindAddress, U32 sendBufferSize, U32 recvBufferSize, bool acceptsBroadcast, bool nonblockingIO) { ! TNL_JOURNAL_READ_BLOCK(1001, TNL_JOURNAL_READ( (&mPlatformSocket) ); return; *************** *** 271,275 **** } } ! TNL_JOURNAL_WRITE_BLOCK( TNL_JOURNAL_WRITE( (mPlatformSocket) ); ) --- 271,275 ---- } } ! TNL_JOURNAL_WRITE_BLOCK(1001, TNL_JOURNAL_WRITE( (mPlatformSocket) ); ) *************** *** 278,285 **** Socket::~Socket() { ! TNL_JOURNAL_READ_BLOCK( return; ) if(mPlatformSocket != INVALID_SOCKET) closesocket(mPlatformSocket); --- 278,287 ---- Socket::~Socket() { ! TNL_JOURNAL_READ_BLOCK(1002, return; ) + TNL_JOURNAL_WRITE_BLOCK(1002, ;) + if(mPlatformSocket != INVALID_SOCKET) closesocket(mPlatformSocket); *************** *** 289,296 **** NetError Socket::sendto(const Address &address, const U8 *buffer, S32 bufferSize) { ! TNL_JOURNAL_READ_BLOCK( return NoError; ) if(address.transport != mTransportProtocol) return InvalidPacketProtocol; --- 291,301 ---- NetError Socket::sendto(const Address &address, const U8 *buffer, S32 bufferSize) { ! TNL_JOURNAL_READ_BLOCK(1003, return NoError; ) + TNL_JOURNAL_WRITE_BLOCK(1003, ; + ) + if(address.transport != mTransportProtocol) return InvalidPacketProtocol; *************** *** 309,313 **** NetError Socket::recvfrom(Address *address, U8 *buffer, S32 bufferSize, S32 *outSize) { ! TNL_JOURNAL_READ_BLOCK( bool wouldBlock; TNL_JOURNAL_READ( (&wouldBlock) ); --- 314,318 ---- NetError Socket::recvfrom(Address *address, U8 *buffer, S32 bufferSize, S32 *outSize) { ! TNL_JOURNAL_READ_BLOCK(1004, bool wouldBlock; TNL_JOURNAL_READ( (&wouldBlock) ); *************** *** 333,337 **** if(bytesRead == SOCKET_ERROR) { ! TNL_JOURNAL_WRITE_BLOCK( TNL_JOURNAL_WRITE ( (true) ); ) --- 338,342 ---- if(bytesRead == SOCKET_ERROR) { ! TNL_JOURNAL_WRITE_BLOCK(1004, TNL_JOURNAL_WRITE ( (true) ); ) *************** *** 343,347 **** *outSize = bytesRead; ! TNL_JOURNAL_WRITE_BLOCK( TNL_JOURNAL_WRITE( (false) ); TNL_JOURNAL_WRITE( (address->transport) ); --- 348,352 ---- *outSize = bytesRead; ! TNL_JOURNAL_WRITE_BLOCK(1004, TNL_JOURNAL_WRITE( (false) ); TNL_JOURNAL_WRITE( (address->transport) ); Index: tnl.vcproj =================================================================== RCS file: /cvsroot/opentnl/tnl/tnl/tnl.vcproj,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** tnl.vcproj 10 May 2004 22:34:23 -0000 1.3 --- tnl.vcproj 12 May 2004 01:37:59 -0000 1.4 *************** *** 75,79 **** InlineFunctionExpansion="1" AdditionalIncludeDirectories="../libtomcrypt" ! PreprocessorDefinitions="WIN32;NDEBUG;_LIB" StringPooling="TRUE" ExceptionHandling="FALSE" --- 75,79 ---- InlineFunctionExpansion="1" AdditionalIncludeDirectories="../libtomcrypt" ! PreprocessorDefinitions="WIN32;NDEBUG;_LIB;TNL_ENABLE_LOGGING" StringPooling="TRUE" ExceptionHandling="FALSE" Index: journal.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/tnl/journal.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** journal.cpp 11 May 2004 18:26:24 -0000 1.3 --- journal.cpp 12 May 2004 01:37:59 -0000 1.4 *************** *** 27,30 **** --- 27,31 ---- #include "tnlJournal.h" #include "tnlEndian.h" + #include "tnlLog.h" namespace TNL *************** *** 35,38 **** --- 36,40 ---- bool Journal::mInsideEntrypoint = false; Journal::Mode Journal::mCurrentMode = Journal::Inactive; + U32 Journal::mReadBreakBitPos = 0; FILE *Journal::mJournalFile = NULL; *************** *** 41,44 **** --- 43,48 ---- Journal *Journal::mJournal = NULL; U32 Journal::mWritePosition = 0; + U32 Journal::mBreakBlockIndex = 0; + U32 Journal::mBlockIndex = 0; JournalEntryRecord::JournalEntryRecord(const char *functionName, MethodArgList *methodArgList) *************** *** 141,144 **** --- 145,152 ---- mReadStream.read(&bitCount); mReadStream.setMaxBitSizes(bitCount); + + if(!mReadBreakBitPos || mReadBreakBitPos > bitCount) + mReadBreakBitPos = bitCount; + fclose(theJournal); mCurrentMode = Playback; *************** *** 163,168 **** --- 171,182 ---- if(mCurrentMode == Record) { + #ifdef TNL_ENABLE_BIG_JOURNALS + TNL_JOURNAL_WRITE( (U16(0x1234)) ); + #endif mWriteStream.writeRangedU32(entryIndex, 0, JournalEntryRecord::mEntryVector->size() - 1); mWriteStream.writeBits(theCall->marshalledData.getBitPosition(), theCall->marshalledData.getBuffer()); + #ifdef TNL_ENABLE_BIG_JOURNALS + TNL_JOURNAL_WRITE( (U16(0x5678)) ); + #endif syncWriteStream(); } *************** *** 180,187 **** void Journal::checkReadPosition() { ! if(!mReadStream.isValid() || mReadStream.getBitPosition() == mReadStream.getMaxReadBitPosition()) TNL_DEBUGBREAK(); } void Journal::processNextJournalEntry() { --- 194,251 ---- void Journal::checkReadPosition() { ! if(!mReadStream.isValid() || mReadStream.getBitPosition() >= mReadBreakBitPos) TNL_DEBUGBREAK(); } + void Journal::beginBlock(U32 blockId, bool writeBlock) + { + if(writeBlock) + { + #ifdef TNL_ENABLE_BIG_JOURNALS + TNL_JOURNAL_WRITE( (U16(0x1234 ^ blockId)) ); + #endif + } + else + { + mBlockIndex++; + if(mBreakBlockIndex && mBlockIndex >= mBreakBlockIndex) + TNL_DEBUGBREAK(); + + #ifdef TNL_ENABLE_BIG_JOURNALS + U16 startToken; + TNL_JOURNAL_READ( (&startToken) ); + if((startToken ^ 0x1234) != blockId) + { + logprintf("Expected token %d - got %d", blockId, startToken ^ 0x1234); + TNL_DEBUGBREAK(); + } + #endif + } + } + + void Journal::endBlock(U32 blockId, bool writeBlock) + { + if(writeBlock) + { + #ifdef TNL_ENABLE_BIG_JOURNALS + TNL_JOURNAL_WRITE( (U16(0x5678 ^ blockId)) ); + #endif + syncWriteStream(); + } + else + { + #ifdef TNL_ENABLE_BIG_JOURNALS + U16 endToken; + TNL_JOURNAL_READ( (&endToken) ); + if((endToken ^ 0x5678) != blockId) + { + logprintf("Expected token %d - got %d", blockId, endToken ^ 0x5678); + TNL_DEBUGBREAK(); + } + #endif + checkReadPosition(); + } + } + void Journal::processNextJournalEntry() { *************** *** 189,192 **** --- 253,263 ---- return; + #ifdef TNL_ENABLE_BIG_JOURNALS + U16 token; + TNL_JOURNAL_READ( (&token) ); + if(token != 0x1234) + TNL_DEBUGBREAK(); + #endif + U32 index = mReadStream.readRangedU32(0, JournalEntryRecord::mEntryVector->size()); *************** *** 203,206 **** --- 274,284 ---- MarshalledCall theCall(theEntry->mMethodArgList); theCall.unmarshall(&mReadStream); + + #ifdef TNL_ENABLE_BIG_JOURNALS + TNL_JOURNAL_READ( (&token) ); + if(token != 0x5678) + TNL_DEBUGBREAK(); + #endif + checkReadPosition(); Index: netConnection.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/tnl/netConnection.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** netConnection.cpp 24 Apr 2004 23:52:32 -0000 1.2 --- netConnection.cpp 12 May 2004 01:37:59 -0000 1.3 *************** *** 206,210 **** mNotifyQueueTail = note; note->nextPacket = NULL; ! note->sendTime = mLastUpdateTime; writePacketRateInfo(bstream, note); --- 206,210 ---- mNotifyQueueTail = note; note->nextPacket = NULL; ! note->sendTime = Platform::getRealMilliseconds(); writePacketRateInfo(bstream, note); *************** *** 245,248 **** --- 245,251 ---- void NetConnection::writePacketHeader(BitStream *stream, NetPacketType packetType) { + if(windowFull() && packetType == DataPacket) + TNL_DEBUGBREAK(); + S32 ackByteCount = ((mLastSeqRecvd - mLastRecvAckAck + 7) >> 3); TNLAssert(ackByteCount <= MaxAckByteCount, "ackByteCount exceeds MaxAckByteCount!"); *************** *** 278,281 **** --- 281,290 ---- mLastSeqRecvdAtSend[mLastSendSeq & PacketWindowMask] = mLastSeqRecvd; + //if(isNetworkConnection()) + //{ + // TNLLogMessageV(LogBlah, ("SND: mLSQ: %08x pkLS: %08x pt: %d abc: %d", + // mLastSendSeq, mLastSeqRecvd, packetType, ackByteCount)); + //} + TNLLogMessageV(LogConnectionProtocol, ("build hdr %d %d", mLastSendSeq, packetType)); } *************** *** 347,351 **** return false; } ! if(!mSymmetricCipher.isNull()) { --- 356,360 ---- return false; } ! if(!mSymmetricCipher.isNull()) { *************** *** 359,363 **** return false; ! U32 pkAckMask[MaxAckByteCount]; U32 pkAckWordCount = (pkAckByteCount + 3) >> 2; --- 368,372 ---- return false; ! U32 pkAckMask[MaxAckMaskSize]; U32 pkAckWordCount = (pkAckByteCount + 3) >> 2; *************** *** 366,369 **** --- 375,384 ---- (pkAckByteCount - (i * 4)) * 8 : 32); + //if(isNetworkConnection()) + //{ + // TNLLogMessageV(LogBlah, ("RCV: mHA: %08x pkHA: %08x mLSQ: %08x pkSN: %08x pkLS: %08x pkAM: %08x", + // mHighestAckedSeq, pkHighestAck, mLastSendSeq, pkSequenceNumber, mLastSeqRecvd, pkAckMask[0])); + //} + U32 pkSendDelay = (pstream->readInt(8) << 3) + 4; *************** *** 560,564 **** // We are in normal state.. if(cwnd < MaxPacketWindowSize-2) ! cwnd += (1 < 1/cwnd) ? 1 : (1/cwnd); TNLLogMessageV(LogNetConnection, ("PKT OK - ssthresh = %f cwnd=%f", ssthresh, cwnd)); --- 575,579 ---- // We are in normal state.. if(cwnd < MaxPacketWindowSize-2) ! cwnd += 1/cwnd; TNLLogMessageV(LogNetConnection, ("PKT OK - ssthresh = %f cwnd=%f", ssthresh, cwnd)); *************** *** 637,642 **** sendAckPacket(); } - return; } } PacketStream stream(mCurrentPacketSendSize); --- 652,657 ---- sendAckPacket(); } } + return; } PacketStream stream(mCurrentPacketSendSize); *************** *** 650,657 **** bool NetConnection::windowFull() { if(isAdaptive()) ! return mLastSendSeq - mHighestAckedSeq >= cwnd; ! else ! return mLastSendSeq - mHighestAckedSeq >= (MaxPacketWindowSize - 2); } --- 665,673 ---- bool NetConnection::windowFull() { + if(mLastSendSeq - mHighestAckedSeq >= (MaxPacketWindowSize - 2)) + return true; if(isAdaptive()) ! return mLastSendSeq - mHighestAckedSeq >= cwnd; ! return false; } |
From: Mark F. <mar...@us...> - 2004-05-12 01:38:09
|
Update of /cvsroot/opentnl/tnl/zap In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28526/zap Modified Files: ZAP.vcproj main.cpp masterConnection.h Log Message: Made Zap master connection client adaptive Added buncha stuff to journaling Fixed nasty netConnection bug (thanks, Journaling!) Index: main.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/main.cpp,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** main.cpp 11 May 2004 18:26:25 -0000 1.27 --- main.cpp 12 May 2004 01:38:00 -0000 1.28 *************** *** 57,60 **** --- 57,63 ---- const char *gMasterAddressString = "IP:master.opentnl.org:29005"; Address gMasterAddress; + Address gConnectAddress; + Address gBindAddress(IPProtocol, Address::Any, 28000); + const char *gLevelList = "level4.txt level2.txt level1.txt level2.txt level3.txt level2.txt"; *************** *** 72,75 **** --- 75,79 ---- TNL_DECLARE_JOURNAL_ENTRYPOINT(idle, (U32 timeDelta)); TNL_DECLARE_JOURNAL_ENTRYPOINT(display, ()); + TNL_DECLARE_JOURNAL_ENTRYPOINT(startup, (bool hasClient, bool hasServer, bool connectLocal, bool connectRemote, bool nameSet)); }; *************** *** 264,268 **** void logString(const char *string) { ! printf("%s\r\n", string); } } gStdoutLogConsumer; --- 268,272 ---- void logString(const char *string) { ! printf("%s\n", string); } } gStdoutLogConsumer; *************** *** 288,292 **** { if(f) ! fprintf(f, "%s\r\n", string); } } gFileLogConsumer; --- 292,299 ---- { if(f) ! { ! fprintf(f, "%s\n", string); ! fflush(f); ! } } } gFileLogConsumer; *************** *** 348,351 **** --- 355,377 ---- extern void InitController(); + TNL_IMPLEMENT_JOURNAL_ENTRYPOINT(ZapJournal, startup, (bool hasClient, bool hasServer, bool connectLocal, bool connectRemote, bool nameSet)) + { + if(hasClient) + gClientGame = new ClientGame(Address()); + + if(hasServer) + hostGame(hasClient == false, gBindAddress); + else if(connectRemote) + joinGame(gConnectAddress, false); + + if(!connectLocal && !connectRemote) + { + if(!nameSet) + gNameEntryUserInterface.activate(); + else + gMainMenuUserInterface.activate(); + } + } + }; *************** *** 354,359 **** --- 380,389 ---- int main(int argc, char **argv) { + //TNLLogEnable(LogConnectionProtocol, true); + //TNLLogEnable(LogNetConnection, true); TNLLogEnable(LogNetInterface, true); TNLLogEnable(LogPlatform, true); + //TNLLogEnable(LogBlah, true); + bool hasClient = true; bool hasServer = false; *************** *** 362,367 **** bool nameSet = false; - Address connectAddress; - Address bindAddress(IPProtocol, Address::Any, 28000); U32 maxPlayers = 128; --- 392,395 ---- *************** *** 375,379 **** connectLocal = true; if(hasAdditionalArg) ! bindAddress.set(argv[i+1]); } else if(!stricmp(argv[i], "-connect")) --- 403,407 ---- connectLocal = true; if(hasAdditionalArg) ! gBindAddress.set(argv[i+1]); } else if(!stricmp(argv[i], "-connect")) *************** *** 381,385 **** connectRemote = true; if(hasAdditionalArg) ! connectAddress.set(argv[i+1]); } else if(!stricmp(argv[i], "-master")) --- 409,413 ---- connectRemote = true; if(hasAdditionalArg) ! gConnectAddress.set(argv[i+1]); } else if(!stricmp(argv[i], "-master")) *************** *** 414,418 **** hasServer = true; if(hasAdditionalArg) ! bindAddress.set(argv[i+1]); } else if(!stricmp(argv[i], "-name")) --- 442,446 ---- hasServer = true; if(hasAdditionalArg) ! gBindAddress.set(argv[i+1]); } else if(!stricmp(argv[i], "-name")) *************** *** 441,461 **** } gMasterAddress.set(gMasterAddressString); if(hasClient) - gClientGame = new ClientGame(Address()); - - if(hasServer) - hostGame(hasClient == false, bindAddress); - else if(connectRemote) - joinGame(connectAddress, false); - - if(!connectLocal && !connectRemote) - { - if(!nameSet) - gNameEntryUserInterface.activate(); - else - gMainMenuUserInterface.activate(); - } - if(hasClient) { SFXObject::init(); --- 469,475 ---- } gMasterAddress.set(gMasterAddressString); + gZapJournal.startup(hasClient, hasServer, connectLocal, connectRemote, nameSet); if(hasClient) { SFXObject::init(); *************** *** 487,497 **** atexit(endGame); glutMainLoop(); } else - { dedicatedServerLoop(); - } return 0; ! } ! --- 501,509 ---- atexit(endGame); + glutMainLoop(); } else dedicatedServerLoop(); return 0; ! } \ No newline at end of file Index: masterConnection.h =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/masterConnection.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** masterConnection.h 20 Apr 2004 04:27:20 -0000 1.1 --- masterConnection.h 12 May 2004 01:38:00 -0000 1.2 *************** *** 48,51 **** --- 48,52 ---- mCurrentQueryId = 0; setIsConnectionToServer(); + setIsAdaptive(); } Index: ZAP.vcproj =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/ZAP.vcproj,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** ZAP.vcproj 9 May 2004 20:35:17 -0000 1.15 --- ZAP.vcproj 12 May 2004 01:38:00 -0000 1.16 *************** *** 73,77 **** OptimizeForWindowsApplication="TRUE" AdditionalIncludeDirectories="../tnl;../glut;../openal" ! PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS" RuntimeLibrary="4" RuntimeTypeInfo="TRUE" --- 73,77 ---- OptimizeForWindowsApplication="TRUE" AdditionalIncludeDirectories="../tnl;../glut;../openal" ! PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;TNL_ENABLE_LOGGING" RuntimeLibrary="4" RuntimeTypeInfo="TRUE" |
Update of /cvsroot/opentnl/tnl/zap In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3672/zap Modified Files: UINameEntry.cpp UINameEntry.h game.cpp game.h gameConnection.cpp gameConnection.h main.cpp ship.cpp ship.h Log Message: Added size optimizations on journal writes Added flush of journal Added debug break at end of journal playback Index: gameConnection.h =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/gameConnection.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** gameConnection.h 3 May 2004 22:06:16 -0000 1.7 --- gameConnection.h 11 May 2004 18:26:25 -0000 1.8 *************** *** 178,184 **** static GameConnection gClientList; - // Time in milliseconds at which we were created. - U32 mCreateTime; - GameConnection(Game *game = NULL); ~GameConnection(); --- 178,181 ---- Index: gameConnection.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/gameConnection.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** gameConnection.cpp 3 May 2004 22:06:16 -0000 1.10 --- gameConnection.cpp 11 May 2004 18:26:25 -0000 1.11 *************** *** 42,46 **** { mNext = mPrev = this; - mCreateTime = Platform::getRealMilliseconds(); highSendIndex[0] = 0; highSendIndex[1] = 0; --- 42,45 ---- Index: ship.h =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/ship.h,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** ship.h 7 May 2004 00:51:01 -0000 1.15 --- ship.h 11 May 2004 18:26:25 -0000 1.16 *************** *** 31,35 **** #include "sparkManager.h" #include "sfx.h" ! namespace Zap { --- 31,35 ---- #include "sparkManager.h" #include "sfx.h" ! #include "timer.h" namespace Zap { *************** *** 71,75 **** U32 interpTime; ! U32 lastFireTime; F32 mHealth; F32 mEnergy; --- 71,75 ---- U32 interpTime; ! Timer mFireTimer; F32 mHealth; F32 mEnergy; *************** *** 83,87 **** Color color; // color of the ship F32 mass; // mass of ship - U32 timeUntilRemove; // when the ship is killed, it sticks around for a while to make sure that the kill message is propagated bool hasExploded; --- 83,86 ---- Index: game.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/game.cpp,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** game.cpp 5 May 2004 09:50:35 -0000 1.19 --- game.cpp 11 May 2004 18:26:24 -0000 1.20 *************** *** 60,65 **** mNextMasterTryTime = 0; - mLastIdleTime = Platform::getRealMilliseconds(); - mNetInterface = new GameNetInterface(theBindAddress, this); } --- 60,63 ---- Index: game.h =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/game.h,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** game.h 8 May 2004 22:59:58 -0000 1.16 --- game.h 11 May 2004 18:26:25 -0000 1.17 *************** *** 85,89 **** { protected: - U32 mLastIdleTime; U32 mNextMasterTryTime; F32 mGridSize; --- 85,88 ---- Index: UINameEntry.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/UINameEntry.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** UINameEntry.cpp 20 Apr 2004 04:27:19 -0000 1.1 --- UINameEntry.cpp 11 May 2004 18:26:24 -0000 1.2 *************** *** 64,71 **** void NameEntryUserInterface::idle(U32 t) { ! U32 time = Platform::getRealMilliseconds(); ! if(time - lastBlinkTime > BlinkTime) { ! lastBlinkTime = time; blink = !blink; } --- 64,70 ---- void NameEntryUserInterface::idle(U32 t) { ! if(mBlinkTimer.update(t)) { ! mBlinkTimer.reset(BlinkTime); blink = !blink; } Index: main.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/main.cpp,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** main.cpp 11 May 2004 02:45:27 -0000 1.26 --- main.cpp 11 May 2004 18:26:25 -0000 1.27 *************** *** 65,73 **** TNL_DECLARE_JOURNAL_ENTRYPOINT(motion, (S32 x, S32 y)); TNL_DECLARE_JOURNAL_ENTRYPOINT(passivemotion, (S32 x, S32 y)); ! TNL_DECLARE_JOURNAL_ENTRYPOINT(key, (U8 key, S32 x, S32 y)); ! TNL_DECLARE_JOURNAL_ENTRYPOINT(keyup, (U8 key, S32 x, S32 y)); TNL_DECLARE_JOURNAL_ENTRYPOINT(mouse, (S32 button, S32 state, S32 x, S32 y)); ! TNL_DECLARE_JOURNAL_ENTRYPOINT(specialkey, (S32 key, S32 x, S32 y)); ! TNL_DECLARE_JOURNAL_ENTRYPOINT(specialkeyup, (S32 key, S32 x, S32 y)); TNL_DECLARE_JOURNAL_ENTRYPOINT(idle, (U32 timeDelta)); TNL_DECLARE_JOURNAL_ENTRYPOINT(display, ()); --- 65,73 ---- TNL_DECLARE_JOURNAL_ENTRYPOINT(motion, (S32 x, S32 y)); TNL_DECLARE_JOURNAL_ENTRYPOINT(passivemotion, (S32 x, S32 y)); ! TNL_DECLARE_JOURNAL_ENTRYPOINT(key, (U8 key)); ! TNL_DECLARE_JOURNAL_ENTRYPOINT(keyup, (U8 key)); TNL_DECLARE_JOURNAL_ENTRYPOINT(mouse, (S32 button, S32 state, S32 x, S32 y)); ! TNL_DECLARE_JOURNAL_ENTRYPOINT(specialkey, (S32 key)); ! TNL_DECLARE_JOURNAL_ENTRYPOINT(specialkeyup, (S32 key)); TNL_DECLARE_JOURNAL_ENTRYPOINT(idle, (U32 timeDelta)); TNL_DECLARE_JOURNAL_ENTRYPOINT(display, ()); *************** *** 111,118 **** void key(unsigned char key, int x, int y) { ! gZapJournal.key(key, x, y); } ! TNL_IMPLEMENT_JOURNAL_ENTRYPOINT(ZapJournal, key, (U8 key, S32 x, S32 y)) { if(UserInterface::current) --- 111,118 ---- void key(unsigned char key, int x, int y) { ! gZapJournal.key(key); } ! TNL_IMPLEMENT_JOURNAL_ENTRYPOINT(ZapJournal, key, (U8 key)) { if(UserInterface::current) *************** *** 122,129 **** void keyup(unsigned char key, int x, int y) { ! gZapJournal.keyup(key, x, y); } ! TNL_IMPLEMENT_JOURNAL_ENTRYPOINT(ZapJournal, keyup, (U8 key, S32 x, S32 y)) { if(UserInterface::current) --- 122,129 ---- void keyup(unsigned char key, int x, int y) { ! gZapJournal.keyup(key); } ! TNL_IMPLEMENT_JOURNAL_ENTRYPOINT(ZapJournal, keyup, (U8 key)) { if(UserInterface::current) *************** *** 172,179 **** void specialkey(int key, int x, int y) { ! gZapJournal.specialkey(key, x, y); } ! TNL_IMPLEMENT_JOURNAL_ENTRYPOINT(ZapJournal, specialkey, (S32 key, S32 x, S32 y)) { if(UserInterface::current) --- 172,179 ---- void specialkey(int key, int x, int y) { ! gZapJournal.specialkey(key); } ! TNL_IMPLEMENT_JOURNAL_ENTRYPOINT(ZapJournal, specialkey, (S32 key)) { if(UserInterface::current) *************** *** 183,190 **** void specialkeyup(int key, int x, int y) { ! gZapJournal.specialkeyup(key, x, y); } ! TNL_IMPLEMENT_JOURNAL_ENTRYPOINT(ZapJournal, specialkeyup, (S32 key, S32 x, S32 y)) { if(UserInterface::current) --- 183,190 ---- void specialkeyup(int key, int x, int y) { ! gZapJournal.specialkeyup(key); } ! TNL_IMPLEMENT_JOURNAL_ENTRYPOINT(ZapJournal, specialkeyup, (S32 key)) { if(UserInterface::current) Index: UINameEntry.h =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/UINameEntry.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** UINameEntry.h 20 Apr 2004 04:27:19 -0000 1.1 --- UINameEntry.h 11 May 2004 18:26:24 -0000 1.2 *************** *** 29,32 **** --- 29,33 ---- #include "UI.h" + #include "timer.h" namespace Zap *************** *** 42,54 **** U32 cursorPos; bool blink; ! U32 lastBlinkTime; protected: const char *title; public: ! NameEntryUserInterface() { title = "ENTER YOUR NAME:"; - lastBlinkTime = 0; buffer[0] = 0; memset(buffer, 0, sizeof(buffer)); --- 43,54 ---- U32 cursorPos; bool blink; ! Timer mBlinkTimer; protected: const char *title; public: ! NameEntryUserInterface() : mBlinkTimer(BlinkTime) { title = "ENTER YOUR NAME:"; buffer[0] = 0; memset(buffer, 0, sizeof(buffer)); Index: ship.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/ship.cpp,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** ship.cpp 7 May 2004 00:51:00 -0000 1.25 --- ship.cpp 11 May 2004 18:26:25 -0000 1.26 *************** *** 61,67 **** mass = m; hasExploded = false; - timeUntilRemove = 0; updateExtent(); - lastFireTime = 0; mPlayerName = playerName; --- 61,65 ---- *************** *** 158,168 **** } if(theMove->fire) { ! U32 currentTime = Platform::getRealMilliseconds(); ! if(currentTime - lastFireTime > FireDelay) { mEnergy -= 0.5f; ! lastFireTime = currentTime; Point dir(sin(mMoveState[ActualState].angle), cos(mMoveState[ActualState].angle) ); Point projVel = dir * 600 + dir * mMoveState[ActualState].vel.dot(dir); --- 156,166 ---- } + mFireTimer.update(theMove->time); if(theMove->fire) { ! if(mFireTimer.getCurrent() == 0) { mEnergy -= 0.5f; ! mFireTimer.reset(FireDelay); Point dir(sin(mMoveState[ActualState].angle), cos(mMoveState[ActualState].angle) ); Point projVel = dir * 600 + dir * mMoveState[ActualState].vel.dot(dir); |
From: Mark F. <mar...@us...> - 2004-05-11 18:26:37
|
Update of /cvsroot/opentnl/tnl/tnl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3672/tnl Modified Files: journal.cpp netInterface.cpp tnlJournal.h Log Message: Added size optimizations on journal writes Added flush of journal Added debug break at end of journal playback Index: tnlJournal.h =================================================================== RCS file: /cvsroot/opentnl/tnl/tnl/tnlJournal.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** tnlJournal.h 11 May 2004 02:45:26 -0000 1.2 --- tnlJournal.h 11 May 2004 18:26:24 -0000 1.3 *************** *** 77,92 **** struct JournalEntryRecord { const char *mFunctionName; MethodArgList *mMethodArgList; JournalEntryRecord *mNext; ! static JournalEntryRecord *mList; - JournalEntryRecord(const char *functionName, MethodArgList *methodArgList) - { - mFunctionName = functionName; - mMethodArgList = methodArgList; - mNext = mList; - mList = this; - } virtual void getFuncPtr(MethodPointer &m) = 0; }; --- 77,89 ---- struct JournalEntryRecord { + U32 mEntryIndex; const char *mFunctionName; MethodArgList *mMethodArgList; JournalEntryRecord *mNext; ! static Vector<JournalEntryRecord *> *mEntryVector; ! ! JournalEntryRecord(const char *functionName, MethodArgList *methodArgList); ! ~JournalEntryRecord(); virtual void getFuncPtr(MethodPointer &m) = 0; }; Index: journal.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/tnl/journal.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** journal.cpp 11 May 2004 02:45:26 -0000 1.2 --- journal.cpp 11 May 2004 18:26:24 -0000 1.3 *************** *** 31,35 **** { ! JournalEntryRecord *JournalEntryRecord::mList = NULL; bool Journal::mInsideEntrypoint = false; --- 31,35 ---- { ! Vector<JournalEntryRecord *> *JournalEntryRecord::mEntryVector; bool Journal::mInsideEntrypoint = false; *************** *** 42,45 **** --- 42,72 ---- U32 Journal::mWritePosition = 0; + JournalEntryRecord::JournalEntryRecord(const char *functionName, MethodArgList *methodArgList) + { + S32 i; + if(!mEntryVector) + mEntryVector = new Vector<JournalEntryRecord *>; + + for(i = 0; i < mEntryVector->size(); i++) + { + if(strcmp((*mEntryVector)[i]->mFunctionName, functionName) < 0) + break; + } + mEntryVector->insert(i); + (*mEntryVector)[i] = this; + mFunctionName = functionName; + mMethodArgList = methodArgList; + mEntryIndex = 0; + } + + JournalEntryRecord::~JournalEntryRecord() + { + if(mEntryVector) + { + delete mEntryVector; + mEntryVector = NULL; + } + } + Journal::Journal() { *************** *** 72,75 **** --- 99,103 ---- // write the bytes to the file fwrite(mWriteStream.getBuffer(), 1, bytesToWrite, mJournalFile); + fflush(mJournalFile); // adjust the write stream *************** *** 124,130 **** TNLAssert(mInsideEntrypoint == false, "Journal entries cannot be reentrant!"); mInsideEntrypoint = true; if(mCurrentMode == Record) { ! mWriteStream.writeString(funcName); mWriteStream.writeBits(theCall->marshalledData.getBitPosition(), theCall->marshalledData.getBuffer()); syncWriteStream(); --- 152,167 ---- TNLAssert(mInsideEntrypoint == false, "Journal entries cannot be reentrant!"); mInsideEntrypoint = true; + + S32 entryIndex; + for(entryIndex = 0; entryIndex < JournalEntryRecord::mEntryVector->size(); entryIndex++) + { + if(!strcmp((*JournalEntryRecord::mEntryVector)[entryIndex]->mFunctionName, funcName)) + break; + } + TNLAssert(entryIndex != JournalEntryRecord::mEntryVector->size(), "No entry point found!"); + if(mCurrentMode == Record) { ! mWriteStream.writeRangedU32(entryIndex, 0, JournalEntryRecord::mEntryVector->size() - 1); mWriteStream.writeBits(theCall->marshalledData.getBitPosition(), theCall->marshalledData.getBuffer()); syncWriteStream(); *************** *** 133,148 **** BitStream unmarshallData(theCall->marshalledData.getBuffer(), theCall->marshalledData.getBytePosition()); theCall->unmarshall(&unmarshallData); ! for(JournalEntryRecord *walk = JournalEntryRecord::mList; walk; walk = walk->mNext) ! { ! if(!strcmp(walk->mFunctionName, funcName)) ! { ! MethodPointer p; ! walk->getFuncPtr(p); ! theCall->dispatch((void *) this, &p); ! mInsideEntrypoint = false; ! return; ! } ! } ! TNLAssert(0, "No entry point found!"); } --- 170,179 ---- BitStream unmarshallData(theCall->marshalledData.getBuffer(), theCall->marshalledData.getBytePosition()); theCall->unmarshall(&unmarshallData); ! ! JournalEntryRecord *theEntry = (*JournalEntryRecord::mEntryVector)[entryIndex]; ! MethodPointer p; ! theEntry->getFuncPtr(p); ! theCall->dispatch((void *) this, &p); ! mInsideEntrypoint = false; } *************** *** 150,154 **** { if(!mReadStream.isValid() || mReadStream.getBitPosition() == mReadStream.getMaxReadBitPosition()) ! Platform::debugBreak(); } --- 181,185 ---- { if(!mReadStream.isValid() || mReadStream.getBitPosition() == mReadStream.getMaxReadBitPosition()) ! TNL_DEBUGBREAK(); } *************** *** 158,167 **** return; ! char funcName[256]; ! mReadStream.readString(funcName); ! JournalEntryRecord *theEntry; ! for(theEntry = JournalEntryRecord::mList; theEntry; theEntry = theEntry->mNext) ! if(!strcmp(theEntry->mFunctionName, funcName)) ! break; // check for errors... --- 189,195 ---- return; ! U32 index = mReadStream.readRangedU32(0, JournalEntryRecord::mEntryVector->size()); ! ! JournalEntryRecord *theEntry = (*JournalEntryRecord::mEntryVector)[index]; // check for errors... *************** *** 170,174 **** TNLAssert(0, "blech!"); } - checkReadPosition(); MethodPointer p; --- 198,201 ---- *************** *** 176,179 **** --- 203,208 ---- MarshalledCall theCall(theEntry->mMethodArgList); theCall.unmarshall(&mReadStream); + checkReadPosition(); + mInsideEntrypoint = true; theCall.dispatch((void *) this, &p); Index: netInterface.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/tnl/netInterface.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** netInterface.cpp 24 Apr 2004 23:52:33 -0000 1.2 --- netInterface.cpp 11 May 2004 18:26:24 -0000 1.3 *************** *** 320,333 **** mConnectionList[i]->checkPacketSend(false, time); - // check if we're trying to solve any client connection puzzles - for(S32 i = 0; i < mPendingConnections.size(); i++) - { - if(mPendingConnections[i]->getConnectionState() == NetConnection::ComputingPuzzleSolution) - { - continuePuzzleSolution(mPendingConnections[i]); - break; - } - } - if(time > mLastTimeoutCheckTime + TimeoutCheckInterval) { --- 320,323 ---- *************** *** 403,406 **** --- 393,406 ---- } } + + // check if we're trying to solve any client connection puzzles + for(S32 i = 0; i < mPendingConnections.size(); i++) + { + if(mPendingConnections[i]->getConnectionState() == NetConnection::ComputingPuzzleSolution) + { + continuePuzzleSolution(mPendingConnections[i]); + break; + } + } } |
From: Mark F. <mar...@us...> - 2004-05-11 02:45:52
|
Update of /cvsroot/opentnl/tnl/tnl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6106/tnl Modified Files: bitStream.cpp journal.cpp platform.cpp tnlBitStream.h tnlEndian.h tnlJournal.h udp.cpp Log Message: Cleaned up endian file and added swaps for types > 4 bytes Fully implemented journal recording and playback Index: platform.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/tnl/platform.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** platform.cpp 25 Apr 2004 19:08:24 -0000 1.2 --- platform.cpp 11 May 2004 02:45:26 -0000 1.3 *************** *** 27,30 **** --- 27,31 ---- #include "tnlTypes.h" #include "tnl.h" + #include "tnlJournal.h" #include <string.h> *************** *** 73,77 **** U32 Platform::getRealMilliseconds() { ! return GetTickCount(); } --- 74,91 ---- U32 Platform::getRealMilliseconds() { ! U32 tickCount; ! TNL_JOURNAL_READ_BLOCK ! ( ! TNL_JOURNAL_READ( (&tickCount) ); ! return tickCount; ! ) ! ! tickCount = GetTickCount(); ! ! TNL_JOURNAL_WRITE_BLOCK ! ( ! TNL_JOURNAL_WRITE(tickCount); ! ) ! return tickCount; } *************** *** 127,131 **** U32 Platform::getRealMilliseconds() { ! return GetTickCount(); } --- 141,158 ---- U32 Platform::getRealMilliseconds() { ! U32 tickCount; ! TNL_JOURNAL_READ_BLOCK ! ( ! TNL_JOURNAL_READ( (&tickCount) ); ! return tickCount; ! ) ! ! tickCount = GetTickCount(); ! ! TNL_JOURNAL_WRITE_BLOCK ! ( ! TNL_JOURNAL_WRITE( (tickCount) ); ! ) ! return tickCount; } *************** *** 168,177 **** S64 Platform::getHighPrecisionTimerValue() { ! return gTimer.getCurrentTime(); } F64 Platform::getHighPrecisionMilliseconds(S64 timerDelta) { ! return gTimer.convertToMS(timerDelta); } --- 195,232 ---- S64 Platform::getHighPrecisionTimerValue() { ! S64 currentTime; ! TNL_JOURNAL_READ_BLOCK ! ( ! TNL_JOURNAL_READ( (¤tTime) ); ! return currentTime; ! ) ! ! currentTime = gTimer.getCurrentTime(); ! ! TNL_JOURNAL_WRITE_BLOCK ! ( ! TNL_JOURNAL_WRITE( (currentTime) ); ! ) ! ! return currentTime; } F64 Platform::getHighPrecisionMilliseconds(S64 timerDelta) { ! F64 timerValue; ! TNL_JOURNAL_READ_BLOCK ! ( ! TNL_JOURNAL_READ( (&timerValue) ); ! return timerValue; ! ) ! ! timerValue = gTimer.convertToMS(timerDelta); ! ! TNL_JOURNAL_WRITE_BLOCK ! ( ! TNL_JOURNAL_WRITE( (timerValue) ); ! ) ! ! return timerValue; } Index: tnlJournal.h =================================================================== RCS file: /cvsroot/opentnl/tnl/tnl/tnlJournal.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** tnlJournal.h 10 May 2004 22:34:23 -0000 1.1 --- tnlJournal.h 11 May 2004 02:45:26 -0000 1.2 *************** *** 43,50 **** class Journal : public Object { ! FILE *journalFile; ! BitStream readStream; ! BitStream writeStream; public: void record(const char *fileName); void load(const char *fileName); --- 43,63 ---- class Journal : public Object { ! static FILE *mJournalFile; ! static BitStream mReadStream; ! static BitStream mWriteStream; ! static Journal *mJournal; ! static U32 mWritePosition; public: + enum Mode + { + Inactive, + Record, + Playback, + }; + protected: + static Mode mCurrentMode; + static bool mInsideEntrypoint; + public: + Journal(); void record(const char *fileName); void load(const char *fileName); *************** *** 52,55 **** --- 65,76 ---- void callEntry(const char *funcName, MarshalledCall *theCall); void processNextJournalEntry(); + + static Mode getCurrentMode() { return mCurrentMode; } + static Journal *get() { return mJournal; } + static void checkReadPosition(); + static void syncWriteStream(); + static BitStream *getReadStream() { return &mReadStream; } + static BitStream *getWriteStream() { return &mWriteStream; } + static bool isInEntrypoint() { return mInsideEntrypoint; } }; *************** *** 57,66 **** { const char *mFunctionName; JournalEntryRecord *mNext; static JournalEntryRecord *mList; ! JournalEntryRecord(const char *functionName) { mFunctionName = functionName; mNext = mList; mList = this; --- 78,89 ---- { const char *mFunctionName; + MethodArgList *mMethodArgList; JournalEntryRecord *mNext; static JournalEntryRecord *mList; ! JournalEntryRecord(const char *functionName, MethodArgList *methodArgList) { mFunctionName = functionName; + mMethodArgList = methodArgList; mNext = mList; mList = this; *************** *** 83,88 **** if(sizeof(fptr) > sizeof(U32)) m.v2 = *(((U32 *) &fptr) + 1); \ }; \ ! Journal_##className##_##func##_er(const char *name) : JournalEntryRecord(name) {} \ ! } gJournal_##className##_##func##_er(#func); \ void FN_CDECL className::func args { \ SAVE_PARAMS \ --- 106,111 ---- if(sizeof(fptr) > sizeof(U32)) m.v2 = *(((U32 *) &fptr) + 1); \ }; \ ! Journal_##className##_##func##_er(const char *name, MethodArgList *methodArgList) : JournalEntryRecord(name, methodArgList) {} \ ! } gJournal_##className##_##func##_er(#func, &Journal_##className##_##func); \ void FN_CDECL className::func args { \ SAVE_PARAMS \ *************** *** 93,96 **** --- 116,154 ---- void FN_CDECL className::func##_body args + #define TNL_JOURNAL_WRITE_BLOCK(x) \ + { \ + if(TNL::Journal::getCurrentMode() == TNL::Journal::Record && TNL::Journal::isInEntrypoint()) \ + { \ + x \ + } \ + TNL::Journal::syncWriteStream(); \ + } + + class JournalReadChecker + { + public: + ~JournalReadChecker() + { + TNL::Journal::checkReadPosition(); + } + }; + + #define TNL_JOURNAL_READ_BLOCK(x) \ + { \ + if(TNL::Journal::isInEntrypoint()) { \ + TNL::JournalReadChecker dummy; \ + if(TNL::Journal::getCurrentMode() == TNL::Journal::Playback) \ + { \ + x \ + } \ + } \ + } + + #define TNL_JOURNAL_READ(x) \ + TNL::Journal::getReadStream()->read x + + #define TNL_JOURNAL_WRITE(x) \ + TNL::Journal::getWriteStream()->write x + #else #define TNL_DECLARE_JOURNAL_ENTRYPOINT(func, args) \ *************** *** 100,103 **** --- 158,164 ---- void className::func args + #define TNL_JOURNAL_WRITE_BLOCK(x) + #define TNL_JOURNAL_READ_BLOCK(x) + #endif }; Index: udp.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/tnl/udp.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** udp.cpp 20 Apr 2004 22:18:37 -0000 1.2 --- udp.cpp 11 May 2004 02:45:26 -0000 1.3 *************** *** 26,29 **** --- 26,30 ---- #include "tnl.h" + #include "tnlJournal.h" #if defined ( TNL_OS_XBOX ) *************** *** 190,193 **** --- 191,198 ---- Socket::Socket(const Address &bindAddress, U32 sendBufferSize, U32 recvBufferSize, bool acceptsBroadcast, bool nonblockingIO) { + TNL_JOURNAL_READ_BLOCK( + TNL_JOURNAL_READ( (&mPlatformSocket) ); + return; + ) init(); mPlatformSocket = INVALID_SOCKET; *************** *** 266,273 **** --- 271,285 ---- } } + TNL_JOURNAL_WRITE_BLOCK( + TNL_JOURNAL_WRITE( (mPlatformSocket) ); + ) } Socket::~Socket() { + TNL_JOURNAL_READ_BLOCK( + return; + ) + if(mPlatformSocket != INVALID_SOCKET) closesocket(mPlatformSocket); *************** *** 277,280 **** --- 289,296 ---- NetError Socket::sendto(const Address &address, const U8 *buffer, S32 bufferSize) { + TNL_JOURNAL_READ_BLOCK( + return NoError; + ) + if(address.transport != mTransportProtocol) return InvalidPacketProtocol; *************** *** 293,296 **** --- 309,329 ---- NetError Socket::recvfrom(Address *address, U8 *buffer, S32 bufferSize, S32 *outSize) { + TNL_JOURNAL_READ_BLOCK( + bool wouldBlock; + TNL_JOURNAL_READ( (&wouldBlock) ); + if(wouldBlock) + return WouldBlock; + + TNL_JOURNAL_READ( (&address->transport) ); + TNL_JOURNAL_READ( (&address->port) ); + TNL_JOURNAL_READ( (&address->netNum[0]) ); + TNL_JOURNAL_READ( (&address->netNum[1]) ); + TNL_JOURNAL_READ( (&address->netNum[2]) ); + TNL_JOURNAL_READ( (&address->netNum[3]) ); + TNL_JOURNAL_READ( (outSize) ); + TNL_JOURNAL_READ( (*outSize, buffer) ); + return NoError; + ) + SOCKADDR sa; socklen_t addrLen = sizeof(sa); *************** *** 299,307 **** --- 332,357 ---- bytesRead = ::recvfrom(mPlatformSocket, (char *) buffer, bufferSize, 0, &sa, &addrLen); if(bytesRead == SOCKET_ERROR) + { + TNL_JOURNAL_WRITE_BLOCK( + TNL_JOURNAL_WRITE ( (true) ); + ) return WouldBlock; + } SocketToTNLAddress(&sa, address); *outSize = bytesRead; + + TNL_JOURNAL_WRITE_BLOCK( + TNL_JOURNAL_WRITE( (false) ); + TNL_JOURNAL_WRITE( (address->transport) ); + TNL_JOURNAL_WRITE( (address->port) ); + TNL_JOURNAL_WRITE( (address->netNum[0]) ); + TNL_JOURNAL_WRITE( (address->netNum[1]) ); + TNL_JOURNAL_WRITE( (address->netNum[2]) ); + TNL_JOURNAL_WRITE( (address->netNum[3]) ); + TNL_JOURNAL_WRITE( (*outSize) ); + TNL_JOURNAL_WRITE( (*outSize, buffer) ); + ) return NoError; } Index: journal.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/tnl/journal.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** journal.cpp 10 May 2004 22:34:23 -0000 1.1 --- journal.cpp 11 May 2004 02:45:26 -0000 1.2 *************** *** 26,29 **** --- 26,30 ---- #include "tnlJournal.h" + #include "tnlEndian.h" namespace TNL *************** *** 32,37 **** --- 33,134 ---- JournalEntryRecord *JournalEntryRecord::mList = NULL; + bool Journal::mInsideEntrypoint = false; + Journal::Mode Journal::mCurrentMode = Journal::Inactive; + + FILE *Journal::mJournalFile = NULL; + BitStream Journal::mWriteStream; + BitStream Journal::mReadStream; + Journal *Journal::mJournal = NULL; + U32 Journal::mWritePosition = 0; + + Journal::Journal() + { + TNLAssert(mJournal == NULL, "Cannot construct more than one Journal instance."); + mJournal = this; + } + + // the journal stream is written as a single continuous bit stream. + // the first four bytes of the stream are the total number of bits in + // the stream. As a block is written, the bits in the write stream are + // all erased except for those in the last byte, which are moved to the first. + void Journal::syncWriteStream() + { + if(mWriteStream.getBytePosition() == 0) + return; + + U32 totalBits = (mWritePosition << 3) + mWriteStream.getBitPosition(); + + // seek back to the beginning + fseek(mJournalFile, 0, SEEK_SET); + + // write the new total bits + U32 writeBits = convertHostToLEndian(totalBits); + fwrite(&writeBits, 1, sizeof(U32), mJournalFile); + + // seek to the writing position + fseek(mJournalFile, mWritePosition, SEEK_SET); + + U32 bytesToWrite = mWriteStream.getBytePosition(); + // write the bytes to the file + fwrite(mWriteStream.getBuffer(), 1, bytesToWrite, mJournalFile); + + // adjust the write stream + if(totalBits & 7) + { + U8 *buffer = mWriteStream.getBuffer(); + buffer[0] = buffer[bytesToWrite - 1]; + mWriteStream.setBitPosition(totalBits & 7); + mWritePosition += bytesToWrite - 1; + } + else + { + mWritePosition += bytesToWrite; + mWriteStream.setBitPosition(0); + } + } + + void Journal::record(const char *fileName) + { + mJournalFile = fopen(fileName, "wb"); + if(mJournalFile) + { + mCurrentMode = Record; + mWritePosition = sizeof(U32); + } + } + + void Journal::load(const char *fileName) + { + FILE *theJournal = fopen(fileName, "rb"); + if(!theJournal) + return; + + fseek(theJournal, 0, SEEK_END); + U32 fileSize = ftell(theJournal); + fseek(theJournal, 0, SEEK_SET); + + mReadStream.resize(fileSize); + U32 bitCount; + fread(mReadStream.getBuffer(), 1, fileSize, theJournal); + mReadStream.read(&bitCount); + mReadStream.setMaxBitSizes(bitCount); + fclose(theJournal); + mCurrentMode = Playback; + } + void Journal::callEntry(const char *funcName, MarshalledCall *theCall) { + if(mCurrentMode == Playback) + return; + + TNLAssert(mInsideEntrypoint == false, "Journal entries cannot be reentrant!"); + mInsideEntrypoint = true; + if(mCurrentMode == Record) + { + mWriteStream.writeString(funcName); + mWriteStream.writeBits(theCall->marshalledData.getBitPosition(), theCall->marshalledData.getBuffer()); + syncWriteStream(); + } + BitStream unmarshallData(theCall->marshalledData.getBuffer(), theCall->marshalledData.getBytePosition()); theCall->unmarshall(&unmarshallData); *************** *** 43,49 **** --- 140,182 ---- walk->getFuncPtr(p); theCall->dispatch((void *) this, &p); + mInsideEntrypoint = false; return; } } + TNLAssert(0, "No entry point found!"); + } + + void Journal::checkReadPosition() + { + if(!mReadStream.isValid() || mReadStream.getBitPosition() == mReadStream.getMaxReadBitPosition()) + Platform::debugBreak(); + } + + void Journal::processNextJournalEntry() + { + if(mCurrentMode != Playback) + return; + + char funcName[256]; + mReadStream.readString(funcName); + JournalEntryRecord *theEntry; + for(theEntry = JournalEntryRecord::mList; theEntry; theEntry = theEntry->mNext) + if(!strcmp(theEntry->mFunctionName, funcName)) + break; + + // check for errors... + if(!theEntry) + { + TNLAssert(0, "blech!"); + } + checkReadPosition(); + + MethodPointer p; + theEntry->getFuncPtr(p); + MarshalledCall theCall(theEntry->mMethodArgList); + theCall.unmarshall(&mReadStream); + mInsideEntrypoint = true; + theCall.dispatch((void *) this, &p); + mInsideEntrypoint = false; } Index: bitStream.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/tnl/bitStream.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** bitStream.cpp 20 Apr 2004 04:27:18 -0000 1.1 --- bitStream.cpp 11 May 2004 02:45:26 -0000 1.2 *************** *** 42,45 **** --- 42,51 ---- } + void BitStream::setMaxBitSizes(U32 maxReadSize, U32 maxWriteSize) + { + maxReadBitNum = maxReadSize; + maxWriteBitNum = maxWriteSize; + } + void BitStream::reset() { Index: tnlBitStream.h =================================================================== RCS file: /cvsroot/opentnl/tnl/tnl/tnlBitStream.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** tnlBitStream.h 22 Apr 2004 20:42:25 -0000 1.2 --- tnlBitStream.h 11 May 2004 02:45:26 -0000 1.3 *************** *** 97,100 **** --- 97,103 ---- void setMaxSizes(U32 maxReadSize, U32 maxWriteSize = 0); + /// Sets the maximum read and write bit sizes for the BitStream. + void setMaxBitSizes(U32 maxReadBitSize, U32 maxWriteBitSize = 0); + /// resets the read/write position to 0 and clears any error state. void reset(); *************** *** 114,117 **** --- 117,123 ---- void advanceBitPosition(const S32 numBits); + /// Returns the maximum readable bit position + U32 getMaxReadBitPosition() const { return maxReadBitNum; } + /// Pads the bits up to the next byte boundary with 0's. void zeroToByteBoundary(); *************** *** 208,211 **** --- 214,220 ---- bool readFlag(); + bool write(bool value) { writeFlag(value); return !error; } + bool read(bool *value) { *value = readFlag(); return !error; } + /// Writes a huffman compressed string into the stream. void writeString(const char *stringBuf, U8 maxLen=255); *************** *** 228,231 **** --- 237,242 ---- DeclareTemplatizedReadWrite(U32); DeclareTemplatizedReadWrite(S32); + DeclareTemplatizedReadWrite(S64); + DeclareTemplatizedReadWrite(U64); DeclareTemplatizedReadWrite(F32); DeclareTemplatizedReadWrite(F64); Index: tnlEndian.h =================================================================== RCS file: /cvsroot/opentnl/tnl/tnl/tnlEndian.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** tnlEndian.h 7 May 2004 02:21:45 -0000 1.2 --- tnlEndian.h 11 May 2004 02:45:26 -0000 1.3 *************** *** 30,33 **** --- 30,43 ---- namespace TNL { + inline U8 endianSwap(const U8 in_swap) + { + return in_swap; + } + + inline S8 endianSwap(const S8 in_swap) + { + return in_swap; + } + /** Convert the byte ordering on the U16 to and from big/little endian format. *************** *** 35,38 **** --- 45,49 ---- @returns swapped U16. */ + inline U16 endianSwap(const U16 in_swap) { *************** *** 41,44 **** --- 52,60 ---- } + inline S16 endianSwap(const S16 in_swap) + { + return S16(endianSwap(U16(in_swap))); + } + /** Convert the byte ordering on the U32 to and from big/little endian format. *************** *** 54,211 **** } ! //------------------------------------------------------------------------------ ! // Endian conversions ! #ifdef TNL_LITTLE_ENDIAN ! ! inline U8 convertHostToLEndian(U8 i) { return i; } ! inline U8 convertLEndianToHost(U8 i) { return i; } ! inline U16 convertHostToLEndian(U16 i) { return i; } ! inline U16 convertLEndianToHost(U16 i) { return i; } ! inline U32 convertHostToLEndian(U32 i) { return i; } ! inline U32 convertLEndianToHost(U32 i) { return i; } ! inline S8 convertHostToLEndian(S8 i) { return i; } ! inline S8 convertLEndianToHost(S8 i) { return i; } ! inline S16 convertHostToLEndian(S16 i) { return i; } ! inline S16 convertLEndianToHost(S16 i) { return i; } ! inline S32 convertHostToLEndian(S32 i) { return i; } ! inline S32 convertLEndianToHost(S32 i) { return i; } ! ! inline F32 convertHostToLEndian(F32 i) { return i; } ! inline F32 convertLEndianToHost(F32 i) { return i; } ! inline F64 convertHostToLEndian(F64 i) { return i; } ! inline F64 convertLEndianToHost(F64 i) { return i; } ! ! inline U8 convertHostToBEndian(U8 i) { return i; } ! inline U8 convertBEndianToHost(U8 i) { return i; } ! inline S8 convertHostToBEndian(S8 i) { return i; } ! inline S8 convertBEndianToHost(S8 i) { return i; } ! ! inline U16 convertHostToBEndian(U16 i) ! { ! return U16((i << 8) | (i >> 8)); ! } ! ! inline U16 convertBEndianToHost(U16 i) ! { ! return U16((i << 8) | (i >> 8)); ! } ! ! inline S16 convertHostToBEndian(S16 i) { ! return S16(convertHostToBEndian(U16(i))); } ! inline S16 convertBEndianToHost(S16 i) { ! return S16(convertBEndianToHost(U16(i))); } ! inline U32 convertHostToBEndian(U32 i) { ! return ((i << 24) & 0xff000000) | ! ((i << 8) & 0x00ff0000) | ! ((i >> 8) & 0x0000ff00) | ! ((i >> 24) & 0x000000ff); } ! inline U32 convertBEndianToHost(U32 i) { ! return ((i << 24) & 0xff000000) | ! ((i << 8) & 0x00ff0000) | ! ((i >> 8) & 0x0000ff00) | ! ((i >> 24) & 0x000000ff); } ! inline S32 convertHostToBEndian(S32 i) { ! return S32(convertHostToBEndian(U32(i))); } ! inline S32 convertBEndianToHost(S32 i) ! { ! return S32(convertBEndianToHost(S32(i))); ! } #elif defined(TNL_BIG_ENDIAN) ! inline U8 convertHostToBEndian(U8 i) { return i; } ! inline U8 convertBEndianToHost(U8 i) { return i; } ! inline S8 convertHostToBEndian(S8 i) { return i; } ! inline S8 convertBEndianToHost(S8 i) { return i; } ! inline U16 convertHostToBEndian(U16 i) { return i; } ! inline U16 convertBEndianToHost(U16 i) { return i; } ! inline U32 convertHostToBEndian(U32 i) { return i; } ! inline U32 convertBEndianToHost(U32 i) { return i; } ! inline S16 convertHostToBEndian(S16 i) { return i; } ! inline S16 convertBEndianToHost(S16 i) { return i; } ! inline S32 convertHostToBEndian(S32 i) { return i; } ! inline S32 convertBEndianToHost(S32 i) { return i; } ! ! inline U8 convertHostToLEndian(U8 i) { return i; } ! inline U8 convertLEndianToHost(U8 i) { return i; } ! inline S8 convertHostToLEndian(S8 i) { return i; } ! inline S8 convertLEndianToHost(S8 i) { return i; } ! ! inline U16 convertHostToLEndian(U16 i) ! { ! return (i << 8) | (i >> 8); ! } ! inline U16 convertLEndianToHost(U16 i) ! { ! return (i << 8) | (i >> 8); ! } ! inline U32 convertHostToLEndian(U32 i) ! { ! return ((i << 24) & 0xff000000) | ! ((i << 8) & 0x00ff0000) | ! ((i >> 8) & 0x0000ff00) | ! ((i >> 24) & 0x000000ff); ! } ! inline U32 convertLEndianToHost(U32 i) ! { ! return ((i << 24) & 0xff000000) | ! ((i << 8) & 0x00ff0000) | ! ((i >> 8) & 0x0000ff00) | ! ((i >> 24) & 0x000000ff); ! } ! ! ! inline F32 convertHostToLEndian(F32 i) ! { ! U32 result = convertHostToLEndian( *reinterpret_cast<U32*>(&i) ); ! return *reinterpret_cast<F32*>(&result); ! } ! ! inline F32 convertLEndianToHost(F32 i) ! { ! U32 result = convertLEndianToHost( *reinterpret_cast<U32*>(&i) ); ! return *reinterpret_cast<F32*>(&result); ! } ! ! inline F64 convertHostToLEndian(F64 i) ! { ! F64 ret; ! reinterpret_cast<U32 *>(&ret)[0] = ! convertLEndianToHost( reinterpret_cast<U32*>(&i)[1] ); ! reinterpret_cast<U32 *>(&ret)[1] = ! convertLEndianToHost( reinterpret_cast<U32*>(&i)[0] ); ! return ret; ! } ! ! inline F64 convertLEndianToHost(F64 i) ! { ! F64 ret; ! reinterpret_cast<U32 *>(&ret)[0] = ! convertLEndianToHost( reinterpret_cast<U32*>(&i)[1] ); ! reinterpret_cast<U32 *>(&ret)[1] = ! convertLEndianToHost( reinterpret_cast<U32*>(&i)[0] ); ! return ret; ! } ! ! inline S16 convertHostToLEndian(S16 i) { return S16(convertHostToLEndian(U16(i))); } ! inline S16 convertLEndianToHost(S16 i) { return S16(convertLEndianToHost(U16(i))); } ! inline S32 convertHostToLEndian(S32 i) { return S32(convertHostToLEndian(U32(i))); } ! inline S32 convertLEndianToHost(S32 i) { return S32(convertLEndianToHost(U32(i))); } #else --- 70,122 ---- } ! inline S32 endianSwap(const S32 in_swap) { ! return S32(endianSwap(U32(in_swap))); } ! inline U64 endianSwap(const U64 in_swap) { ! U32 *inp = (U32 *) &in_swap; ! U64 ret; ! U32 *outp = (U32 *) &ret; ! outp[0] = endianSwap(inp[1]); ! outp[1] = endianSwap(inp[0]); ! return ret; } ! inline S64 endianSwap(const S64 in_swap) { ! return S64(endianSwap(U64(in_swap))); } ! inline F32 endianSwap(const F32 in_swap) { ! U32 result = endianSwap(* ((U32 *) &in_swap) ); ! return * ((F32 *) &result); } ! inline F64 endianSwap(const F64 in_swap) { ! U64 result = endianSwap(* ((U64 *) &in_swap) ); ! return * ((F64 *) &result); } ! //------------------------------------------------------------------------------ ! // Endian conversions ! #ifdef TNL_LITTLE_ENDIAN + #define TNL_DECLARE_TEMPLATIZED_ENDIAN_CONV(type) \ + inline type convertHostToLEndian(type i) { return i; } \ + inline type convertLEndianToHost(type i) { return i; } \ + inline type convertHostToBEndian(type i) { return endianSwap(i); } \ + inline type convertBEndianToHost(type i) { return endianSwap(i); } #elif defined(TNL_BIG_ENDIAN) ! #define TNL_DECLARE_TEMPLATIZED_ENDIAN_CONV(type) \ ! inline type convertHostToLEndian(type i) { return endianSwap(i); } \ ! inline type convertLEndianToHost(type i) { return endianSwap(i); } \ ! inline type convertHostToBEndian(type i) { return i; } \ ! inline type convertBEndianToHost(type i) { return i; } #else *************** *** 214,217 **** --- 125,139 ---- + TNL_DECLARE_TEMPLATIZED_ENDIAN_CONV(U8) + TNL_DECLARE_TEMPLATIZED_ENDIAN_CONV(S8) + TNL_DECLARE_TEMPLATIZED_ENDIAN_CONV(U16) + TNL_DECLARE_TEMPLATIZED_ENDIAN_CONV(S16) + TNL_DECLARE_TEMPLATIZED_ENDIAN_CONV(U32) + TNL_DECLARE_TEMPLATIZED_ENDIAN_CONV(S32) + TNL_DECLARE_TEMPLATIZED_ENDIAN_CONV(U64) + TNL_DECLARE_TEMPLATIZED_ENDIAN_CONV(S64) + TNL_DECLARE_TEMPLATIZED_ENDIAN_CONV(F32) + TNL_DECLARE_TEMPLATIZED_ENDIAN_CONV(F64) + }; |
From: Mark F. <mar...@us...> - 2004-05-11 02:45:38
|
Update of /cvsroot/opentnl/tnl/zap In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6106/zap Modified Files: main.cpp Log Message: Cleaned up endian file and added swaps for types > 4 bytes Fully implemented journal recording and playback Index: main.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/main.cpp,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** main.cpp 10 May 2004 22:34:24 -0000 1.25 --- main.cpp 11 May 2004 02:45:27 -0000 1.26 *************** *** 70,74 **** TNL_DECLARE_JOURNAL_ENTRYPOINT(specialkey, (S32 key, S32 x, S32 y)); TNL_DECLARE_JOURNAL_ENTRYPOINT(specialkeyup, (S32 key, S32 x, S32 y)); ! TNL_DECLARE_JOURNAL_ENTRYPOINT(idle, ()); TNL_DECLARE_JOURNAL_ENTRYPOINT(display, ()); }; --- 70,74 ---- TNL_DECLARE_JOURNAL_ENTRYPOINT(specialkey, (S32 key, S32 x, S32 y)); TNL_DECLARE_JOURNAL_ENTRYPOINT(specialkeyup, (S32 key, S32 x, S32 y)); ! TNL_DECLARE_JOURNAL_ENTRYPOINT(idle, (U32 timeDelta)); TNL_DECLARE_JOURNAL_ENTRYPOINT(display, ()); }; *************** *** 194,202 **** void idle() { - gZapJournal.idle(); - } - - TNL_IMPLEMENT_JOURNAL_ENTRYPOINT(ZapJournal, idle, ()) - { static S64 lastTimer = Platform::getHighPrecisionTimerValue(); static F64 unusedFraction = 0; --- 194,197 ---- *************** *** 212,223 **** unusedFraction = timeElapsed - integerTime; ! if(UserInterface::current) ! UserInterface::current->idle(integerTime); ! if(gClientGame) ! gClientGame->idle(integerTime); ! if(gServerGame) ! gServerGame->idle(integerTime); ! if(gClientGame) ! glutPostRedisplay(); } --- 207,211 ---- unusedFraction = timeElapsed - integerTime; ! gZapJournal.idle(integerTime); } *************** *** 225,228 **** --- 213,229 ---- // sleep(0) helps reduce the impact of OpenGL on windows. Platform::sleep((gClientGame ? 0 : 1)); + gZapJournal.processNextJournalEntry(); + } + + TNL_IMPLEMENT_JOURNAL_ENTRYPOINT(ZapJournal, idle, (U32 integerTime)) + { + if(UserInterface::current) + UserInterface::current->idle(integerTime); + if(gClientGame) + gClientGame->idle(integerTime); + if(gServerGame) + gServerGame->idle(integerTime); + if(gClientGame) + glutPostRedisplay(); } *************** *** 393,396 **** --- 394,407 ---- gJoystickType = atoi(argv[i+1]); } + else if(!stricmp(argv[i], "-jsave")) + { + if(hasAdditionalArg) + gZapJournal.record(argv[i+1]); + } + else if(!stricmp(argv[i], "-jplay")) + { + if(hasAdditionalArg) + gZapJournal.load(argv[i+1]); + } else if(!stricmp(argv[i], "-gain")) { |