gcblue-commits Mailing List for Global Conflict Blue (Page 58)
Status: Alpha
Brought to you by:
ddcforge
You can subscribe to this list here.
| 2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(6) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2004 |
Jan
(112) |
Feb
(106) |
Mar
(88) |
Apr
(111) |
May
(53) |
Jun
(60) |
Jul
(58) |
Aug
(61) |
Sep
(45) |
Oct
(31) |
Nov
(71) |
Dec
(70) |
| 2005 |
Jan
(33) |
Feb
(57) |
Mar
(98) |
Apr
(47) |
May
(53) |
Jun
(79) |
Jul
(79) |
Aug
|
Sep
(33) |
Oct
(1) |
Nov
(20) |
Dec
(64) |
| 2006 |
Jan
(20) |
Feb
(1) |
Mar
(43) |
Apr
(11) |
May
(8) |
Jun
(23) |
Jul
|
Aug
(28) |
Sep
(58) |
Oct
(25) |
Nov
(47) |
Dec
(70) |
|
From: Dewitt C. <ddc...@us...> - 2004-04-09 03:21:22
|
Update of /cvsroot/gcblue/gcb_wx/docs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12869/docs Modified Files: CHANGES.txt Log Message: multiplayer related changes Index: CHANGES.txt =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/docs/CHANGES.txt,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** CHANGES.txt 7 Apr 2004 00:41:07 -0000 1.10 --- CHANGES.txt 9 Apr 2004 03:08:06 -0000 1.11 *************** *** 3,6 **** --- 3,11 ---- 0.6 --------------------------------------------------------------------- + *** 2004-04-09 Dewitt Colclough *** + - Added client-mode to simstate update + - /startgame server command now starts the client's game + - Started to update object serialization to support multiplayer + *** 2004-04-06 Dewitt Colclough *** - Added a few test server commands via multiplayer console |
|
From: Dewitt C. <ddc...@us...> - 2004-04-09 03:21:22
|
Update of /cvsroot/gcblue/gcb_wx/include/database In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12869/include/database Modified Files: tcDBString.h Log Message: multiplayer related changes Index: tcDBString.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/database/tcDBString.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** tcDBString.h 28 Mar 2004 18:44:29 -0000 1.2 --- tcDBString.h 9 Apr 2004 03:08:07 -0000 1.3 *************** *** 30,34 **** #include "tcString.h" // CString replacement #include "tcFile.h" // tcFile replacement ! #include "tcFile.h" --- 30,34 ---- #include "tcString.h" // CString replacement #include "tcFile.h" // tcFile replacement ! #include <sstream> #include "tcFile.h" *************** *** 48,51 **** --- 48,54 ---- int operator== (tcDBString&); void operator= (const char *s); + + std::stringstream& operator<<(std::stringstream& buffer); + std::stringstream& operator>>(std::stringstream& buffer); int Serialize(tcFile& file, bool mbLoad); tcDBString(); |
|
From: Dewitt C. <ddc...@us...> - 2004-04-09 03:21:21
|
Update of /cvsroot/gcblue/gcb_wx/include/common In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12869/include/common Modified Files: simmath.h Log Message: multiplayer related changes Index: simmath.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/common/simmath.h,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** simmath.h 3 Apr 2004 15:39:31 -0000 1.10 --- simmath.h 9 Apr 2004 03:08:07 -0000 1.11 *************** *** 31,34 **** --- 31,35 ---- #include "gctypes.h" #include "tcDatabaseObject.h" + #include <sstream> #ifndef UINT8 *************** *** 178,181 **** --- 179,184 ---- void GetInterceptData3D(const tcTrack& track, float& rfHeading_rad, float& rfClimbAngle_rad, float& rfTimeToIntercept, float& rfRange_rad); + void LoadFromStream(std::stringstream& buffer); + void SaveToStream(std::stringstream& buffer); void Serialize(tcFile& file, bool abLoad); void SetRelativeGeo(tsGeoPoint& rpGeoPoint, float afBearing_rad, float afRange_km); |
|
From: Dewitt C. <ddc...@us...> - 2004-04-07 00:54:02
|
Update of /cvsroot/gcblue/gcb_wx/src/sim In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25434/src/sim Modified Files: Game.cpp tcNetworkView.cpp tcSimState.cpp Log Message: Index: tcSimState.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcSimState.cpp,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** tcSimState.cpp 21 Mar 2004 21:03:27 -0000 1.36 --- tcSimState.cpp 7 Apr 2004 00:41:08 -0000 1.37 *************** *** 48,51 **** --- 48,61 ---- /***************************************** tcSimState *******************************/ + /** + * @return singleton instance + */ + tcSimState* tcSimState::Get() + { + static tcSimState instance; + return &instance; + } + + void tcSimState::ChangeHeadingToLocation(long anKey, float afLon, float afLat) { Index: tcNetworkView.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcNetworkView.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** tcNetworkView.cpp 5 Apr 2004 02:24:29 -0000 1.9 --- tcNetworkView.cpp 7 Apr 2004 00:41:08 -0000 1.10 *************** *** 1,5 **** /** tcNetworkView.cpp */ /* ! ** Copyright (C) 2003 Dewitt "Cole" Colclough (de...@tw...) ** All rights reserved. --- 1,5 ---- /** tcNetworkView.cpp */ /* ! ** Copyright (C) 2003-2004 Dewitt "Cole" Colclough (de...@tw...) ** All rights reserved. *************** *** 58,62 **** Erase(); ! if (!GetGraphics(pGraphics)) { return false; } --- 58,63 ---- Erase(); ! if (!GetGraphics(pGraphics)) ! { return false; } *************** *** 121,127 **** void tcNetworkView::SendChatText(wxCommandEvent& event) { std::string chatText = event.GetString().c_str(); ! unsigned nConnections = tcMultiplayerInterface::Get()->GetNumConnections(); for (unsigned n=0;n<nConnections;n++) --- 122,146 ---- void tcNetworkView::SendChatText(wxCommandEvent& event) { + tcMultiplayerInterface* multiplayerInterface = tcMultiplayerInterface::Get(); + + bool isServer = multiplayerInterface->IsServer(); std::string chatText = event.GetString().c_str(); ! if (isServer && (multiplayerInterface->IsCommand(chatText))) ! { ! chatBox->Print(chatText.c_str()); ! multiplayerInterface->ProcessCommandServer(chatText); ! return; ! } ! ! /* prepend name tag if server, this is done for clients by server, server has ! ** to do tagging itself */ ! if (isServer) ! { ! chatText = std::string("<") + multiplayerInterface->GetName() + ! std::string("> ") + chatText; ! } ! ! unsigned nConnections = multiplayerInterface->GetNumConnections(); for (unsigned n=0;n<nConnections;n++) *************** *** 131,136 **** } // if server, print chat text locally since no echo comes back ! if (tcMultiplayerInterface::Get()->IsServer()) { chatBox->Print(chatText.c_str()); --- 150,156 ---- } + // if server, print chat text locally since no echo comes back ! if (isServer) { chatBox->Print(chatText.c_str()); Index: Game.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/Game.cpp,v retrieving revision 1.73 retrieving revision 1.74 diff -C2 -d -r1.73 -r1.74 *** Game.cpp 5 Apr 2004 02:24:29 -0000 1.73 --- Game.cpp 7 Apr 2004 00:41:08 -0000 1.74 *************** *** 1,20 **** ! /** @file Game.cpp main application class */ ! /** ! * Copyright (C) 2003 Dewitt "Cole" Colclough (de...@tw...) ! * All rights reserved. ! * ! * This file is part of the Global Conflict Blue (GCB) program. ! * GCB is free software; you can redistribute it and/or modify ! * it under the terms of version 2 of the GNU General Public License as ! * published by the Free Software Foundation. ! * ! * GCB is distributed in the hope that it will be useful, ! * but WITHOUT ANY WARRANTY; without even the implied warranty of ! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! * GNU General Public License for more details. ! * ! * You should have received a copy of the GNU General Public License ! * along with GCB; if not, write to the Free Software ! * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ --- 1,20 ---- ! /** @file Game.cpp main application class ! ** ! ** Copyright (C) 2003 Dewitt "Cole" Colclough (de...@tw...) ! ** All rights reserved. ! ** ! ** This file is part of the Global Conflict Blue (GCB) program. ! ** GCB is free software; you can redistribute it and/or modify ! ** it under the terms of version 2 of the GNU General Public License as ! ** published by the Free Software Foundation. ! ** ! ** GCB is distributed in the hope that it will be useful, ! ** but WITHOUT ANY WARRANTY; without even the implied warranty of ! ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! ** GNU General Public License for more details. ! ** ! ** You should have received a copy of the GNU General Public License ! ** along with GCB; if not, write to the Free Software ! ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ *************** *** 111,119 **** Show(FALSE); glCanvas = new wxGLCanvas(this, -1, wxPoint(0,0), size, 0, "GLCanvas", 0, wxNullPalette); glCanvas->SetBackgroundColour(*wxBLACK); pythonInterface = new tcSimPythonInterface(); ! goalTracker = mcSimState.GetGoalTracker(); mcOptions.Init(); --- 111,121 ---- Show(FALSE); + simState = tcSimState::Get(); + glCanvas = new wxGLCanvas(this, -1, wxPoint(0,0), size, 0, "GLCanvas", 0, wxNullPalette); glCanvas->SetBackgroundColour(*wxBLACK); pythonInterface = new tcSimPythonInterface(); ! goalTracker = simState->GetGoalTracker(); mcOptions.Init(); *************** *** 218,222 **** UninitGame(); ! mcSimState.RandInit(); // generate new random scenario // reset time --- 220,224 ---- UninitGame(); ! simState->RandInit(); // generate new random scenario // reset time *************** *** 397,407 **** tcGameObject::SetGameObjectDatabase(&mcDatabase); // added to allow objects to init themselves ! mcSimState.AttachDB(&mcDatabase); ! mcSimState.AttachMapData(&mcMapData); ! mcSimState.AttachPythonInterface(pythonInterface); ! mcSimState.AttachUserInfo(&mcUserInfo); pythonInterface->AttachMapData(&mcMapData); ! pythonInterface->AttachSimState(&mcSimState); tcLauncherState::mpDatabase = &mcDatabase; --- 399,409 ---- tcGameObject::SetGameObjectDatabase(&mcDatabase); // added to allow objects to init themselves ! simState->AttachDB(&mcDatabase); ! simState->AttachMapData(&mcMapData); ! simState->AttachPythonInterface(pythonInterface); ! simState->AttachUserInfo(&mcUserInfo); pythonInterface->AttachMapData(&mcMapData); ! pythonInterface->AttachSimState(simState); tcLauncherState::mpDatabase = &mcDatabase; *************** *** 426,430 **** /* ** Miscellaneous startup * **/ ! mcSimState.RandInit(); meGameMode = GM_START; --- 428,432 ---- /* ** Miscellaneous startup * **/ ! simState->RandInit(); meGameMode = GM_START; *************** *** 626,630 **** wxPoint(0,0), frameSize, "ScenarioSelect", startView); ! scenarioSelectView->AttachSimState(&mcSimState); scenarioSelectView->LoadBackgroundImage("start_background.jpg"); --- 628,632 ---- wxPoint(0,0), frameSize, "ScenarioSelect", startView); ! scenarioSelectView->AttachSimState(simState); scenarioSelectView->LoadBackgroundImage("start_background.jpg"); *************** *** 698,702 **** hookInfo->LoadBackgroundImage("console_b.jpg"); ! hookInfo->AttachSimState(&mcSimState); hookInfo->AttachOptions(&mcOptions); hookInfo->AttachUserInfo(&mcUserInfo); --- 700,704 ---- hookInfo->LoadBackgroundImage("console_b.jpg"); ! hookInfo->AttachSimState(simState); hookInfo->AttachOptions(&mcOptions); hookInfo->AttachUserInfo(&mcUserInfo); *************** *** 717,721 **** objectControl->AttachCommandInterface(&mcCommandQueue); ! objectControl->AttachSimState(&mcSimState); objectControl->AttachOptions(&mcOptions); objectControl->AttachUserInfo(&mcUserInfo); --- 719,723 ---- objectControl->AttachCommandInterface(&mcCommandQueue); ! objectControl->AttachSimState(simState); objectControl->AttachOptions(&mcOptions); objectControl->AttachUserInfo(&mcUserInfo); *************** *** 739,743 **** oobView->AttachMapView(tacticalMap); ! oobView->AttachSimState(&mcSimState); oobView->mnAlliance = mcUserInfo.GetOwnAlliance(); // TODO: make this configurable oobView->SetSkipCount(mcOptions.renderSkipCount); --- 741,745 ---- oobView->AttachMapView(tacticalMap); ! oobView->AttachSimState(simState); oobView->mnAlliance = mcUserInfo.GetOwnAlliance(); // TODO: make this configurable oobView->SetSkipCount(mcOptions.renderSkipCount); *************** *** 839,860 **** tcString s; ! mcSimState.AttachMapData(&mcMapData); ! mcSimState.AttachPythonInterface(pythonInterface); ! mcSimState.AttachUserInfo(&mcUserInfo); ! mcSimState.AttachCommandInterface(&mcCommandQueue); ! s.Format("Starting scenario: %s",mcSimState.msScenarioInfo.mzName); ConsoleMessage(s.GetBuffer()); ! mcSimState.PrintToFile("log\\simstate_text.txt"); wxASSERT(infoConsole); wxASSERT(director); pythonInterface->AttachConsole(infoConsole); ! pythonInterface->AttachSensorMap(mcSimState.mcSensorMap.GetMap(mcUserInfo.GetOwnAlliance())); pythonInterface->AttachCommandQueue(&mcCommandQueue); ! mcGameView.AttachSimState(&mcSimState); mcGameView.AttachMapView(tacticalMap); mcGameView.AttachUserInfo(&mcUserInfo); --- 841,862 ---- tcString s; ! simState->AttachMapData(&mcMapData); ! simState->AttachPythonInterface(pythonInterface); ! simState->AttachUserInfo(&mcUserInfo); ! simState->AttachCommandInterface(&mcCommandQueue); ! s.Format("Starting scenario: %s",simState->msScenarioInfo.mzName); ConsoleMessage(s.GetBuffer()); ! simState->PrintToFile("log\\simstate_text.txt"); wxASSERT(infoConsole); wxASSERT(director); pythonInterface->AttachConsole(infoConsole); ! pythonInterface->AttachSensorMap(simState->mcSensorMap.GetMap(mcUserInfo.GetOwnAlliance())); pythonInterface->AttachCommandQueue(&mcCommandQueue); ! mcGameView.AttachSimState(simState); mcGameView.AttachMapView(tacticalMap); mcGameView.AttachUserInfo(&mcUserInfo); *************** *** 862,866 **** mcGameView.AttachObjectControl(objectControl); ! viewer->AttachSimState(&mcSimState); viewer->AttachMapData(&mcMapData); --- 864,868 ---- mcGameView.AttachObjectControl(objectControl); ! viewer->AttachSimState(simState); viewer->AttachMapData(&mcMapData); *************** *** 877,881 **** void tcGame::SaveScenario(char *azFilePath) { ! if (mcSimState.Serialize(azFilePath,false) == false) { if (!DirectoryExists(SCENARIO_PATH)) --- 879,883 ---- void tcGame::SaveScenario(char *azFilePath) { ! if (simState->Serialize(azFilePath,false) == false) { if (!DirectoryExists(SCENARIO_PATH)) *************** *** 883,887 **** _mkdir(SCENARIO_PATH); ! if(mcSimState.Serialize(azFilePath,false)==false) { WTLC("Failed to save scenario file"); --- 885,889 ---- _mkdir(SCENARIO_PATH); ! if(simState->Serialize(azFilePath,false)==false) { WTLC("Failed to save scenario file"); *************** *** 976,982 **** { DateZulu dz; ! mcSimState.GetDateZulu(dz); dz.addTime(delta_s); ! mcSimState.SetDateTime(dz); } --- 978,984 ---- { DateZulu dz; ! simState->GetDateZulu(dz); dz.addTime(delta_s); ! simState->SetDateTime(dz); } *************** *** 1010,1014 **** tcMultiplayerInterface::Get()->Update(); ! startView->mbPlayEnabled = mcSimState.msScenarioInfo.mbLoaded; if (meScreenMode != lastMode) --- 1012,1016 ---- tcMultiplayerInterface::Get()->Update(); ! startView->mbPlayEnabled = simState->msScenarioInfo.mbLoaded; if (meScreenMode != lastMode) *************** *** 1228,1249 **** if ((nPerformanceCount.QuadPart-nLastCount) >= ndt) { ! mcSimState.Update(); ! gameTime = mcSimState.GetTime(); ! mcSimState.GetDateZulu(gameDateZulu); if (!mbPaused) { gameTime += fdt; gameDateZulu.addTime(fdt*dateZuluScale); ! mcSimState.SetTime(gameTime); ! mcSimState.SetDateTime(gameDateZulu); if (accelerateTime) { for (int step=0;step<accelerateTime;step++) { ! mcSimState.Update(); gameTime += fdt; gameDateZulu.addTime(fdt*dateZuluScale); ! mcSimState.SetTime(gameTime); ! mcSimState.SetDateTime(gameDateZulu); } } --- 1230,1251 ---- if ((nPerformanceCount.QuadPart-nLastCount) >= ndt) { ! simState->Update(); ! gameTime = simState->GetTime(); ! simState->GetDateZulu(gameDateZulu); if (!mbPaused) { gameTime += fdt; gameDateZulu.addTime(fdt*dateZuluScale); ! simState->SetTime(gameTime); ! simState->SetDateTime(gameDateZulu); if (accelerateTime) { for (int step=0;step<accelerateTime;step++) { ! simState->Update(); gameTime += fdt; gameDateZulu.addTime(fdt*dateZuluScale); ! simState->SetTime(gameTime); ! simState->SetDateTime(gameDateZulu); } } *************** *** 1429,1433 **** // check alliance UINT nAlliance; ! mcSimState.GetPlatformAlliance(hookID, nAlliance); if ((mcUserInfo.IsOwnAlliance(nAlliance))||(mcOptions.mnCommandMode == 0)) --- 1431,1435 ---- // check alliance UINT nAlliance; ! simState->GetPlatformAlliance(hookID, nAlliance); if ((mcUserInfo.IsOwnAlliance(nAlliance))||(mcOptions.mnCommandMode == 0)) *************** *** 1985,1995 **** case GC_RESETMAP: WTL("tcGame::ProcessCommand GC_RESETMAP"); ! mcSimState.DeleteAllPlatforms(); ! mcSimState.ClearSensorMaps(); ! mcSimState.RandInit(); break; case GC_ADDRANDPLAT: WTL("tcGame::ProcessCommand GC_ADDRANDPLAT"); ! mcSimState.AddRandomPlatform(); break; case GC_SAVESCEN: --- 1987,1997 ---- case GC_RESETMAP: WTL("tcGame::ProcessCommand GC_RESETMAP"); ! simState->DeleteAllPlatforms(); ! simState->ClearSensorMaps(); ! simState->RandInit(); break; case GC_ADDRANDPLAT: WTL("tcGame::ProcessCommand GC_ADDRANDPLAT"); ! simState->AddRandomPlatform(); break; case GC_SAVESCEN: *************** *** 2020,2036 **** WTL("tcGame::ProcessCommand PC_CHANGEHEADING"); if (mbScenarioEdit) { ! mcSimState.ChangeHeadingForced(tacticalMap->mnHookID,afData); } else { ! mcSimState.ChangeHeading(tacticalMap->mnHookID,afData); } break; case PC_HALFSPEED: WTL("tcGame::ProcessCommand PC_HALFSPEED"); ! mcSimState.ChangeNormSpeed(tacticalMap->mnHookID,0.5f); break; case PC_FULLSPEED: WTL("tcGame::ProcessCommand PC_FULLSPEED"); ! mcSimState.ChangeNormSpeed(tacticalMap->mnHookID,1.0f); break; case PC_GETNEWTARGET: --- 2022,2038 ---- WTL("tcGame::ProcessCommand PC_CHANGEHEADING"); if (mbScenarioEdit) { ! simState->ChangeHeadingForced(tacticalMap->mnHookID,afData); } else { ! simState->ChangeHeading(tacticalMap->mnHookID,afData); } break; case PC_HALFSPEED: WTL("tcGame::ProcessCommand PC_HALFSPEED"); ! simState->ChangeNormSpeed(tacticalMap->mnHookID,0.5f); break; case PC_FULLSPEED: WTL("tcGame::ProcessCommand PC_FULLSPEED"); ! simState->ChangeNormSpeed(tacticalMap->mnHookID,1.0f); break; case PC_GETNEWTARGET: *************** *** 2050,2057 **** tacticalMap->GetMapCmdDatum(p); if (seMode == PLATFORM_TARGET) { ! mcSimState.DesignateTarget(tacticalMap->mnHookID,anData); } else { ! if (mcSimState.DesignateLauncherTarget(tacticalMap->mnHookID,anData,snData2)==false) { tcSound::Get()->PlayEffect(SEFFECT_REJECTBEEP); // failed, repeat command --- 2052,2059 ---- tacticalMap->GetMapCmdDatum(p); if (seMode == PLATFORM_TARGET) { ! simState->DesignateTarget(tacticalMap->mnHookID,anData); } else { ! if (simState->DesignateLauncherTarget(tacticalMap->mnHookID,anData,snData2)==false) { tcSound::Get()->PlayEffect(SEFFECT_REJECTBEEP); // failed, repeat command *************** *** 2079,2089 **** tacticalMap->GetMapCmdDatum(p); if (seMode == PLATFORM_LOCATION) { ! mcSimState.ChangeLocation(tacticalMap->mnHookID,p.x,p.y); } else if (seMode == PLATFORM_DATUM) { ! mcSimState.DesignateDatum(tacticalMap->mnHookID,p); } else { ! mcSimState.DesignateLauncherDatum(tacticalMap->mnHookID,p,snData2); } } --- 2081,2091 ---- tacticalMap->GetMapCmdDatum(p); if (seMode == PLATFORM_LOCATION) { ! simState->ChangeLocation(tacticalMap->mnHookID,p.x,p.y); } else if (seMode == PLATFORM_DATUM) { ! simState->DesignateDatum(tacticalMap->mnHookID,p); } else { ! simState->DesignateLauncherDatum(tacticalMap->mnHookID,p,snData2); } } *************** *** 2091,2105 **** case PC_LAUNCH: WTL("tcGame::ProcessCommand PC_LAUNCH"); ! if (mcSimState.IsLauncherReady(tacticalMap->mnHookID,0)) { ! mcSimState.RequestLaunch(tacticalMap->mnHookID,0); } ! else if (mcSimState.IsLauncherReady(tacticalMap->mnHookID,1)) { ! mcSimState.RequestLaunch(tacticalMap->mnHookID,1); } ! else if (mcSimState.IsLauncherReady(tacticalMap->mnHookID,2)) { ! mcSimState.RequestLaunch(tacticalMap->mnHookID,2); } ! else if (mcSimState.IsLauncherReady(tacticalMap->mnHookID,3)) { ! mcSimState.RequestLaunch(tacticalMap->mnHookID,3); } else { --- 2093,2107 ---- case PC_LAUNCH: WTL("tcGame::ProcessCommand PC_LAUNCH"); ! if (simState->IsLauncherReady(tacticalMap->mnHookID,0)) { ! simState->RequestLaunch(tacticalMap->mnHookID,0); } ! else if (simState->IsLauncherReady(tacticalMap->mnHookID,1)) { ! simState->RequestLaunch(tacticalMap->mnHookID,1); } ! else if (simState->IsLauncherReady(tacticalMap->mnHookID,2)) { ! simState->RequestLaunch(tacticalMap->mnHookID,2); } ! else if (simState->IsLauncherReady(tacticalMap->mnHookID,3)) { ! simState->RequestLaunch(tacticalMap->mnHookID,3); } else { *************** *** 2110,2114 **** case PC_DELETE: WTL("tcGame::ProcessCommand PC_DELETE"); ! mcSimState.DeletePlatform(tacticalMap->mnHookID); tacticalMap->mnHookID = NULL_INDEX; mcHook.SetHookID(NULL_INDEX); --- 2112,2116 ---- case PC_DELETE: WTL("tcGame::ProcessCommand PC_DELETE"); ! simState->DeletePlatform(tacticalMap->mnHookID); tacticalMap->mnHookID = NULL_INDEX; mcHook.SetHookID(NULL_INDEX); |
Update of /cvsroot/gcblue/gcb_wx/src/network In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25434/src/network Modified Files: tcMultiplayerInterface.cpp tcNetworkInterface.cpp Added Files: tcControlMessageHandler.cpp tcMessageHandler.cpp tcTextMessageHandler.cpp Removed Files: tcChatMessageHandler.cpp Log Message: --- NEW FILE: tcMessageHandler.cpp --- /** * Copyright (C) 2004 Dewitt "Cole" Colclough (de...@tw...) * All rights reserved. * * This file is part of the Global Conflict Blue (GCB) program. * GCB is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as * published by the Free Software Foundation. * * GCB is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GCB; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /** @file tcMessageHandler.cpp */ #include "network/tcMessageHandler.h" BEGIN_NAMESPACE(network) bool tcMessageHandler::isServer = false; void tcMessageHandler::SetAsServer() { isServer = true; } void tcMessageHandler::SetAsClient() { isServer = false; } END_NAMESPACE --- tcChatMessageHandler.cpp DELETED --- --- NEW FILE: tcControlMessageHandler.cpp --- /** * @file tcControlMessageHandler.cpp * * Copyright (C) 2004 Dewitt "Cole" Colclough (de...@tw...) * All rights reserved. * * This file is part of the Global Conflict Blue (GCB) program. * GCB is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as * published by the Free Software Foundation. * * GCB is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GCB; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "stdwx.h" // precompiled header file #ifndef WX_PRECOMP #include "wx/wx.h" #endif #include "wx/string.h" #include "network/tcControlMessageHandler.h" #include "network/tcMultiplayerInterface.h" BEGIN_NAMESPACE(network) void tcControlMessageHandler::CreateControlMessage(int messageCode, unsigned& messageSize, unsigned char *data) { switch (messageCode) { case CM_BEEP: case CM_STARTGAME: { messageSize = sizeof(messageCode); memcpy(data, &messageCode, messageSize); return; } break; default: { fprintf(stderr, "tcControlMessageHandler::CreateControlMessage - unrecognized message code\n"); break; } } } void tcControlMessageHandler::Handle(int connectionId, unsigned messageSize, const unsigned char *data) { // server ignores control messages if (isServer) { fprintf(stderr, "Warning - control message received by server\n"); return; } int messageCode; if (messageSize <= sizeof(messageCode)) { fprintf(stderr, "Warning - Empty or short control message received by server\n"); return; } memcpy(&messageCode, data, sizeof(messageCode)); wxMessageBox(wxString::Format("Received control message %d", messageCode), "Msg received", wxOK); } tcControlMessageHandler::tcControlMessageHandler() { } tcControlMessageHandler::~tcControlMessageHandler() { } END_NAMESPACE --- NEW FILE: tcTextMessageHandler.cpp --- /** * Copyright (C) 2004 Dewitt "Cole" Colclough (de...@tw...) * All rights reserved. * * This file is part of the Global Conflict Blue (GCB) program. * GCB is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as * published by the Free Software Foundation. * * GCB is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GCB; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /** @file tcTextMessageHandler.cpp */ #include "network/tcTextMessageHandler.h" #include "network/tcMultiplayerInterface.h" BEGIN_NAMESPACE(network) /** * Creates text message. * @param maxSize maximum size of string to send not including terminating null */ void tcTextMessageHandler::CreateMessage(unsigned& messageSize, unsigned char *data, std::string text, unsigned maxSize) { messageSize = (unsigned int)text.length(); if (messageSize > maxSize) messageSize = maxSize; strncpy((char*)data, text.c_str(), messageSize); data[messageSize++] = 0; // append terminating null } void tcTextMessageHandler::Handle(int connectionId, unsigned messageSize, const unsigned char *data) { std::string text((char*)data); tcMultiplayerInterface* multiplayerInterface = tcMultiplayerInterface::Get(); if (multiplayerInterface->IsServer()) { // create string with name prepended to text to identify source tcPlayerStatus pstatus = multiplayerInterface->GetPlayerStatus(connectionId); std::string namedText = std::string("<") + pstatus.name + std::string("> ") + text; // check if this is a text command if (multiplayerInterface->IsCommand(text)) { multiplayerInterface->ProcessCommandClient(connectionId, text); } else { // broadcast chat text to all clients unsigned nConn = multiplayerInterface->GetNumConnections(); for (unsigned n=0;n<nConn;n++) { int connId = multiplayerInterface->GetConnectionId(n); multiplayerInterface->SendChatText(connId, namedText); } } text = namedText; } chatText.push(text); } tcTextMessageHandler::tcTextMessageHandler(std::queue<std::string>& _chatText) : chatText(_chatText) { } tcTextMessageHandler::~tcTextMessageHandler() { } END_NAMESPACE Index: tcMultiplayerInterface.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/network/tcMultiplayerInterface.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** tcMultiplayerInterface.cpp 5 Apr 2004 02:24:29 -0000 1.4 --- tcMultiplayerInterface.cpp 7 Apr 2004 00:41:08 -0000 1.5 *************** *** 1,6 **** ! /** @file tcNetworkInterface.cpp */ ! /** tcMultiplayerInterface.cpp */ ! /* ! ** Copyright (C) 2003 Dewitt "Cole" Colclough (de...@tw...) ** All rights reserved. --- 1,5 ---- ! /** @file tcMultiplayerInterface.cpp ! ** ! ** Copyright (C) 2003-2004 Dewitt "Cole" Colclough (de...@tw...) ** All rights reserved. *************** *** 29,33 **** #include "network/tcMultiplayerInterface.h" #include "network/tcMessageHandler.h" ! #include "network/tcChatMessageHandler.h" #include <iostream> #include <queue> --- 28,33 ---- #include "network/tcMultiplayerInterface.h" #include "network/tcMessageHandler.h" ! #include "network/tcTextMessageHandler.h" ! #include "network/tcControlMessageHandler.h" #include <iostream> #include <queue> *************** *** 72,75 **** --- 72,90 ---- /** + * Broadcast control message to all connected clients + */ + void tcMultiplayerInterface::BroadcastControlMessage(int messageCode) + { + unsigned nConnections = GetNumConnections(); + + for (unsigned n=0;n<nConnections;n++) + { + int connId = GetConnectionId(n); + SendControlMessage(connId, messageCode); + } + + } + + /** * Clears messageMap, deleting all message handlers */ *************** *** 114,117 **** --- 129,140 ---- } + /** + * @return identification name string for player using this interface + */ + std::string tcMultiplayerInterface::GetName() const + { + return myName; + } + unsigned tcMultiplayerInterface::GetNumConnections() { *************** *** 119,122 **** --- 142,186 ---- } + /** + * @return tcPlayerStatus object associated with connectionId + * @see tcPlayerStatus + */ + tcPlayerStatus& tcMultiplayerInterface::GetPlayerStatus(int connectionId) + { + std::map<int,tcPlayerStatus>::iterator mapIter; + + mapIter = playerInfo.find(connectionId); + if (mapIter == playerInfo.end()) + { + fprintf(stderr, "Error - tcMultiplayerInterface::GetPlayerStatus - " + "conn id: %d not found\n", connectionId); + return errorPlayerStatus; + } + + return mapIter->second; + } + + /** + * Clear message map and (re)initialize based on + * multiplayer mode. + */ + void tcMultiplayerInterface::InitMessageHandlers() + { + ClearMessageMap(); + + // common handlers + // register chat text message handler + AddMessageHandler(MSG_CHATTEXT, new tcTextMessageHandler(chatText)); + AddMessageHandler(MSG_CONTROL, new tcControlMessageHandler()); + + if (IsServer()) + { // server-specific handlers + } + else + { // client-specific handlers + + } + } + bool tcMultiplayerInterface::IsChatTextAvail() { *************** *** 124,127 **** --- 188,202 ---- } + /** + * Tests if text is a command. Commands start with a + * forward slash '/' + * @return true if text is a (server) command + */ + bool tcMultiplayerInterface::IsCommand(std::string text) + { + wxString candidate(text.c_str()); + return ((candidate.find('/') == 0)); + } + bool tcMultiplayerInterface::IsNewPlayer(int id) { *************** *** 150,153 **** --- 225,230 ---- { networkInterface->MakeClient(); + tcMessageHandler::SetAsClient(); + InitMessageHandlers(); } *************** *** 155,158 **** --- 232,237 ---- { networkInterface->MakeServer(); + tcMessageHandler::SetAsServer(); + InitMessageHandlers(); } *************** *** 178,181 **** --- 257,339 ---- } + + + /** + * Process client command + * text commands start with a forward slash '/' + * @return string to send back to client + */ + void tcMultiplayerInterface::ProcessCommandClient(int connectionId, std::string text) + { + wxString candidate(text.c_str()); + + SendChatText(connectionId, text); + + wxString commandLine = candidate.AfterFirst('/'); + wxString command = commandLine.BeforeFirst(' '); + wxString args = commandLine.AfterFirst(' '); + + /* replace this with a std::map<std::string, handle> registry system + ** when it outgrows this switch */ + if (command == "test") + { + chatText.push(std::string("*** test command from client ***")); + SendChatText(connectionId, "*** test command acknowledged ***"); + } + else if (command == "help") + { + SendChatText(connectionId, "*** Help ***"); + SendChatText(connectionId, " /help - print command list"); + SendChatText(connectionId, " /test - dummy test command"); + } + else if (command == "name") + { + wxString updatedName = args; + tcPlayerStatus& pstatus = GetPlayerStatus(connectionId); + pstatus.name = updatedName.c_str(); + SendChatText(connectionId, "*** set name acknowledged ***"); + } + else + { + SendChatText(connectionId, "*** unrecognized command ***"); + } + } + + /** + * Process server command + * text commands start with a forward slash '/' + */ + void tcMultiplayerInterface::ProcessCommandServer(std::string text) + { + wxASSERT(IsServer()); + wxString candidate(text.c_str()); + + wxString command = candidate.AfterFirst('/'); + /* replace this with a std::map<std::string, handle> registry system + ** when it outgrows this switch */ + if (command == "startgame") + { + chatText.push(std::string("*** sending STARTGAME ***")); + BroadcastControlMessage(tcControlMessageHandler::CM_STARTGAME); + } + else if (command == "test") + { + chatText.push(std::string("*** test command ***")); + } + else if (command == "help") + { + chatText.push(std::string("*** Help ***")); + chatText.push(std::string(" /help - print command list")); + chatText.push(std::string(" /startgame - starts the game")); + chatText.push(std::string(" /test - dummy test command")); + } + else + { + chatText.push(std::string("*** unrecognized command ***")); + tcSound::Get()->PlayEffect("intercom"); + } + + } + /** * Process single receive message for connection associated with connectionId *************** *** 255,272 **** { char buff[256]; int protocol = tcpChat ? tcNetworkInterface::TCP : tcNetworkInterface::UDP; ! size_t messageLength = message.length(); ! if (messageLength > 255) messageLength = 255; ! strncpy(buff, message.c_str(), messageLength); ! buff[messageLength] = 0; ! networkInterface->SendMessage(destination, MSG_CHATTEXT, ! (unsigned)(messageLength+1), (unsigned char*)buff, ! protocol); ! /** networkInterface->SendMessage(destination, MSG_CHATTEXT, ! (unsigned)(messageLength+1), (unsigned char*)buff); ! */ } --- 413,441 ---- { char buff[256]; + unsigned messageLength; int protocol = tcpChat ? tcNetworkInterface::TCP : tcNetworkInterface::UDP; ! tcTextMessageHandler::CreateMessage(messageLength, (unsigned char*)buff, message, 255); ! networkInterface->SendMessage(destination, MSG_CHATTEXT, ! messageLength, (unsigned char*)buff, protocol); ! } ! ! /** ! * Send control message to destination ! */ ! void tcMultiplayerInterface::SendControlMessage(int destination, int messageCode) ! { ! unsigned char data[64]; ! unsigned messageSize; ! ! tcControlMessageHandler::CreateControlMessage(tcControlMessageHandler::CM_STARTGAME, ! messageSize, ! data); ! networkInterface->SendMessage(destination, MSG_CONTROL, ! (messageSize+1), data, ! tcNetworkInterface::TCP); ! } *************** *** 297,300 **** --- 466,477 ---- /** + * Sets identification name string for player using this interface + */ + void tcMultiplayerInterface::SetName(const std::string &name) + { + myName = name; + } + + /** * This must be called regularly to perform network functions. * (avoids need for multithreadeding) *************** *** 331,334 **** --- 508,512 ---- tcPlayerStatus stat; stat.timestamp = tcTime::Get30HzCount(); + stat.name = "anonymous"; playerInfo[connId] = stat; tcSound::Get()->PlayEffect("intercom"); *************** *** 367,377 **** tcMultiplayerInterface::tcMultiplayerInterface() ! : tcpChat(true) { networkInterface = new tcNetworkInterface(); wxASSERT(networkInterface); ! // register chat text message handler ! AddMessageHandler(MSG_CHATTEXT, new tcChatMessageHandler(chatText)); } --- 545,555 ---- tcMultiplayerInterface::tcMultiplayerInterface() ! : tcpChat(true), myName("Somebody") { networkInterface = new tcNetworkInterface(); wxASSERT(networkInterface); ! errorPlayerStatus.name = "error"; ! errorPlayerStatus.timestamp = 0; } Index: tcNetworkInterface.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/network/tcNetworkInterface.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** tcNetworkInterface.cpp 4 Apr 2004 21:00:43 -0000 1.7 --- tcNetworkInterface.cpp 7 Apr 2004 00:41:08 -0000 1.8 *************** *** 51,55 **** else { ! cdata.idString = wxString::Format("%s:%d",addr.Hostname().c_str(), addr.Service()); } --- 51,56 ---- else { ! // cdata.idString = wxString::Format("%s:%d",addr.Hostname().c_str(), addr.Service()); ! cdata.idString = wxString::Format("%s",addr.IPAddress().c_str()); } *************** *** 400,403 **** --- 401,408 ---- } + /** + * Opens connection with server specified by hostName. + * @param hostName server address--can be a host name or an IP-style address in dot notation (a.b.c.d) + */ void tcNetworkInterface::OpenConnection(wxString hostName) { *************** *** 685,691 **** { connectState = NOT_CONNECTED; ! fprintf(stdout, "Connection refused %s : %d\n", ! hostAddress.Hostname().c_str(), hostAddress.Service()); ! std::cerr << "Error - Connection refused." << std::endl; return; } --- 690,696 ---- { connectState = NOT_CONNECTED; ! ! fprintf(stderr, "Error - Connection with %s refused.\n", ! hostAddress.IPAddress()); return; } *************** *** 720,724 **** connectionData[n].socket->GetPeer(peerAddr); ! std::string hostName = peerAddr.Hostname().c_str(); peerMap[hostName] = (int)n; } --- 725,730 ---- connectionData[n].socket->GetPeer(peerAddr); ! //std::string hostName = peerAddr.Hostname().c_str(); ! std::string hostName = peerAddr.IPAddress().c_str(); peerMap[hostName] = (int)n; } |
|
From: Dewitt C. <ddc...@us...> - 2004-04-07 00:54:01
|
Update of /cvsroot/gcblue/gcb_wx/include/sim In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25434/include/sim Modified Files: Game.h tcSimState.h Log Message: Index: tcSimState.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/tcSimState.h,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** tcSimState.h 29 Feb 2004 22:51:35 -0000 1.18 --- tcSimState.h 7 Apr 2004 00:41:08 -0000 1.19 *************** *** 1,4 **** /* ! ** tcSimState.h ** ** Copyright (C) 2003 Dewitt "Cole" Colclough (de...@tw...) --- 1,4 ---- /* ! ** @file tcSimState.h ** ** Copyright (C) 2003 Dewitt "Cole" Colclough (de...@tw...) *************** *** 65,69 **** #define SCEN_STRING_LENGTH 1024 ! /***************** tcSimState ********************/ class tcSimState { --- 65,71 ---- #define SCEN_STRING_LENGTH 1024 ! /** ! * Singleton class that manages core simulation ! */ class tcSimState { *************** *** 92,95 **** --- 94,99 ---- tsScenarioInfo msScenarioInfo; + static tcSimState* Get(); ///< accessor for singleton instance + void AddLaunchedPlatform(long anNewKey, tcGameObject *plaunchingplatform, unsigned anLauncher); void AddPlatform(tcGameObject *pplat); *************** *** 163,170 **** void UpdateSensors(void); void UpdateWeaponHits(void); - - tcSimState(); - virtual ~tcSimState(); private: tcMapData *mpMapData; double mfSimTime; --- 167,174 ---- void UpdateSensors(void); void UpdateWeaponHits(void); private: + tcSimState(); + ~tcSimState(); + tcMapData *mpMapData; double mfSimTime; Index: Game.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/Game.h,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** Game.h 5 Apr 2004 02:24:29 -0000 1.31 --- Game.h 7 Apr 2004 00:41:08 -0000 1.32 *************** *** 154,158 **** tcPopupControl *popupControl; // popup control object tcDatabase mcDatabase; ! tcSimState mcSimState; tcMapData mcMapData; tcOptions mcOptions; --- 154,158 ---- tcPopupControl *popupControl; // popup control object tcDatabase mcDatabase; ! tcSimState *simState; tcMapData mcMapData; tcOptions mcOptions; |
|
From: Dewitt C. <ddc...@us...> - 2004-04-07 00:54:01
|
Update of /cvsroot/gcblue/gcb_wx/include/network In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25434/include/network Modified Files: tcMessageHandler.h tcMultiplayerInterface.h Added Files: tcControlMessageHandler.h tcTextMessageHandler.h Removed Files: tcChatMessageHandler.h Log Message: Index: tcMessageHandler.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/network/tcMessageHandler.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** tcMessageHandler.h 5 Apr 2004 02:24:28 -0000 1.1 --- tcMessageHandler.h 7 Apr 2004 00:41:07 -0000 1.2 *************** *** 33,45 **** /** ! * Abstract base class for message handler */ class tcMessageHandler { public: virtual void Handle(int connectionId, unsigned messageSize, const unsigned char *data) = 0; virtual ~tcMessageHandler() {} protected: tcMessageHandler() {} }; --- 33,50 ---- /** ! * Base class for message handler */ class tcMessageHandler { public: + static void SetAsServer(); + static void SetAsClient(); + virtual void Handle(int connectionId, unsigned messageSize, const unsigned char *data) = 0; + virtual ~tcMessageHandler() {} protected: tcMessageHandler() {} + static bool isServer; }; Index: tcMultiplayerInterface.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/network/tcMultiplayerInterface.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** tcMultiplayerInterface.h 5 Apr 2004 02:24:28 -0000 1.5 --- tcMultiplayerInterface.h 7 Apr 2004 00:41:07 -0000 1.6 *************** *** 33,38 **** - - #define BEGIN_NAMESPACE(x) namespace x { #define END_NAMESPACE } --- 33,36 ---- *************** *** 58,61 **** --- 56,60 ---- * also try this as an abstract base class, but application level * methods exist in this class as well. + * */ class tcMultiplayerInterface *************** *** 65,87 **** { MSG_CHATTEXT = 1, ! MSG_USERNAME = 2 }; static tcMultiplayerInterface* Get(); void AddMessageHandler(int messageId, tcMessageHandler* handler); std::string GetChatText(); int GetConnectionId(unsigned connectionIdx); std::string GetConnectionStatus(unsigned connectionIdx); ! unsigned GetNumConnections(); ! ! bool IsChatTextAvail(); bool IsServer(); void MakeClient(); void MakeServer(); void OpenConnection(std::string hostName); void SendChatText(int destination, std::string message); void SendTestUDP(int destination, std::string message); void SetChatProtocol(int code); void Update(); --- 64,94 ---- { MSG_CHATTEXT = 1, ! MSG_CONTROL = 2, ! MSG_USERNAME = 3 }; static tcMultiplayerInterface* Get(); void AddMessageHandler(int messageId, tcMessageHandler* handler); + void BroadcastControlMessage(int messageCode); std::string GetChatText(); int GetConnectionId(unsigned connectionIdx); std::string GetConnectionStatus(unsigned connectionIdx); ! std::string GetName() const; unsigned GetNumConnections(); ! tcPlayerStatus& GetPlayerStatus(int connectionId); ///< redundant with GetConnectionStatus? ! void InitMessageHandlers(); ! bool IsChatTextAvail(); ! bool IsCommand(std::string text); bool IsServer(); void MakeClient(); void MakeServer(); void OpenConnection(std::string hostName); + void ProcessCommandClient(int connectionId, std::string text); + void ProcessCommandServer(std::string text); void SendChatText(int destination, std::string message); + void SendControlMessage(int destination, int messageCode); void SendTestUDP(int destination, std::string message); void SetChatProtocol(int code); + void SetName(const std::string& name); void Update(); *************** *** 89,96 **** tcNetworkInterface *networkInterface; std::queue<std::string> chatText; ///< chat text to display ! std::string myName; std::map<int, tcPlayerStatus> playerInfo; ///< map of (connection id, tcPlayerStatus) pairs std::map<int, std::vector<tcMessageHandler*> > messageMap; ///< map of (message id, message handler vector) pairs bool tcpChat; ///< true to use TCP for chat protocol, otherwise UDP void ClearMessageMap(); --- 96,104 ---- tcNetworkInterface *networkInterface; std::queue<std::string> chatText; ///< chat text to display ! std::string myName; ///< name to identify player std::map<int, tcPlayerStatus> playerInfo; ///< map of (connection id, tcPlayerStatus) pairs std::map<int, std::vector<tcMessageHandler*> > messageMap; ///< map of (message id, message handler vector) pairs bool tcpChat; ///< true to use TCP for chat protocol, otherwise UDP + tcPlayerStatus errorPlayerStatus; ///< status to return if player not found void ClearMessageMap(); --- NEW FILE: tcControlMessageHandler.h --- /** @file tcControlMessageHandler.h * * Copyright (C) 2004 Dewitt "Cole" Colclough (de...@tw...) * All rights reserved. * * This file is part of the Global Conflict Blue (GCB) program. * GCB is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as * published by the Free Software Foundation. * * GCB is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GCB; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _CONTROLMESSAGEHANDLER_H_ #define _CONTROLMESSAGEHANDLER_H_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #include <queue> #include <string> #include "network/tcMessageHandler.h" #define BEGIN_NAMESPACE(x) namespace x { #define END_NAMESPACE } BEGIN_NAMESPACE(network) /** * Control message received handler. * Control messages are used to do things like start and pause the game */ class tcControlMessageHandler : public tcMessageHandler { public: enum { CM_BEEP = 1, CM_STARTGAME = 2 }; static void CreateControlMessage(int messageCode, unsigned& messageSize, unsigned char *data); virtual void Handle(int connectionId, unsigned messageSize, const unsigned char *data); tcControlMessageHandler(); virtual ~tcControlMessageHandler(); }; END_NAMESPACE #endif --- NEW FILE: tcTextMessageHandler.h --- /** @file tcTextMessageHandler.h * * Copyright (C) 2004 Dewitt "Cole" Colclough (de...@tw...) * All rights reserved. * * This file is part of the Global Conflict Blue (GCB) program. * GCB is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as * published by the Free Software Foundation. * * GCB is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GCB; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _TEXTMESSAGEHANDLER_H_ #define _TEXTMESSAGEHANDLER_H_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #include <queue> #include <string> #include "network/tcMessageHandler.h" #define BEGIN_NAMESPACE(x) namespace x { #define END_NAMESPACE } BEGIN_NAMESPACE(network) /** * Chat message received handler, also handles text slash '/' commands * Also added code to create messages so that it's in one place. */ class tcTextMessageHandler : public tcMessageHandler { public: static void CreateMessage(unsigned& messageSize, unsigned char *data, std::string text, unsigned maxSize); virtual void Handle(int connectionId, unsigned messageSize, const unsigned char *data); tcTextMessageHandler(std::queue<std::string>& _chatText); virtual ~tcTextMessageHandler(); private: std::queue<std::string>& chatText; // reference to queue for storing chat text }; END_NAMESPACE #endif --- tcChatMessageHandler.h DELETED --- |
|
From: Dewitt C. <ddc...@us...> - 2004-04-07 00:54:01
|
Update of /cvsroot/gcblue/gcb_wx In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25434 Modified Files: GCblue.vcproj Log Message: Index: GCblue.vcproj =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/GCblue.vcproj,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** GCblue.vcproj 5 Apr 2004 02:24:28 -0000 1.48 --- GCblue.vcproj 7 Apr 2004 00:41:06 -0000 1.49 *************** *** 496,503 **** Filter=""> <File ! RelativePath=".\src\network\tcChatMessageHandler.cpp"> </File> <File ! RelativePath="src\network\tcConnectionData.cpp"> </File> <File --- 496,503 ---- Filter=""> <File ! RelativePath="src\network\tcConnectionData.cpp"> </File> <File ! RelativePath=".\src\network\tcControlMessageHandler.cpp"> </File> <File *************** *** 505,508 **** --- 505,511 ---- </File> <File + RelativePath=".\src\network\tcMessageHandler.cpp"> + </File> + <File RelativePath="src\network\tcMultiplayerInterface.cpp"> </File> *************** *** 510,513 **** --- 513,519 ---- RelativePath="src\network\tcNetworkInterface.cpp"> </File> + <File + RelativePath=".\src\network\tcTextMessageHandler.cpp"> + </File> </Filter> </Filter> *************** *** 866,873 **** Filter=""> <File ! RelativePath=".\include\network\tcChatMessageHandler.h"> </File> <File ! RelativePath="include\network\tcConnectionData.h"> </File> <File --- 872,879 ---- Filter=""> <File ! RelativePath="include\network\tcConnectionData.h"> </File> <File ! RelativePath=".\include\network\tcControlMessageHandler.h"> </File> <File *************** *** 883,886 **** --- 889,895 ---- RelativePath="include\network\tcNetworkInterface.h"> </File> + <File + RelativePath=".\include\network\tcTextMessageHandler.h"> + </File> </Filter> </Filter> |
|
From: Dewitt C. <ddc...@us...> - 2004-04-07 00:54:01
|
Update of /cvsroot/gcblue/gcb_wx/docs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25434/docs Modified Files: CHANGES.txt Log Message: Index: CHANGES.txt =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/docs/CHANGES.txt,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** CHANGES.txt 5 Apr 2004 02:24:28 -0000 1.9 --- CHANGES.txt 7 Apr 2004 00:41:07 -0000 1.10 *************** *** 3,6 **** --- 3,10 ---- 0.6 --------------------------------------------------------------------- + *** 2004-04-06 Dewitt Colclough *** + - Added a few test server commands via multiplayer console + - Added client test command system, added help and name commands + *** 2004-04-05 Dewitt Colclough *** - Added basics of message handling system for multiplayer |
|
From: Dewitt C. <ddc...@us...> - 2004-04-05 02:37:05
|
Update of /cvsroot/gcblue/gcb_wx/src/graphics In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4666/src/graphics Modified Files: tcTerrainTextureFactory.cpp Log Message: Index: tcTerrainTextureFactory.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcTerrainTextureFactory.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** tcTerrainTextureFactory.cpp 15 Dec 2003 04:19:59 -0000 1.5 --- tcTerrainTextureFactory.cpp 5 Apr 2004 02:24:29 -0000 1.6 *************** *** 1,3 **** ! /* * This is a very simple demonstration of how to provide procedural textures to Demeter. * This sample texture factory simply creates texels based on the terrain elevation at each texel. --- 1,21 ---- ! /** ! * Copyright (C) 2003 Dewitt "Cole" Colclough (de...@tw...) ! * All rights reserved. ! * ! * This file is part of the Global Conflict Blue (GCB) program. ! * GCB is free software; you can redistribute it and/or modify ! * it under the terms of version 2 of the GNU General Public License as ! * published by the Free Software Foundation. ! * ! * GCB is distributed in the hope that it will be useful, ! * but WITHOUT ANY WARRANTY; without even the implied warranty of ! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! * GNU General Public License for more details. ! * ! * You should have received a copy of the GNU General Public License ! * along with GCB; if not, write to the Free Software ! * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ! */ ! /** @file tcTerrainTextureFactory.cpp * This is a very simple demonstration of how to provide procedural textures to Demeter. * This sample texture factory simply creates texels based on the terrain elevation at each texel. |
|
From: Dewitt C. <ddc...@us...> - 2004-04-05 02:37:03
|
Update of /cvsroot/gcblue/gcb_wx/src/sim In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4666/src/sim Modified Files: Game.cpp tcNetworkView.cpp Log Message: Index: tcNetworkView.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcNetworkView.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** tcNetworkView.cpp 24 Mar 2004 21:09:27 -0000 1.8 --- tcNetworkView.cpp 5 Apr 2004 02:24:29 -0000 1.9 *************** *** 68,74 **** DrawStatusBox(pGraphics); ! if (tcMultiplayerInterface::Get().IsChatTextAvail()) { ! chatBox->Print(tcMultiplayerInterface::Get().GetChatText().c_str()); } --- 68,74 ---- DrawStatusBox(pGraphics); ! if (tcMultiplayerInterface::Get()->IsChatTextAvail()) { ! chatBox->Print(tcMultiplayerInterface::Get()->GetChatText().c_str()); } *************** *** 91,100 **** DrawTextCenteredHV(graphics, font12, mpBrush, "Connection Status", x, y); ! unsigned nConnections = tcMultiplayerInterface::Get().GetNumConnections(); x = (float)statusBoxBounds.x + 10.0f; for (unsigned n=0;n<nConnections;n++) { y += 10.0f; ! std::string connectionStatus = tcMultiplayerInterface::Get().GetConnectionStatus(n); DrawText(graphics, font8, mpBrush, connectionStatus.c_str(), x, y); } --- 91,100 ---- DrawTextCenteredHV(graphics, font12, mpBrush, "Connection Status", x, y); ! unsigned nConnections = tcMultiplayerInterface::Get()->GetNumConnections(); x = (float)statusBoxBounds.x + 10.0f; for (unsigned n=0;n<nConnections;n++) { y += 10.0f; ! std::string connectionStatus = tcMultiplayerInterface::Get()->GetConnectionStatus(n); DrawText(graphics, font8, mpBrush, connectionStatus.c_str(), x, y); } *************** *** 109,113 **** if (networkMode != 1) return; ! tcMultiplayerInterface::Get().OpenConnection(ipText.c_str()); } --- 109,113 ---- if (networkMode != 1) return; ! tcMultiplayerInterface::Get()->OpenConnection(ipText.c_str()); } *************** *** 123,136 **** std::string chatText = event.GetString().c_str(); ! unsigned nConnections = tcMultiplayerInterface::Get().GetNumConnections(); for (unsigned n=0;n<nConnections;n++) { ! int connId = tcMultiplayerInterface::Get().GetConnectionId(n); ! tcMultiplayerInterface::Get().SendChatText(connId, chatText); } // if server, print chat text locally since no echo comes back ! if (tcMultiplayerInterface::Get().IsServer()) { chatBox->Print(chatText.c_str()); --- 123,136 ---- std::string chatText = event.GetString().c_str(); ! unsigned nConnections = tcMultiplayerInterface::Get()->GetNumConnections(); for (unsigned n=0;n<nConnections;n++) { ! int connId = tcMultiplayerInterface::Get()->GetConnectionId(n); ! tcMultiplayerInterface::Get()->SendChatText(connId, chatText); } // if server, print chat text locally since no echo comes back ! if (tcMultiplayerInterface::Get()->IsServer()) { chatBox->Print(chatText.c_str()); *************** *** 144,148 **** ! tcMultiplayerInterface::Get().SetChatProtocol(protocol == 0); } --- 144,148 ---- ! tcMultiplayerInterface::Get()->SetChatProtocol(protocol == 0); } *************** *** 161,170 **** if (mode <= 1) { ! tcMultiplayerInterface::Get().MakeClient(); } else if (mode == 2) { ! tcMultiplayerInterface::Get().MakeServer(); } --- 161,170 ---- if (mode <= 1) { ! tcMultiplayerInterface::Get()->MakeClient(); } else if (mode == 2) { ! tcMultiplayerInterface::Get()->MakeServer(); } *************** *** 178,191 **** std::string testText = "Test text for UDP"; ! unsigned nConnections = tcMultiplayerInterface::Get().GetNumConnections(); for (unsigned n=0;n<nConnections;n++) { ! int connId = tcMultiplayerInterface::Get().GetConnectionId(n); ! tcMultiplayerInterface::Get().SendTestUDP(connId, testText); } // if server, print chat text locally since no echo comes back ! if (tcMultiplayerInterface::Get().IsServer()) { std::string localText = std::string("Sent UDP test: ") + --- 178,191 ---- std::string testText = "Test text for UDP"; ! unsigned nConnections = tcMultiplayerInterface::Get()->GetNumConnections(); for (unsigned n=0;n<nConnections;n++) { ! int connId = tcMultiplayerInterface::Get()->GetConnectionId(n); ! tcMultiplayerInterface::Get()->SendTestUDP(connId, testText); } // if server, print chat text locally since no echo comes back ! if (tcMultiplayerInterface::Get()->IsServer()) { std::string localText = std::string("Sent UDP test: ") + Index: Game.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/Game.cpp,v retrieving revision 1.72 retrieving revision 1.73 diff -C2 -d -r1.72 -r1.73 *** Game.cpp 3 Apr 2004 20:24:33 -0000 1.72 --- Game.cpp 5 Apr 2004 02:24:29 -0000 1.73 *************** *** 1007,1012 **** tcTime::Update(); ! tcMultiplayerInterface::Get().Update(); ! tcMultiplayerInterface::Get().Update(); startView->mbPlayEnabled = mcSimState.msScenarioInfo.mbLoaded; --- 1007,1012 ---- tcTime::Update(); ! tcMultiplayerInterface::Get()->Update(); ! tcMultiplayerInterface::Get()->Update(); startView->mbPlayEnabled = mcSimState.msScenarioInfo.mbLoaded; |
|
From: Dewitt C. <ddc...@us...> - 2004-04-05 02:37:03
|
Update of /cvsroot/gcblue/gcb_wx/src/network In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4666/src/network Modified Files: tcMultiplayerInterface.cpp Added Files: tcChatMessageHandler.cpp Log Message: Index: tcMultiplayerInterface.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/network/tcMultiplayerInterface.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** tcMultiplayerInterface.cpp 6 Mar 2004 20:52:29 -0000 1.3 --- tcMultiplayerInterface.cpp 5 Apr 2004 02:24:29 -0000 1.4 *************** *** 28,31 **** --- 28,33 ---- #include "network/tcNetworkInterface.h" #include "network/tcMultiplayerInterface.h" + #include "network/tcMessageHandler.h" + #include "network/tcChatMessageHandler.h" #include <iostream> #include <queue> *************** *** 38,47 **** * @return singleton instance */ ! tcMultiplayerInterface& tcMultiplayerInterface::Get() { static tcMultiplayerInterface instance; ! return instance; } std::string tcMultiplayerInterface::GetChatText() { --- 40,99 ---- * @return singleton instance */ ! tcMultiplayerInterface* tcMultiplayerInterface::Get() { static tcMultiplayerInterface instance; ! return &instance; } + /** + * Adds message handler for message with messageId. + * tcMessageHandler::Handle method will be called for any matching messages received + * Currently tcMultiplayerInterface deletes the message handlers--may want to change + * this such that creator deletes or use shared pointer. + */ + void tcMultiplayerInterface::AddMessageHandler(int messageId, tcMessageHandler* handler) + { + std::map<int, std::vector<tcMessageHandler*> >::iterator mapIter; + + mapIter = messageMap.find(messageId); + if (mapIter == messageMap.end()) + { + // create new map pair + std::vector<tcMessageHandler*> mm; + mm.push_back(handler); + messageMap[messageId] = mm; + } + else + { + // add handler to existing map pair + mapIter->second.push_back(handler); + } + } + + /** + * Clears messageMap, deleting all message handlers + */ + void tcMultiplayerInterface::ClearMessageMap() + { + std::map<int, std::vector<tcMessageHandler*> >::iterator mapIter; + + mapIter = messageMap.begin(); + + for (mapIter = messageMap.begin(); mapIter != messageMap.end(); + ++mapIter) + { + std::vector<tcMessageHandler*>& mm = mapIter->second; + size_t nHandlers = mm.size(); + for (size_t n = 0; n < nHandlers; n++) + { + wxASSERT(mm[n]); + delete mm[n]; + } + mm.clear(); + } + messageMap.clear(); + } + + std::string tcMultiplayerInterface::GetChatText() { *************** *** 110,133 **** } /** * Process single receive message for connection associated with connectionId */ ! void tcMultiplayerInterface::ProcessMessage(int connectionId, int messageId, unsigned messageSize, const unsigned char *data) { switch (messageId) { case MSG_CHATTEXT: ! chatText.push(std::string((char*)data)); ! if (networkInterface->IsServer()) ! { ! // broadcast chat text to all clients ! unsigned nConn = networkInterface->GetNumConnections(); ! for (unsigned n=0;n<nConn;n++) ! { ! int connId = networkInterface->GetConnectionId(n); ! SendChatText(connId, (char*)data); ! } ! } break; default: --- 162,214 ---- } + void tcMultiplayerInterface::ProcessChatMessage(int connectionId, + unsigned messageSize, const unsigned char *data) + { + chatText.push(std::string((char*)data)); + if (networkInterface->IsServer()) + { + // broadcast chat text to all clients + unsigned nConn = networkInterface->GetNumConnections(); + for (unsigned n=0;n<nConn;n++) + { + int connId = networkInterface->GetConnectionId(n); + SendChatText(connId, (char*)data); + } + } + } + /** * Process single receive message for connection associated with connectionId */ ! void tcMultiplayerInterface::ProcessMessage(int messageId, int connectionId, unsigned messageSize, const unsigned char *data) { + + std::map<int, std::vector<tcMessageHandler*> >::iterator mapIter; + + mapIter = messageMap.find(messageId); + if (mapIter == messageMap.end()) + { + fprintf(stderr, + "Warning - tcMultiplayerInterface::ProcessMessage unrecognized message ID (%d)\n", + messageId); + return; + } + + // call all registered message handlers for this message + std::vector<tcMessageHandler*>& mm = mapIter->second; + size_t nHandlers = mm.size(); + for (size_t n = 0; n < nHandlers; n++) + { + wxASSERT(mm[n]); + mm[n]->Handle(connectionId, messageSize, data); + } + + /* switch (messageId) { case MSG_CHATTEXT: ! ProcessChatMessage(connectionId, messageSize, data); ! break; default: *************** *** 136,139 **** --- 217,221 ---- break; } + */ } *************** *** 154,158 **** if (tcp_data != NULL) { ! ProcessMessage(connId, messageId, messageSize, tcp_data); } --- 236,240 ---- if (tcp_data != NULL) { ! ProcessMessage(messageId, connId, messageSize, tcp_data); } *************** *** 161,165 **** if (udp_data != NULL) { ! ProcessMessage(connId, messageId, messageSize, udp_data); } } --- 243,247 ---- if (udp_data != NULL) { ! ProcessMessage(messageId, connId, messageSize, udp_data); } } *************** *** 289,292 **** --- 371,377 ---- networkInterface = new tcNetworkInterface(); wxASSERT(networkInterface); + + // register chat text message handler + AddMessageHandler(MSG_CHATTEXT, new tcChatMessageHandler(chatText)); } *************** *** 301,304 **** --- 386,390 ---- tcMultiplayerInterface::~tcMultiplayerInterface() { + ClearMessageMap(); if (networkInterface) delete networkInterface; } --- NEW FILE: tcChatMessageHandler.cpp --- /** * Copyright (C) 2004 Dewitt "Cole" Colclough (de...@tw...) * All rights reserved. * * This file is part of the Global Conflict Blue (GCB) program. * GCB is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as * published by the Free Software Foundation. * * GCB is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GCB; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /** @file tcChatMessageHandler.cpp */ #include "network/tcChatMessageHandler.h" #include "network/tcMultiplayerInterface.h" BEGIN_NAMESPACE(network) void tcChatMessageHandler::Handle(int connectionId, unsigned messageSize, const unsigned char *data) { chatText.push(std::string((char*)data)); tcMultiplayerInterface* multiplayerInterface = tcMultiplayerInterface::Get(); if (multiplayerInterface->IsServer()) { // broadcast chat text to all clients unsigned nConn = multiplayerInterface->GetNumConnections(); for (unsigned n=0;n<nConn;n++) { int connId = multiplayerInterface->GetConnectionId(n); multiplayerInterface->SendChatText(connId, (char*)data); } } } tcChatMessageHandler::tcChatMessageHandler(std::queue<std::string>& _chatText) : chatText(_chatText) { } tcChatMessageHandler::~tcChatMessageHandler() { } END_NAMESPACE |
|
From: Dewitt C. <ddc...@us...> - 2004-04-05 02:37:03
|
Update of /cvsroot/gcblue/gcb_wx/include/sim In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4666/include/sim Modified Files: Game.h Log Message: Index: Game.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/Game.h,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** Game.h 21 Mar 2004 21:03:25 -0000 1.30 --- Game.h 5 Apr 2004 02:24:29 -0000 1.31 *************** *** 55,59 **** class tcOOBView; class tcPopupControl; - class tcSceneHandler; enum teMenuMode; class tc3DViewer; --- 55,58 ---- |
|
From: Dewitt C. <ddc...@us...> - 2004-04-05 02:37:02
|
Update of /cvsroot/gcblue/gcb_wx/include/network In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4666/include/network Modified Files: tcMultiplayerInterface.h Added Files: tcChatMessageHandler.h tcMessageHandler.h Log Message: --- NEW FILE: tcMessageHandler.h --- /** @file tcMessageHandler.h * * Copyright (C) 2004 Dewitt "Cole" Colclough (de...@tw...) * All rights reserved. * * This file is part of the Global Conflict Blue (GCB) program. * GCB is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as * published by the Free Software Foundation. * * GCB is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GCB; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _MESSAGEHANDLER_H_ #define _MESSAGEHANDLER_H_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #define BEGIN_NAMESPACE(x) namespace x { #define END_NAMESPACE } BEGIN_NAMESPACE(network) /** * Abstract base class for message handler */ class tcMessageHandler { public: virtual void Handle(int connectionId, unsigned messageSize, const unsigned char *data) = 0; virtual ~tcMessageHandler() {} protected: tcMessageHandler() {} }; END_NAMESPACE #endif --- NEW FILE: tcChatMessageHandler.h --- /** @file tcChatMessageHandler.h * * Copyright (C) 2004 Dewitt "Cole" Colclough (de...@tw...) * All rights reserved. * * This file is part of the Global Conflict Blue (GCB) program. * GCB is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as * published by the Free Software Foundation. * * GCB is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GCB; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _CHATMESSAGEHANDLER_H_ #define _CHATMESSAGEHANDLER_H_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #include <queue> #include <string> #include "network/tcMessageHandler.h" #define BEGIN_NAMESPACE(x) namespace x { #define END_NAMESPACE } BEGIN_NAMESPACE(network) /** * Chat message received handler */ class tcChatMessageHandler : public tcMessageHandler { public: virtual void Handle(int connectionId, unsigned messageSize, const unsigned char *data); tcChatMessageHandler(std::queue<std::string>& _chatText); virtual ~tcChatMessageHandler(); private: std::queue<std::string>& chatText; }; END_NAMESPACE #endif Index: tcMultiplayerInterface.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/network/tcMultiplayerInterface.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** tcMultiplayerInterface.h 4 Apr 2004 20:54:12 -0000 1.4 --- tcMultiplayerInterface.h 5 Apr 2004 02:24:28 -0000 1.5 *************** *** 28,36 **** #include <queue> ! /* #include <vector> - #include <map> - */ --- 28,35 ---- #include <queue> ! #include <map> ! #include <string> #include <vector> *************** *** 42,45 **** --- 41,45 ---- class tcNetworkInterface; + class tcMessageHandler; *************** *** 67,72 **** MSG_USERNAME = 2 }; ! static tcMultiplayerInterface& Get(); std::string GetChatText(); int GetConnectionId(unsigned connectionIdx); --- 67,73 ---- MSG_USERNAME = 2 }; ! static tcMultiplayerInterface* Get(); + void AddMessageHandler(int messageId, tcMessageHandler* handler); std::string GetChatText(); int GetConnectionId(unsigned connectionIdx); *************** *** 90,98 **** std::string myName; std::map<int, tcPlayerStatus> playerInfo; ///< map of (connection id, tcPlayerStatus) pairs bool tcpChat; ///< true to use TCP for chat protocol, otherwise UDP bool IsNewPlayer(int id); ! void ProcessMessage(int connectionId, int messageId, unsigned messageSize, const unsigned char *data); void ProcessReceiveMessages(); void UpdatePlayerInfo(); --- 91,103 ---- std::string myName; std::map<int, tcPlayerStatus> playerInfo; ///< map of (connection id, tcPlayerStatus) pairs + std::map<int, std::vector<tcMessageHandler*> > messageMap; ///< map of (message id, message handler vector) pairs bool tcpChat; ///< true to use TCP for chat protocol, otherwise UDP + void ClearMessageMap(); bool IsNewPlayer(int id); ! void ProcessChatMessage(int connectionId, unsigned messageSize, const unsigned char *data); ! void ProcessMessage(int messageId, int connectionId, unsigned messageSize, const unsigned char *data); + void ProcessReceiveMessages(); void UpdatePlayerInfo(); |
|
From: Dewitt C. <ddc...@us...> - 2004-04-05 02:37:02
|
Update of /cvsroot/gcblue/gcb_wx/docs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4666/docs Modified Files: CHANGES.txt Log Message: Index: CHANGES.txt =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/docs/CHANGES.txt,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** CHANGES.txt 4 Apr 2004 21:54:30 -0000 1.8 --- CHANGES.txt 5 Apr 2004 02:24:28 -0000 1.9 *************** *** 3,6 **** --- 3,10 ---- 0.6 --------------------------------------------------------------------- + *** 2004-04-05 Dewitt Colclough *** + - Added basics of message handling system for multiplayer + - Changed chat text code to use message handling system + *** 2004-04-05 Xavi Rubio *** - Linux compatibility fixes in network dir |
|
From: Dewitt C. <ddc...@us...> - 2004-04-05 02:37:02
|
Update of /cvsroot/gcblue/gcb_wx In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4666 Modified Files: GCblue.vcproj Log Message: Index: GCblue.vcproj =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/GCblue.vcproj,v retrieving revision 1.47 retrieving revision 1.48 diff -C2 -d -r1.47 -r1.48 *** GCblue.vcproj 24 Mar 2004 21:09:25 -0000 1.47 --- GCblue.vcproj 5 Apr 2004 02:24:28 -0000 1.48 *************** *** 273,277 **** </File> <File ! RelativePath="src\graphics\tcwindow.cpp"> </File> </Filter> --- 273,277 ---- </File> <File ! RelativePath=".\src\graphics\tcWindow.cpp"> </File> </Filter> *************** *** 496,499 **** --- 496,502 ---- Filter=""> <File + RelativePath=".\src\network\tcChatMessageHandler.cpp"> + </File> + <File RelativePath="src\network\tcConnectionData.cpp"> </File> *************** *** 631,635 **** </File> <File ! RelativePath="include\graphics\tcwindow.h"> </File> </Filter> --- 634,638 ---- </File> <File ! RelativePath=".\include\graphics\tcWindow.h"> </File> </Filter> *************** *** 863,866 **** --- 866,872 ---- Filter=""> <File + RelativePath=".\include\network\tcChatMessageHandler.h"> + </File> + <File RelativePath="include\network\tcConnectionData.h"> </File> *************** *** 869,872 **** --- 875,881 ---- </File> <File + RelativePath=".\include\network\tcMessageHandler.h"> + </File> + <File RelativePath="include\network\tcMultiplayerInterface.h"> </File> |
|
From: Xavi <xr...@us...> - 2004-04-04 22:07:02
|
Update of /cvsroot/gcblue/gcb_wx/docs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25460 Modified Files: CHANGES.txt Log Message: + added last changes and fixes Index: CHANGES.txt =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/docs/CHANGES.txt,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** CHANGES.txt 3 Apr 2004 20:24:32 -0000 1.7 --- CHANGES.txt 4 Apr 2004 21:54:30 -0000 1.8 *************** *** 3,6 **** --- 3,11 ---- 0.6 --------------------------------------------------------------------- + *** 2004-04-05 Xavi Rubio *** + - Linux compatibility fixes in network dir + - Changed tcwindow and tcscenehandler files to tcWindow and tcSceneHandler, + according to includes (having in mind that linux is case sensitive). + *** 2004-04-03 Dewitt Colclough *** - Added multi-unit selection box drawing to map |
|
From: Xavi <xr...@us...> - 2004-04-04 22:02:05
|
Update of /cvsroot/gcblue/gcb_wx/src/graphics In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24645 Added Files: tcWindow.cpp Removed Files: tcwindow.cpp Log Message: + changed lowercase tcwindow.cpp to tcWindow.cpp, according to the includes from other files and the name of the class --- NEW FILE: tcWindow.cpp --- /* ** tcWindow.cpp: implementation of the tcWindow class. ** ** Copyright (C) 2003 Dewitt "Cole" Colclough (de...@tw...) ** All rights reserved. ** This file is part of the Global Conflict Blue (GCB) program. ** GCB is free software; you can redistribute it and/or modify ** it under the terms of version 2 of the GNU General Public License as ** published by the Free Software Foundation. ** GCB is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** You should have received a copy of the GNU General Public License ** along with GCB; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "stdwx.h" // precompiled header file #ifndef WX_PRECOMP #include "wx/wx.h" #include "wx/msw/private.h" // for MS Windows specific definitions #endif #include "tcWindow.h" #include "gdiplus.h" #include "tcGraphicsEngine.h" #include "aerror.h" #include <stdio.h> #include <iostream> #include "tcString.h" #include "tcSound.h" using namespace Gdiplus; BEGIN_EVENT_TABLE(tcWindow, wxWindow) //EVT_PAINT(tcWindow::OnPaint) //EVT_NC_PAINT(tcWindow::OnPaint) //EVT_ERASE_BACKGROUND(tcWindow::OnEraseBackground) EVT_MOVE(tcWindow::OnMove) EVT_LEFT_DOWN(tcWindow::OnLButtonDown) EVT_LEFT_UP(tcWindow::OnLButtonUp) EVT_RIGHT_DOWN(tcWindow::OnRButtonDown) EVT_MOTION(tcWindow::OnMouseMove) EVT_MOUSEWHEEL(tcWindow::OnMouseWheel) EVT_KEY_DOWN(tcWindow::OnKeyDown) ///< any key has been pressed EVT_CHAR(tcWindow::OnChar) EVT_ENTER_WINDOW(tcWindow::OnEnterWindow) EVT_LEAVE_WINDOW(tcWindow::OnLeaveWindow) EVT_SHOW(tcWindow::OnShow) EVT_SIZE(tcWindow::OnSize) EVT_SET_FOCUS(tcWindow::OnSetFocus) EVT_KILL_FOCUS(tcWindow::OnKillFocus) END_EVENT_TABLE() /** * This override along with use of Freeze() Thaw() prevents * the flicker that happens when the window background is erased * by wxWindows. */ long tcWindow::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) { switch (nMsg) { case WM_ERASEBKGND: return 0; break; default: return wxWindow::MSWWindowProc(nMsg, wParam, lParam); break; } } void tcWindow::OnChar(wxKeyEvent& event) { event.Skip(); } void tcWindow::OnEnterWindow(wxMouseEvent& event) { SetFocus(); } /** * Do nothing for EraseBackground event. */ void tcWindow::OnEraseBackground(wxEraseEvent& event) { SetBackgroundColour(*wxBLACK); fprintf(stdout, "Erase [%s]\n",GetName()); } /** * Do nothing for OnPaint event. */ void tcWindow::OnPaint(wxPaintEvent& event) { wxPaintDC dc(this); fprintf(stdout, "Paint [%s]\n",GetName()); } /** * Do nothing for show event. */ void tcWindow::OnShow(wxShowEvent& event) { return; } void tcWindow::OnKeyDown(wxKeyEvent& event) { event.Skip(); } void tcWindow::OnLButtonDown(wxMouseEvent& event) { SkipMouseEvent(event); } void tcWindow::OnLButtonUp(wxMouseEvent& event) { SkipMouseEvent(event); } void tcWindow::OnLeaveWindow(wxMouseEvent& event) { event.Skip(); } void tcWindow::OnMouseMove(wxMouseEvent& event) { event.Skip(); } void tcWindow::OnMouseWheel(wxMouseEvent& event) { event.Skip(); } void tcWindow::OnMove(wxMoveEvent& event) { // event.Skip(); } void tcWindow::OnRButtonDown(wxMouseEvent& event) { SkipMouseEvent(event); } void tcWindow::OnSetFocus(wxFocusEvent& event) { } void tcWindow::OnKillFocus(wxFocusEvent& event) { } void tcWindow::OnSize(wxSizeEvent& event) { wxSize size = event.GetSize(); wxPoint pos = wxWindow::GetPosition(); mnWidth = size.GetWidth(); mnHeight = size.GetHeight(); mrectWindow.left = pos.x; mrectWindow.right = pos.x + size.GetWidth(); mrectWindow.top = pos.y; mrectWindow.bottom = pos.y + size.GetHeight(); if (mbCloned) return; // do not modify shared mp2DSurface for cloned/shared windows if (resizeable2DSurface) { mp2DSurface->SetDisplayRegion(0,0,(float)mnWidth,(float)mnHeight); if (mp2DSurface->Init(mnWidth, mnHeight) != true) { wxMessageBox("Window resize failed","ERROR",wxICON_ERROR); return; } } mp2DSurface->SetWindow(mrectWindow.left, yMirror - mrectWindow.bottom, mrectWindow.right, yMirror - mrectWindow.top); mp2DSurface->mbModified = true; } /** * Adds child window to children vector. This * allows drawing of children windows through * DrawChildren() method. */ void tcWindow::AddChild(tcWindow* child) { wxASSERT(child); if (child == NULL) return; children.push_back(child); } bool tcWindow::GetDrawDC(HDC& hdc) { return mp2DSurface->GetDrawDC(hdc); } /** * @return pointer to WCHAR array (string) with IMAGE_PATH prepended, * extremely long file names can cause overrun. */ WCHAR* tcWindow::PrependImagePath(const char *azFileName) { char zBuff[96]; strcpy(zBuff,IMAGE_PATH); strcat(zBuff,azFileName); MultiByteToWideChar(CP_ACP, 0, zBuff, -1, mzwchar, 255); return mzwchar; } bool tcWindow::ReleaseDrawDC(HDC hdc) { return mp2DSurface->ReleaseDrawDC(hdc); } bool tcWindow::GetGraphics(Graphics*& rpGraphics) { if (GetDrawDC(mhdc) == false) {return false;} rpGraphics = new Graphics(mhdc); if (rpGraphics == NULL) {return false;} rpGraphics->SetCompositingMode(CompositingModeSourceOver); // SourceCopy doesn't do blending rpGraphics->SetSmoothingMode(SmoothingModeAntiAlias); rpGraphics->SetPixelOffsetMode(PixelOffsetModeHighQuality); rpGraphics->SetTextRenderingHint(TextRenderingHintAntiAlias); //rpGraphics->SetTextRenderingHint(TextRenderingHintAntiAliasGridFit); return true; } bool tcWindow::GetLowQualityGraphics(Graphics*& rpGraphics) { if (GetDrawDC(mhdc) == false) {return false;} rpGraphics = new Graphics(mhdc); if (rpGraphics == NULL) {return false;} rpGraphics->SetCompositingMode(CompositingModeSourceOver); // SourceCopy doesn't do blending rpGraphics->SetSmoothingMode(SmoothingModeHighSpeed); rpGraphics->SetPixelOffsetMode(PixelOffsetModeHighSpeed ); rpGraphics->SetTextRenderingHint(TextRenderingHintSingleBitPerPixelGridFit); return true; } bool tcWindow::ReleaseGraphics(Graphics* apGraphics) { if (apGraphics != NULL) {delete apGraphics;} return ReleaseDrawDC(mhdc); } /** * wxWindows (or MS Windows behind it) erases window region * when the window is moved or Show() is used. This causes * a flickering effect. Enable() is used to activate/deactivate * GUI inputs for the window. */ void tcWindow::SetActive(bool abActive) { if (abActive) { if (!wxWindow::IsShown()) { wxWindow::Show(TRUE); } wxWindow::Enable(true); } else { wxWindow::Enable(false); } mbActive=abActive; mp2DSurface->SetActive(abActive); size_t nChildren = children.size(); for(size_t n=0;n<nChildren;n++) { children[n]->SetActive(abActive); } } void tcWindow::SetRenderTexture(bool abState) { mp2DSurface->SetRenderTexture(abState); } /** * Used to reduce the number OpenGL 2D graphics transfers via * glDrawPixels to speed frame rate. Set to 1 to only transfer * every 3rd frame for window. Set to 2 for every 5th frame. * @see tc2DGraphicsSurface::SetSkipCount */ void tcWindow::SetSkipCount(unsigned skipCount) { mp2DSurface->SetSkipCount(skipCount); } /** * Adjusts wxMouseEvent position to parent's frame. * Calls Skip() on event. */ void tcWindow::SkipMouseEvent(wxMouseEvent& event) { wxPoint pos = wxWindow::GetPosition(); event.m_x += pos.x; event.m_y += pos.y; event.Skip(); } /** * Use this for child windows, or windows that are not * displayed at the same time as the parent window to * save memory. This must be called after the parent's surface * has been created. */ void tcWindow::ShareSurfaceWith(const tcWindow* apWindow) { wxASSERT(apWindow); wxASSERT(apWindow->mp2DSurface); mp2DSurface = apWindow->mp2DSurface; mbCloned = true; mbActive = apWindow->mbActive; } /** * Called once to register and create tc2DGraphics surface. Will * call tc2DGraphicsSurface::Init method to create bitmap for surface. * If the graphics surface has already been created this method will * log a warning and return. */ int tcWindow::CreateSurfaces(tcGraphicsEngine* apGraphicsEngine) { wxASSERT(!mbCloned); // error, parent will create surface // check if surface has already been created if (mp2DSurface) { fprintf(stderr,"WARNING: CreateSurfaces called more than once.\n"); return true; } if (apGraphicsEngine->Create2DSurface(mp2DSurface) == false) {return false;} if (yMirror) { mp2DSurface->SetWindow(mrectWindow.left, yMirror - mrectWindow.bottom, mrectWindow.right, yMirror - mrectWindow.top); } else { mp2DSurface->SetWindow(mrectWindow.left, mrectWindow.top, mrectWindow.right, mrectWindow.bottom); } mp2DSurface->SetDisplayRegion(0,0,(float)mnWidth,(float)mnHeight); if (mp2DSurface->Init(mnWidth, mnHeight) != true) {return false;} mp2DSurface->GetActive(mbActive); return true; } int tcWindow::DeleteSurfaces(tcGraphicsEngine* apGraphicsEngine) { wxASSERT(!mbCloned); // error, parent window will delete surface if (apGraphicsEngine->Delete2DSurface(mp2DSurface) == false) {return false;} mp2DSurface = NULL; mbActive = false; return true; } int tcWindow::DrawTest() { if (mp2DSurface != NULL) { mp2DSurface->DrawTestGdiPlus(); return 1; } else { return 0; } } /** * @return 1 if Draw was performed, 0 otherwise. */ int tcWindow::Draw() { return 1; } void tcWindow::Draw(Gdiplus::Graphics *graphics) { } /** * Call Draw(Gdiplus::Graphics*) method for all children */ void tcWindow::DrawChildren(Gdiplus::Graphics *graphics) { wxASSERT(graphics); size_t nChildren = children.size(); for(size_t n=0;n<nChildren;n++) { wxASSERT(children[n]); graphics->TranslateTransform(children[n]->mrectWindow.left, children[n]->mrectWindow.top); children[n]->Draw(graphics); graphics->TranslateTransform(-children[n]->mrectWindow.left, -children[n]->mrectWindow.top); } } void tcWindow::DrawText(Graphics* apGraphics, Font* apFont, Brush* apBrush, const char* azstr, float afX, float afY) { MultiByteToWideChar(CP_ACP, 0, azstr, -1, mzwchar, 255); apGraphics->DrawString(mzwchar, -1, apFont, PointF(afX,afY), apBrush); } void tcWindow::DrawText(Graphics* apGraphics, Font* apFont, Brush* apBrush, const char* azstr, float afX, float afY, RectF& r) { PointF p(afX,afY); MultiByteToWideChar(CP_ACP, 0, azstr, -1, mzwchar, 255); apGraphics->DrawString(mzwchar, -1, apFont, p, apBrush); apGraphics->MeasureString(mzwchar,-1,apFont,p, &r); } /** * Draws horizontally centered text */ void tcWindow::DrawTextCentered(Graphics* apGraphics, Font* apFont, Brush* apBrush, const char* azstr, float afX, float afY) { MultiByteToWideChar(CP_ACP, 0, azstr, -1, mzwchar, 255); apGraphics->DrawString(mzwchar, -1, apFont, PointF(afX,afY), &stringformatcentered, apBrush); } /** * Draws horizontally and vertically centered text */ void tcWindow::DrawTextCenteredHV(Gdiplus::Graphics* apGraphics, Gdiplus::Font* apFont, Gdiplus::Brush* apBrush, const char* azstr, float x, float y) { RectF r; MultiByteToWideChar(CP_ACP, 0, azstr, -1, mzwchar, 255); apGraphics->MeasureString(mzwchar, -1, apFont, PointF(0,0), &r); float dx = r.X + 0.5*r.Width; float dy = r.Y + 0.5*r.Height; apGraphics->DrawString(mzwchar, -1, apFont, PointF(x-dx,y-dy), apBrush); } void tcWindow::DrawTextInRect(Graphics* apGraphics, Font* apFont, Brush* apBrush, const char* azstr, RectF& rect) { MultiByteToWideChar(CP_ACP, 0, azstr, -1, mzwchar, 255); apGraphics->DrawString(mzwchar, -1, apFont, rect, &stringformatleftalign, apBrush); } void tcWindow::DrawTextInRectWrap(Graphics* apGraphics, Font* apFont, Brush* apBrush, const char* azstr, RectF& rect) { MultiByteToWideChar(CP_ACP, 0, azstr, -1, mzwchar, 255); apGraphics->DrawString(mzwchar, -1, apFont, rect, &stringformatwrap, apBrush); } void tcWindow::MeasureText(Graphics* apGraphics, Font* apFont, const char* azstr, SizeF& size) { RectF r; // this conversion ends up being done twice if DrawText is called after this MultiByteToWideChar(CP_ACP, 0, azstr, -1, mzwchar, 255); apGraphics->MeasureString(mzwchar,-1,apFont,PointF(0,0),&r); size.Width = r.Width; size.Height = r.Height; } /* Erase the surface with alpha = 0 */ void tcWindow::Erase() { mp2DSurface->Erase(); } /* Erase with alpha = 0xFF */ void tcWindow::EraseOpaque() { mp2DSurface->EraseOpaque(); } void tcWindow::Freeze() { if (!mbFrozen) wxWindow::Freeze(); mbFrozen = true; } wxBitmap* tcWindow::GetBitmap() { return mp2DSurface->GetBitmap(); } bool tcWindow::IsSurfaceModified() { return mp2DSurface->mbModified; } void tcWindow::LoadBackgroundImage(char *azFileName) { char zBuff[64]; if (mpiBackground != NULL) {delete mpiBackground;} // de-allocate existing image strcpy(zBuff,IMAGE_PATH); strcat(zBuff,azFileName); MultiByteToWideChar(CP_ACP, 0, zBuff, -1, mzwchar, 255); mpiBackground = new Image(mzwchar,false); if (mpiBackground==NULL) {WTL("tcWindow::LoadBackgroundImage - failed to load background image");} } /** * Loads image (prepends image path automatically) */ Gdiplus::Image* tcWindow::LoadImage(const char *fileName) { Gdiplus::Image* image; std::string path = IMAGE_PATH; path += fileName; MultiByteToWideChar(CP_ACP, 0, path.c_str(), -1, mzwchar, 255); image = new Image(mzwchar,false); if (image==NULL) { std::cerr << "tcWindow::LoadImage - " << path << " failed." << std::endl; } return image; } void tcWindow::SetBackground(UINT32 anColor) { mp2DSurface->SetBackground(anColor); } /** * @return alpha blending state for window. */ bool tcWindow::GetBlend() { return mp2DSurface->GetBlend(); } /** * Used to enable or disable (default state) alpha blending * for window. */ void tcWindow::SetBlend(bool blendingOn) { mp2DSurface->SetBlend(blendingOn); } void tcWindow::SetOpaque() { mp2DSurface->SetOpaque(); } void tcWindow::SetPixel(int x, int y, unsigned int value) { if (mp2DSurface != NULL) { mp2DSurface->SetPixel(x,y,value); } } /* draw background image if one is loaded, otherwise fill with black */ void tcWindow::DrawBackground(Graphics *apGraphics) { if (mpiBackground == NULL) { Color startcolor; mpBrushDefault->GetColor(&startcolor); mpBrushDefault->SetColor(Color(255,0,0,0)); apGraphics->FillRectangle(mpBrushDefault,0,0,mnWidth,mnHeight); mpBrushDefault->SetColor(startcolor); } else { apGraphics->DrawImage(mpiBackground,0,0); } } /* Draw a border */ void tcWindow::DrawBorder() { mp2DSurface->DrawBorder(); } /** * Sets region of window to display. This is intended * to provide a zoomed view of a window e.g. the view * area of the terrain map is a small region of the overall * map that is zoomed to fit the map window. * @param r RectF structure defining the display region bounds. */ void tcWindow::SetDisplayRegion(RectF r) { mp2DSurface->SetDisplayRegion(r.X,r.Y,r.GetRight(),r.GetBottom()); mrectDisplay = r; } void tcWindow::MoveToTop() { if (!tcGraphicsEngine::Get()->MoveSurfaceToTop(mp2DSurface)) { std::cerr << "Error - tcWindow::MoveToTop() - surface not found" << std::endl; } if (mbCloned) { std::cerr << "Warning - tcWindow::MoveToTop() - called on shared surface" << std::endl; } } void tcWindow::MoveWindow(int ax, int ay) { mrectWindow.left = ax; mrectWindow.top = ay; mrectWindow.right = ax + mnWidth; mrectWindow.bottom = ay + mnHeight; if (yMirror) mp2DSurface->MoveWindow(ax,yMirror-mrectWindow.bottom); else mp2DSurface->MoveWindow(ax,ay); wxWindow::Move(wxPoint(ax,ay)); } void tcWindow::Thaw() { if (mbFrozen) { wxWindow::Thaw(); mbFrozen = false; } } ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// tcWindow::tcWindow(wxWindow *parent, const wxPoint& pos, const wxSize& size, const wxString& name, tcWindow *sharedSurfaceHost) : wxWindow(parent, -1, pos, size, wxTRANSPARENT_WINDOW | wxNO_FULL_REPAINT_ON_RESIZE, name), //| wxNO_FULL_REPAINT_ON_RESIZE |wxCLIP_CHILDREN mnHeight(size.GetHeight()), mnWidth(size.GetWidth()) { wxWindow::SetBackgroundColour(*wxBLACK); wxWindow::Show(FALSE); mbActive = false; mp2DSurface = NULL; mrectWindow.left = pos.x; mrectWindow.right = pos.x + size.GetWidth(); mrectWindow.top = pos.y; mrectWindow.bottom = pos.y + size.GetHeight(); mpiBackground = NULL; mbFrozen = false; if (sharedSurfaceHost) { mbCloned = true; resizeable2DSurface = false; yMirror = 0; tcWindow::ShareSurfaceWith(sharedSurfaceHost); if (parent == static_cast<wxWindow*>(sharedSurfaceHost)) // if parent matches sharedSurfaceHost { sharedSurfaceHost->AddChild(this); // adds this to parent's list of children to draw } } else { mbCloned = false; resizeable2DSurface = true; wxSize parentSize = parent->GetSize(); yMirror = parentSize.GetHeight(); if (!CreateSurfaces(tcGraphicsEngine::Get())) { throw "Failed to create 2D surface"; } } mhFontDefault = CreateFont(20,0,0,0,FW_BOLD,FALSE,FALSE,FALSE, ANSI_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY, DEFAULT_PITCH|FF_MODERN,"Arial"); if (mhFontDefault == NULL) { WTL("mhFontDefault creation failed\n"); ShowAndAbort("mhFontDefault creation failed\n"); } FontFamily ff(L"Arial"); mpFontDefault = new Font(&ff,16,FontStyleBold,UnitPixel); if (mpFontDefault == NULL) {WTL("tcWindow - mpFontDefault creation failed\n");} mpBrushDefault = new SolidBrush(Color(0xFEFFFFFF)); // color is ARGB if (mpBrushDefault == NULL) {WTL("tcWindow - mpBrushDefault creation failed\n");} stringformatleftalign.SetFormatFlags(StringFormatFlagsNoWrap); stringformatleftalign.SetAlignment(StringAlignmentNear); stringformatleftalign.SetTrimming(StringTrimmingEllipsisCharacter); //stringformatleftalign.SetTrimming(StringTrimmingNone); //stringformatwrap.SetFormatFlags(StringFormatFlagsWrap); stringformatwrap.SetAlignment(StringAlignmentNear); stringformatwrap.SetTrimming(StringTrimmingEllipsisCharacter); stringformatcentered.SetAlignment(StringAlignmentCenter); } tcWindow::~tcWindow() { if (mpFontDefault != NULL) {delete mpFontDefault;} if (mpBrushDefault != NULL) {delete mpBrushDefault;} if (mpiBackground != NULL) {delete mpiBackground;} // delete surface if not a shared surface if (!mbCloned) { if (!tcGraphicsEngine::Get()->Delete2DSurface(mp2DSurface)) { std::cerr << "Warning - tcWindow::~tcWindow() 2D surface not found" << std::endl; } } } --- tcwindow.cpp DELETED --- |
|
From: Xavi <xr...@us...> - 2004-04-04 21:59:55
|
Update of /cvsroot/gcblue/gcb_wx/src/graphics In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24153 Added Files: tcSceneHandler.cpp Removed Files: tcscenehandler.cpp Log Message: + changed lowercase tcscenehandler.cpp to tcSceneHandler.cpp, according to the includes from other files and the name of the class --- tcscenehandler.cpp DELETED --- --- NEW FILE: tcSceneHandler.cpp --- #include "wx/wx.h" #include "wx/msw/private.h" // for MS Windows specific definitions #include "tcscenehandler.h" #include <graphics/tcGraphicsEngine.h> #include <osgProducer/OsgSceneHandler> tcSceneHandler::tcSceneHandler(osg::DisplaySettings *ds) : osgProducer::OsgSceneHandler(ds) { graphicsEngine = NULL; } tcSceneHandler::~tcSceneHandler() { } void tcSceneHandler::drawImplementation(Producer::Camera& camera) { if (graphicsEngine) { graphicsEngine->RenderAll(); } } |
|
From: Xavi <xr...@us...> - 2004-04-04 21:42:04
|
Update of /cvsroot/gcblue/gcb_wx/include/graphics In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21016 Added Files: tcSceneHandler.h Removed Files: tcscenehandler.h Log Message: + changed lowercase tcscenehandler.h to tcSceneHandler.h, according to the includes from other files and the name of the class --- tcscenehandler.h DELETED --- --- NEW FILE: tcSceneHandler.h --- #ifndef _SCENEHANDLER_H_ #define _SCENEHANDLER_H_ //#include <osg/DisplaySettings> #include <osgProducer/OsgSceneHandler> class tcGraphicsEngine; class tcSceneHandler : public osgProducer::OsgSceneHandler { public: void cullImplementation(Producer::Camera& camera) {} void drawImplementation(Producer::Camera& camera); void SetGraphicsEngine(tcGraphicsEngine *ge) {graphicsEngine = ge;} tcSceneHandler(osg::DisplaySettings *ds = NULL); ~tcSceneHandler(); private: tcGraphicsEngine *graphicsEngine; }; #endif |
|
From: Xavi <xr...@us...> - 2004-04-04 21:34:26
|
Update of /cvsroot/gcblue/gcb_wx/include/graphics In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19767 Added Files: tcWindow.h Removed Files: tcwindow.h Log Message: + changed lowercase tcwindow.h to tcWindow.h, according to the includes from other files and the name of the class --- NEW FILE: tcWindow.h --- /* ** tcWindow.h ** ** Copyright (C) 2003 Dewitt "Cole" Colclough (de...@tw...) ** All rights reserved. ** This file is part of the Global Conflict Blue (GCB) program. ** GCB is free software; you can redistribute it and/or modify ** it under the terms of version 2 of the GNU General Public License as ** published by the Free Software Foundation. ** GCB is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** You should have received a copy of the GNU General Public License ** along with GCB; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #if !defined _TCWINDOW_H_ #define _TCWINDOW_H_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #include "wx/wx.h" #include "wx/msw/private.h" // for MS Windows specific definitions #include "gdiplus.h" #include <vector> class tcGraphicsEngine; // forward declaration for better encapsulation class tc2DGraphicsSurface; #define IMAGE_PATH "images\\" /** * Window class for drawing to a tc2DGraphicsSurface (bitmap) * with GDI+. */ class tcWindow : public wxWindow { public: bool mbActive; Gdiplus::RectF mrectDisplay; void AddChild(tcWindow* child); bool IsBackgroundLoaded() {return mpiBackground != NULL;} virtual int Draw(); virtual void Draw(Gdiplus::Graphics *graphics); virtual void DrawChildren(Gdiplus::Graphics *graphics); virtual int DrawTest(); void DrawBackground(Gdiplus::Graphics *apGraphics); void DrawBorder(void); void DrawText(Gdiplus::Graphics* apGraphics, Gdiplus::Font* apFont, Gdiplus::Brush* apBrush, const char* azstr, float afX, float afY); void DrawText(Gdiplus::Graphics* apGraphics, Gdiplus::Font* apFont, Gdiplus::Brush* apBrush, const char* azstr, float afX, float afY, Gdiplus::RectF& r); // returns bounding box in r void DrawTextCentered(Gdiplus::Graphics* apGraphics, Gdiplus::Font* apFont, Gdiplus::Brush* apBrush, const char* azstr, float afX, float afY); void DrawTextCenteredHV(Gdiplus::Graphics* apGraphics, Gdiplus::Font* apFont, Gdiplus::Brush* apBrush, const char* azstr, float x, float y); void DrawTextInRect(Gdiplus::Graphics* apGraphics, Gdiplus::Font* apFont, Gdiplus::Brush* apBrush, const char* azstr, Gdiplus::RectF& rect); void DrawTextInRectWrap(Gdiplus::Graphics* apGraphics, Gdiplus::Font* apFont, Gdiplus::Brush* apBrush, const char* azstr, Gdiplus::RectF& rect); void MeasureText(Gdiplus::Graphics* apGraphics, Gdiplus::Font* apFont, const char* azstr, Gdiplus::SizeF& size); void Erase(void); void EraseOpaque(void); virtual void Freeze(); wxBitmap* GetBitmap(); bool IsSurfaceModified(); void LoadBackgroundImage(char *azFileName); Gdiplus::Image* LoadImage(const char *fileName); void MoveToTop(); ///< moves window to top void SetBackground(UINT32 anColor); bool GetBlend(); void SetBlend(bool blendingOn); void SetOpaque(void); void SetPixel(int x, int y, unsigned int value); void GetWindow(RECT& r) {r = mrectWindow;} void SetDisplayRegion(Gdiplus::RectF r); tc2DGraphicsSurface* GetSurface() const {return mp2DSurface;} void MoveWindow(int ax, int ay); bool GetDrawDC(HDC& hdc); bool ReleaseDrawDC(HDC hdc); bool GetGraphics(Gdiplus::Graphics*& rpGraphics); // GDI+ bool GetLowQualityGraphics(Gdiplus::Graphics*& rpGraphics); // GDI+ bool ReleaseGraphics(Gdiplus::Graphics* apGraphics); // GDI+ virtual void SetActive(bool abActive); void SetRenderTexture(bool abState); void SetResizeable2D(bool abState) {resizeable2DSurface = abState;} ///< @see tcWindow::OnSize void SetSkipCount(unsigned skipCount); virtual void SetYMirror(int y) {yMirror = y;} virtual void Thaw(); tcWindow(wxWindow *parent, const wxPoint& pos, const wxSize& size, const wxString& name = "tcWindow", tcWindow *sharedSurfaceHost = NULL); virtual ~tcWindow(); protected: std::vector<tcWindow*> children; tc2DGraphicsSurface* mp2DSurface; RECT mrectWindow; // location for map in back buffer int mnWidth; ///< window dimension--tried to make const, but problem in tcTerrainView int mnHeight; int yMirror; ///< workaround for opposite y directions of OpenGL vs. wxWindows /// true if 2DSurface should be resized with window, normally false for zoomed surfaces /// such as with the tcTerrainView /// @see tcWindow::OnSize view OnSize method code to see how this is used bool resizeable2DSurface; HFONT mhFontDefault; Gdiplus::Font *mpFontDefault; // GDI+ font Gdiplus::SolidBrush *mpBrushDefault; Gdiplus::Image *mpiBackground; // background image WCHAR mzwchar[255]; // for GDI+ DrawString conversion bool mbCloned; bool mbFrozen; virtual int CreateSurfaces(tcGraphicsEngine* apGraphicsEngine); virtual int DeleteSurfaces(tcGraphicsEngine* apGraphicsEngine); WCHAR* PrependImagePath(const char *azFileName); virtual void OnChar(wxKeyEvent& event); virtual void OnEnterWindow(wxMouseEvent& event); void OnEraseBackground(wxEraseEvent& event); virtual void OnKeyDown(wxKeyEvent& event); virtual void OnKillFocus(wxFocusEvent& event); virtual void OnLButtonDown(wxMouseEvent& event); virtual void OnLButtonUp(wxMouseEvent& event); virtual void OnLeaveWindow(wxMouseEvent& event); virtual void OnMouseMove(wxMouseEvent& event); virtual void OnMouseWheel(wxMouseEvent& event); virtual void OnMove(wxMoveEvent& event); void OnPaint(wxPaintEvent& event); virtual void OnRButtonDown(wxMouseEvent& event); virtual void OnSetFocus(wxFocusEvent& event); virtual void OnShow(wxShowEvent& event); virtual void OnSize(wxSizeEvent& event); void SkipMouseEvent(wxMouseEvent& event); ///< adjusts position to parent frame long MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); private: HDC mhdc; Gdiplus::StringFormat stringformatleftalign; Gdiplus::StringFormat stringformatwrap; Gdiplus::StringFormat stringformatcentered; void ShareSurfaceWith(const tcWindow* apWindow); // shares 2D surface with apWindow DECLARE_EVENT_TABLE() }; #endif --- tcwindow.h DELETED --- |
|
From: Xavi <xr...@us...> - 2004-04-04 21:13:15
|
Update of /cvsroot/gcblue/gcb_wx/src/network In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16306 Modified Files: tcConnectionData.cpp tcMessage.cpp tcNetworkInterface.cpp Log Message: + newline at the end of file Index: tcMessage.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/network/tcMessage.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** tcMessage.cpp 6 Mar 2004 20:52:29 -0000 1.3 --- tcMessage.cpp 4 Apr 2004 21:00:43 -0000 1.4 *************** *** 163,165 **** } ! END_NAMESPACE \ No newline at end of file --- 163,166 ---- } ! END_NAMESPACE ! Index: tcConnectionData.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/network/tcConnectionData.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** tcConnectionData.cpp 6 Mar 2004 20:52:29 -0000 1.3 --- tcConnectionData.cpp 4 Apr 2004 21:00:43 -0000 1.4 *************** *** 294,296 **** } ! END_NAMESPACE \ No newline at end of file --- 294,297 ---- } ! END_NAMESPACE ! Index: tcNetworkInterface.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/network/tcNetworkInterface.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** tcNetworkInterface.cpp 6 Mar 2004 20:52:29 -0000 1.6 --- tcNetworkInterface.cpp 4 Apr 2004 21:00:43 -0000 1.7 *************** *** 761,763 **** } ! END_NAMESPACE \ No newline at end of file --- 761,764 ---- } ! END_NAMESPACE ! |
|
From: Xavi <xr...@us...> - 2004-04-04 21:09:08
|
Update of /cvsroot/gcblue/gcb_wx/include/network In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15509 Modified Files: tcNetworkInterface.h Log Message: + added ifdef MSV for #pragma once instruction + newline at the end of function + removed comma at the end of enum + modified order of attribute declaration to match the order of initialization Index: tcNetworkInterface.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/network/tcNetworkInterface.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** tcNetworkInterface.h 6 Mar 2004 20:52:29 -0000 1.6 --- tcNetworkInterface.h 4 Apr 2004 20:56:36 -0000 1.7 *************** *** 23,27 **** --- 23,29 ---- #define _NETWORKINTERFACE_H_ + #if _MSC_VER > 1000 #pragma once + #endif #include "wx/wx.h" *************** *** 34,37 **** --- 36,40 ---- #include "tcConnectionData.h" #include "tcMessage.h" + #include "gctypes.h" #define BEGIN_NAMESPACE(x) namespace x { *************** *** 42,46 **** class tcNetworkInterface : public wxEvtHandler { ! friend tcConnectionData; public: enum --- 45,49 ---- class tcNetworkInterface : public wxEvtHandler { ! friend class tcConnectionData; public: enum *************** *** 53,57 **** MESSAGE_BUFFER_SIZE = 128, UDP_EVENT_ID = -123, ! MAX_UDP_SIZE = 4096, }; --- 56,60 ---- MESSAGE_BUFFER_SIZE = 128, UDP_EVENT_ID = -123, ! MAX_UDP_SIZE = 4096 }; *************** *** 81,91 **** NOT_CONNECTED, IS_CONNECTING, ! IS_CONNECTED, } connectState; bool isServer; ///< true if this interface is acting as a server, false if client UINT32 connectionStartTime; wxIPV4address hostAddress; - int connectionIndex; ///< counter used to assigned connection id wxSocketClient *clientSock; ///< single socket that will be used in client mode --- 84,94 ---- NOT_CONNECTED, IS_CONNECTING, ! IS_CONNECTED } connectState; + int connectionIndex; ///< counter used to assigned connection id bool isServer; ///< true if this interface is acting as a server, false if client UINT32 connectionStartTime; wxIPV4address hostAddress; wxSocketClient *clientSock; ///< single socket that will be used in client mode *************** *** 125,127 **** END_NAMESPACE ! #endif \ No newline at end of file --- 128,131 ---- END_NAMESPACE ! #endif ! |
|
From: Xavi <xr...@us...> - 2004-04-04 21:06:43
|
Update of /cvsroot/gcblue/gcb_wx/include/network In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15086 Modified Files: tcMultiplayerInterface.h Log Message: + added ifdef MSV for #pragma once instruction + newline at the end of function + removed comma at the end of enum Index: tcMultiplayerInterface.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/network/tcMultiplayerInterface.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** tcMultiplayerInterface.h 6 Mar 2004 20:52:29 -0000 1.3 --- tcMultiplayerInterface.h 4 Apr 2004 20:54:12 -0000 1.4 *************** *** 23,27 **** --- 23,29 ---- #define _MULTIPLAYERINTERFACE_H_ + #if _MSC_VER > 1000 #pragma once + #endif #include <queue> *************** *** 63,67 **** { MSG_CHATTEXT = 1, ! MSG_USERNAME = 2, }; static tcMultiplayerInterface& Get(); --- 65,69 ---- { MSG_CHATTEXT = 1, ! MSG_USERNAME = 2 }; static tcMultiplayerInterface& Get(); *************** *** 103,105 **** END_NAMESPACE ! #endif \ No newline at end of file --- 105,108 ---- END_NAMESPACE ! #endif ! |
|
From: Xavi <xr...@us...> - 2004-04-04 21:04:55
|
Update of /cvsroot/gcblue/gcb_wx/include/network In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14650 Modified Files: tcMessage.h Log Message: + added ifdef MSV for #pragma once instruction + newline at the end of function + removed comma at the end of enum Index: tcMessage.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/network/tcMessage.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** tcMessage.h 6 Mar 2004 20:52:29 -0000 1.3 --- tcMessage.h 4 Apr 2004 20:52:23 -0000 1.4 *************** *** 23,28 **** #define _TCMESSAGE_H_ #pragma once ! #define BEGIN_NAMESPACE(x) namespace x { --- 23,29 ---- #define _TCMESSAGE_H_ + #if _MSC_VER > 1000 #pragma once ! #endif #define BEGIN_NAMESPACE(x) namespace x { *************** *** 39,43 **** HEADER_SIZE = 8, SIZE_SIZE = 2, ///< size of messageSize field (first field in header) ! MESSAGE_SIZE = BUFFER_SIZE - HEADER_SIZE, }; unsigned int timestamp; --- 40,44 ---- HEADER_SIZE = 8, SIZE_SIZE = 2, ///< size of messageSize field (first field in header) ! MESSAGE_SIZE = BUFFER_SIZE - HEADER_SIZE }; unsigned int timestamp; *************** *** 71,73 **** END_NAMESPACE ! #endif \ No newline at end of file --- 72,75 ---- END_NAMESPACE ! #endif ! |