gcblue-commits Mailing List for Global Conflict Blue (Page 26)
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...> - 2005-05-17 00:22:05
|
Update of /cvsroot/gcblue/gcb_wx/database In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32418/database Modified Files: database.db Log Message: New feature to display 3D models for sensor tracks based on track position (only generic models for now) Index: database.db =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/database/database.db,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 Binary files /tmp/cvsGp0lnH and /tmp/cvsiy2W5e differ |
|
From: Dewitt C. <ddc...@us...> - 2005-05-17 00:22:03
|
Update of /cvsroot/gcblue/gcb_wx/xml In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32418/xml Modified Files: chat_box.xml network_view.xml options.xml Log Message: New feature to display 3D models for sensor tracks based on track position (only generic models for now) Index: options.xml =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/xml/options.xml,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** options.xml 31 Mar 2005 03:51:13 -0000 1.17 --- options.xml 17 May 2005 00:20:41 -0000 1.18 *************** *** 1,4 **** <Options> ! <HostAddress>192.168.0.102</HostAddress> <DisplaySettings>default</DisplaySettings> <LastScenarioPath>GroundSAMTest.py</LastScenarioPath> --- 1,4 ---- <Options> ! <HostAddress>192.168.0.101</HostAddress> <DisplaySettings>default</DisplaySettings> <LastScenarioPath>GroundSAMTest.py</LastScenarioPath> *************** *** 10,12 **** --- 10,13 ---- <AutoKillAssessment /> <ShakeAirCamera /> + <UserName>Dewitt</UserName> </Options> Index: network_view.xml =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/xml/network_view.xml,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** network_view.xml 8 Apr 2005 01:54:12 -0000 1.9 --- network_view.xml 17 May 2005 00:20:41 -0000 1.10 *************** *** 12,21 **** </RadioButton> ! <EditIP X="30" Y="300" Width="180" Height="25" BarX="10.0" BarY="5.0" BarWidth="160.0" BarHeight="14.0" Caption="IP Address"/> <Button X="240" Y="305" Width="65" Height="15" Caption="Connect" Command="160"/> <Button X="340" Y="305" Width="65" Height="15" Caption="Join Game" Command="170"/> <StatusBox X="250" Y="130" Width="220" Height="120"/> ! <ChatBox X="30" Y="350" Width="400" Height="200" FontSize="11.0" DrawBorder="1"/> ! <ChatEntry X="30" Y="556" Width="400" Height="16" BarX="0.0" BarY="1.0" BarWidth="400.0" BarHeight="14.0" Caption=""/> <RadioButton X="30" Y="190" Width="115" Height="40" Caption="Chat Protocol" Command="180"> --- 12,25 ---- </RadioButton> ! <EditIP X="30" Y="300" Width="180" Height="25" BarX="10.0" BarY="5.0" BarWidth="160.0" BarHeight="14.0" FontSize="14.0" Caption="IP Address"/> ! <EditName X="30" Y="350" Width="180" Height="25" BarX="10.0" BarY="5.0" BarWidth="160.0" BarHeight="14.0" FontSize="14.0" Caption="Username"/> ! <EditPassword X="30" Y="400" Width="180" Height="25" BarX="10.0" BarY="5.0" BarWidth="160.0" BarHeight="14.0" FontSize="14.0" Caption="Password" PasswordMode="1"/> ! <Button X="240" Y="305" Width="65" Height="15" Caption="Connect" Command="160"/> <Button X="340" Y="305" Width="65" Height="15" Caption="Join Game" Command="170"/> <StatusBox X="250" Y="130" Width="220" Height="120"/> ! ! <ChatBox X="30" Y="450" Width="450" Height="250" FontSize="14.0" Wrap="70" DrawBorder="1"/> ! <ChatEntry X="30" Y="706" Width="450" Height="16" BarX="0.0" BarY="1.0" BarWidth="450.0" BarHeight="14.0" FontSize="14.0" Caption=""/> <RadioButton X="30" Y="190" Width="115" Height="40" Caption="Chat Protocol" Command="180"> Index: chat_box.xml =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/xml/chat_box.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** chat_box.xml 2 Mar 2005 22:28:45 -0000 1.2 --- chat_box.xml 17 May 2005 00:20:41 -0000 1.3 *************** *** 1,5 **** <Window> ! <ChatBox X="10" Y="10" Width="280" Height="145" FontSize="9.0" DrawBorder="1"/> ! <ChatEntry X="10" Y="160" Width="280" Height="16" BarX="0.0" BarY="1.0" BarWidth="280.0" BarHeight="14.0" Caption="" DrawBorder="1"/> </Window> \ No newline at end of file --- 1,5 ---- <Window> ! <ChatBox X="10" Y="10" Width="400" Height="250" FontSize="14.0" Wrap="70" DrawBorder="1"/> ! <ChatEntry X="10" Y="260" Width="400" Height="16" BarX="0.0" BarY="1.0" BarWidth="400.0" BarHeight="14.0" Caption="" FontSize="14.0" DrawBorder="1"/> </Window> \ No newline at end of file |
|
From: Dewitt C. <ddc...@us...> - 2005-05-17 00:22:00
|
Update of /cvsroot/gcblue/gcb_wx/src/sim In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32418/src/sim Modified Files: tcSensorMap.cpp tcSensorTrackIterator.cpp Added Files: tcSensorMapTrack.cpp Log Message: New feature to display 3D models for sensor tracks based on track position (only generic models for now) Index: tcSensorTrackIterator.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcSensorTrackIterator.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** tcSensorTrackIterator.cpp 11 Dec 2004 01:09:08 -0000 1.1 --- tcSensorTrackIterator.cpp 17 May 2005 00:20:41 -0000 1.2 *************** *** 159,162 **** --- 159,181 ---- } + /** + * Version that doesn't require region argument + */ + tcSensorTrackIterator::tcSensorTrackIterator(unsigned int alliance_, unsigned int classificationMask) + : + useRegion(false), + alliance(alliance_), + classMask(classificationMask) + { + if (!simState) + { + simState = tcSimState::Get(); + } + + map = simState->mcSensorMap.GetMap(alliance); + + First(); + } + tcSensorTrackIterator::tcSensorTrackIterator() : useRegion(false), Index: tcSensorMap.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcSensorMap.cpp,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** tcSensorMap.cpp 6 May 2005 23:57:52 -0000 1.20 --- tcSensorMap.cpp 17 May 2005 00:20:40 -0000 1.21 *************** *** 36,619 **** - /******************************* tcSensorMapTrack ****************************/ - tcDatabase* tcSensorMapTrack::database = NULL; - tcSimState* tcSensorMapTrack::simState = NULL; - unsigned int tcSensorMapTrack::ambiguityListUpdates = 0; - bool tcSensorMapTrack::autoKillAssess = false; - - - /** - * Set to true to automatically check and mark stale tracks that - * are destroyed. - */ - void tcSensorMapTrack::SetAutoKillAssess(bool state) - { - autoKillAssess = state; - } - - - - - /** - * Loads state from update stream - */ - tcUpdateStream& tcSensorMapTrack::operator<<(tcUpdateStream& stream) - { - tcTrack::operator<<(stream); - - stream >> mnContributors; - for (int n = 0; n < mnContributors; n++) - { - stream >> maSensorReport[n].mfTimestamp; - } - - stream >> sensorFlags; - - return stream; - } - - /** - * Saves state to update stream - */ - tcUpdateStream& tcSensorMapTrack::operator>>(tcUpdateStream& stream) - { - tcTrack::operator>>(stream); - - stream << mnContributors; - for (int n = 0; n < mnContributors; n++) - { - stream << maSensorReport[n].mfTimestamp; - } - - stream << sensorFlags; - - return stream; - } - - /** - * @return false if id already in engaged vector - */ - bool tcSensorMapTrack::AddEngagement(long id) - { - if (id == -1) return false; - - unsigned nEngaged = engaged.size(); - for(unsigned n=0;n<nEngaged;n++) - { - if (engaged[n] == id) return false; - } - engaged.push_back(id); - return true; - } - - /** - * @return false if id already in intercepts vector - */ - bool tcSensorMapTrack::AddIntercept(long id) - { - if (id == -1) return false; - - unsigned nIntercepts = intercepts.size(); - for(unsigned n=0;n<nIntercepts;n++) - { - if (intercepts[n] == id) return false; - } - intercepts.push_back(id); - return true; - } - - - void tcSensorMapTrack::Clear() - { - for (int k=0; k<mnContributors; k++) - { - tcSensorReport* sensorReport = &maSensorReport[k]; - sensorReport->Clear(); - } - - mnContributors = 0; - mnEmitters = 0; - mnDatabaseID = -1; - assessedDamage = 0; - intercepts.clear(); - engaged.clear(); - - tcTrack::Clear(); - } - - /** - * @return number of contributors to this track - */ - unsigned tcSensorMapTrack::GetContributorCount() const - { - return (unsigned)mnContributors; - } - - /** - * @return name of contributing platform <idx> or pointer to "" if bad idx - */ - const char* tcSensorMapTrack::GetContributorName(unsigned idx) const - { - static const std::string emptyString(""); - - if (idx >= (unsigned)mnContributors) return emptyString.c_str(); - - long contributorId = maSensorReport[idx].mnSensorPlatformID; - if (tcGameObject* obj = simState->GetObject(contributorId)) - { - return obj->mzUnit.mz; - } - else - { - return emptyString.c_str(); - } - } - - - unsigned tcSensorMapTrack::GetEngagedCount() const - { - return engaged.size(); - } - - - unsigned tcSensorMapTrack::GetInterceptCount() const - { - return intercepts.size(); - } - /** - * This method is called periodically to cleanup the engaged vector. - * There will be some lag between the state of this vector and true - * state in the sim. - */ - void tcSensorMapTrack::UpdateEngagements() - { - wxASSERT(simState); - int nEngaged = (int)engaged.size(); - for (int n=nEngaged-1;n>=0;n--) - { - long id = engaged[n]; - tcWeaponObject *weapon = dynamic_cast<tcWeaponObject*>(simState->GetObject(id)); - if (weapon) - { - if (!weapon->IsIntendedTarget(tcTrack::mnID)) - { - engaged.erase(engaged.begin() + n); // weapon isn't targeting track - } - } - else // weapon doesn't exist anymore, erase engaged id - { - engaged.erase(engaged.begin() + n); - } - - } - } - - /** - * This method is called periodically to cleanup the intercepts vector. - * There will be some lag between the state of this vector and true - * state in the sim. - */ - void tcSensorMapTrack::UpdateIntercepts() - { - wxASSERT(simState); - - int nIntercepts = (int)intercepts.size(); - for (int n=nIntercepts-1;n>=0;n--) - { - long id = intercepts[n]; - tcPlatformObject *platform = dynamic_cast<tcPlatformObject*>(simState->GetObject(id)); - if (platform) - { - if (!platform->IsInterceptingTrack(tcTrack::mnID)) - { - intercepts.erase(intercepts.begin() + n); // platform isn't intercepting track - } - } - else // platform doesn't exist anymore, erase intercepts id - { - intercepts.erase(intercepts.begin() + n); - } - - } - } - - - bool tcSensorMapTrack::UpdateEmitter(tsEmitterInfo*& rpEmitterInfo, tnPoolIndex anEmitterID) { - // search for existing match - for(int n=0;n<mnEmitters;n++) { - tsEmitterInfo *pEmitterInfo = &maEmitterInfo[n]; - if (pEmitterInfo->mnEmitterID == anEmitterID) { - rpEmitterInfo = pEmitterInfo; - return true; - } - } - // add new emitter if there is room - if (mnEmitters < MAX_EMITTERS) { - rpEmitterInfo = &maEmitterInfo[mnEmitters++]; - rpEmitterInfo->mnEmitterID = anEmitterID; - rpEmitterInfo->mfTimestamp = 0; - rpEmitterInfo->mnMode = 0; - - UpdateAmbiguityList(); - return true; - } - return false; - } - - - bool tcSensorMapTrack::UpdateActiveReport(Sensor::tcSensorReport*& rpReport, tnPoolIndex anSensorID) - { - int nPassiveIdx = -1; - - // search for existing match - for(int n=0; n<mnContributors; n++) - { - tcSensorReport *pSensorReport = &maSensorReport[n]; - if (pSensorReport->mnFlags & (TRACK_BEARING_ONLY|TRACK_TRIANGULATED)) - { - nPassiveIdx = n; // used to have "int nPassiveIdx = n;" here !? - } - else if (pSensorReport->mnSensorPlatformID == anSensorID) - { - rpReport = pSensorReport; - return true; - } - } - - // add new report if there is room - if (mnContributors < MAX_SENSOR_REPORTS) - { - tcSensorReport *pSensorReport = &maSensorReport[mnContributors++]; - pSensorReport->Clear(); - pSensorReport->mnSensorPlatformID = anSensorID; - rpReport = pSensorReport; - return true; - } - - // overwrite passive with active if one exists - if (nPassiveIdx >= 0) - { - tcSensorReport *pSensorReport = &maSensorReport[nPassiveIdx]; - pSensorReport->Clear(); - pSensorReport->mnSensorPlatformID = anSensorID; - rpReport = pSensorReport; - return true; - } - - rpReport = NULL; - return false; - } - - /** - * Using database, updates ambiguity list of platforms - * consistent with detected emitters - */ - void tcSensorMapTrack::UpdateAmbiguityList() - { - ambiguityList.clear(); - - // return if coarse classification is not available - if (mnClassification == PTYPE_UNKNOWN) return; - if (mnEmitters < 1) return; - - std::vector<long> emitterList; - for (int n=0; n<mnEmitters; n++) - { - emitterList.push_back(maEmitterInfo[n].mnEmitterID); - } - - tcDatabaseIterator iter(mnClassification); - for (iter.First(); !iter.IsDone(); iter.Next()) - { - bool platformMatches = false; - tcDatabaseObject* obj = iter.Get(); - wxASSERT(obj); - if (tcGenericDBObject* generic = dynamic_cast<tcGenericDBObject*>(obj)) - { - if (generic->HasAllEmitters(emitterList)) platformMatches = true; - } - else if (tcMissileDBObject* missile = dynamic_cast<tcMissileDBObject*>(obj)) - { - if (missile->HasAllEmitters(emitterList)) platformMatches = true; - } - - if (platformMatches) - { - ambiguityList.push_back(obj->mnKey); - } - - } - - /* use esm ambiguity list for identification if platform not - ** identified, and there is exactly one entry in ambiguity list */ - if ((ambiguityList.size() == 1) && (mnDatabaseID == -1)) - { - mnDatabaseID = ambiguityList[0]; - } - - ambiguityListUpdates++; - } - - bool tcSensorMapTrack::UpdatePassiveReport(Sensor::tcSensorReport*& rpReport, tnPoolIndex anSensorID) { - //int nPassiveIdx = -1; - - // if track already has active data then do not update with passive data - if (tcTrack::mnFlags & TRACK_ACTIVE) {return false;} - - // search for existing match - for(int n=0;n<mnContributors;n++) - { - tcSensorReport *pSensorReport = &maSensorReport[n]; - if ((pSensorReport->mnFlags & (TRACK_BEARING_ONLY|TRACK_TRIANGULATED))&& - (pSensorReport->mnSensorPlatformID == anSensorID)) - { - rpReport = pSensorReport; - return true; - } - } - - // add new report if there is room - if (mnContributors < MAX_SENSOR_REPORTS) - { - tcSensorReport *pSensorReport = &maSensorReport[mnContributors++]; - pSensorReport->Clear(); - pSensorReport->mnSensorPlatformID = anSensorID; - rpReport = pSensorReport; - return true; - } - - rpReport = NULL; - return false; - } - - - void tcSensorMapTrack::UpdateClassification(UINT16 mnClassification, teAffiliation meAffiliation, - tnPoolIndex databaseID) - { - if (mnClassification != 0) - { - tcTrack::mnClassification |= mnClassification; - } - if (meAffiliation != UNKNOWN) - { - tcTrack::mnAffiliation = meAffiliation; - } - if (databaseID != -1) - { - mnDatabaseID = databaseID; - } - - UpdateAmbiguityList(); - - } - - - /** - * check if reporting sensor has reported, if so update report - * if not add new report if slots are free - */ - bool tcSensorMapTrack::AddReport(const Sensor::tcSensorReport& report) - { - // search for existing match - for(int n=0;n<mnContributors;n++) - { - tcSensorReport *pSensorReport = &maSensorReport[n]; - //bool bActivePassiveMatch = (pSensorReport->mnFlags & report.mnFlags & TRACK_BEARING_ONLY); - if ((pSensorReport->mnSensorPlatformID == report.mnSensorPlatformID)) - { - *pSensorReport = report; - return true; - } - } - // add new report if there is room - if (mnContributors < MAX_SENSOR_REPORTS) - { - maSensorReport[mnContributors] = report; - mnContributors++; - return true; - } - return false; - } - - /** - * Queries simState to check if track object exists. If - * not the track is marked as destroyed. - * This assumes that the track id matches the simState object - * id. This assumption will be invalid someday once the two - * sets of ids are decoupled. - * TODO repair for this - */ - void tcSensorMapTrack::KillAssess() - { - if (simState->GetObject(mnID) == 0) - { - MarkDestroyed(); - #ifdef _DEBUG - fprintf(stdout, "Track %d marked destroyed\n", mnID); - #endif - } - } - - /** - * check for update reports and update track - */ - void tcSensorMapTrack::UpdateTrack() - { - - if (autoKillAssess) - { - if (IsStale() && !IsDestroyed()) - { - KillAssess(); - } - } - - // find first new active report since last update and update track - for(int n=0;n<mnContributors;n++) - { - tcSensorReport *pSensorReport = &maSensorReport[n]; - if ((!(pSensorReport->mnFlags & (TRACK_BEARING_ONLY|TRACK_TRIANGULATED))) - &&(pSensorReport->mfTimestamp > tcTrack::mfTimestamp)) - { - int bSpeedValid = (pSensorReport->mnFlags & TRACK_SPEED_VALID) ; - int bHeadingValid = (pSensorReport->mnFlags & TRACK_HEADING_VALID); - int bAltValid = (pSensorReport->mnFlags & TRACK_ALT_VALID); - - tcTrack::mnID = pSensorReport->mnTrackID; - tcTrack::mfLat_rad = pSensorReport->mfLat_rad; - tcTrack::mfLon_rad = pSensorReport->mfLon_rad; - tcTrack::mfTimestamp = pSensorReport->mfTimestamp; - - tcTrack::mnFlags = TRACK_ACTIVE; - if (bHeadingValid) - { - tcTrack::mfHeading_rad = pSensorReport->mfHeading_rad; - tcTrack::mnFlags |= TRACK_HEADING_VALID; - } - if (bSpeedValid) - { - tcTrack::mfSpeed_kts = pSensorReport->mfSpeed_kts; - tcTrack::mnFlags |= TRACK_SPEED_VALID; - } - if (bAltValid) - { - tcTrack::mfAlt_m = pSensorReport->mfAlt_m; - tcTrack::mnFlags |= TRACK_ALT_VALID; - } - return; - } - } - - // if the track is passive update with first new passive - if (tcTrack::mnFlags & TRACK_ACTIVE) {return;} - - for(int n=0;n<mnContributors;n++) - { - tcSensorReport *pSensorReport = &maSensorReport[n]; - if ((pSensorReport->mnFlags & (TRACK_BEARING_ONLY | TRACK_TRIANGULATED)) - &&(pSensorReport->mfTimestamp > tcTrack::mfTimestamp)) - { - tcTrack::mnID = pSensorReport->mnTrackID; - tcTrack::mfLat_rad = pSensorReport->mfLat_rad; - tcTrack::mfLon_rad = pSensorReport->mfLon_rad; - tcTrack::mfHeading_rad = pSensorReport->mfHeading_rad; - tcTrack::mfSpeed_kts = pSensorReport->mfSpeed_kts; - tcTrack::mfTimestamp = pSensorReport->mfTimestamp; - tcTrack::mnFlags = pSensorReport->mnFlags; - - tcTrack::mnPassivePlatformID = pSensorReport->mnSensorPlatformID; - return; - } - } - - - } - - /** - * remove report n and shift other reports to fill array from beginning - */ - void tcSensorMapTrack::RemoveReport(int n) - { - if ((n<0)||(n>=mnContributors)) {return;} - for(int k=n+1;k<mnContributors;k++) - { - maSensorReport[k-1] = maSensorReport[k]; - } - mnContributors--; - } - - bool tcSensorMapTrack::IsDestroyed() const - { - return (sensorFlags & TRACK_DESTROYED) != 0; - } - - bool tcSensorMapTrack::IsStale() const - { - return (sensorFlags & TRACK_STALE) != 0; - } - - void tcSensorMapTrack::MarkDestroyed() - { - sensorFlags |= TRACK_DESTROYED; - } - - void tcSensorMapTrack::MarkStale() - { - sensorFlags |= TRACK_STALE; - } - - void tcSensorMapTrack::ClearStale() - { - sensorFlags &= (~TRACK_STALE); - } - - - - - tcSensorMapTrack& tcSensorMapTrack::operator= (const tcSensorMapTrack& t) - { - *(tcTrack*)this = t ; - - for(int i=0;i<MAX_SENSOR_REPORTS;i++) - { - maSensorReport[i] = t.maSensorReport[i]; - } - mnContributors = t.mnContributors; - - for(int j=0;j<MAX_EMITTERS;j++) - { - maEmitterInfo[j] = t.maEmitterInfo[j]; - } - - mnEmitters = t.mnEmitters; - mnDatabaseID = t.mnDatabaseID; - sensorFlags = t.sensorFlags; - intercepts = t.intercepts; - engaged = t.engaged; - assessedDamage = t.assessedDamage; - - return(*this); - } - - tcSensorMapTrack::tcSensorMapTrack() - : sensorFlags(0), - mnEmitters(0), - mnContributors(0), - mnDatabaseID(-1), - assessedDamage(0) - { - tcTrack::mnID = NULL_INDEX; - tcTrack::mnAffiliation = 0; - tcTrack::mnAlliance = 0; - tcTrack::mnClassification = 0; - tcTrack::mfTimestamp = 0; - tcTrack::mnFlags = 0; - - } - - tcSensorMapTrack::~tcSensorMapTrack() - { - } /******************************* tcAllianceSensorMap ****************************/ --- 36,40 ---- --- NEW FILE: tcSensorMapTrack.cpp --- /** ** @file tcSensorMapTrack.cpp */ /* Copyright (C) 2003-2005 Dewitt 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" #include "tcSensorMapTrack.h" #include "aerror.h" #include "simmath.h" #include "tcSimState.h" #include "tcWeaponObject.h" #include "tcGenericDBObject.h" #include "common/tcObjStream.h" #include "tcDatabaseIterator.h" #include "tc3DModel.h" #ifdef _DEBUG #define new DEBUG_NEW #endif using namespace Sensor; /******************************* tcSensorMapTrack ****************************/ tcDatabase* tcSensorMapTrack::database = NULL; tcSimState* tcSensorMapTrack::simState = NULL; unsigned int tcSensorMapTrack::ambiguityListUpdates = 0; bool tcSensorMapTrack::autoKillAssess = false; /** * Set to true to automatically check and mark stale tracks that * are destroyed. */ void tcSensorMapTrack::SetAutoKillAssess(bool state) { autoKillAssess = state; } /** * Loads state from update stream */ tcUpdateStream& tcSensorMapTrack::operator<<(tcUpdateStream& stream) { tcTrack::operator<<(stream); stream >> mnContributors; for (int n = 0; n < mnContributors; n++) { stream >> maSensorReport[n].mfTimestamp; } stream >> sensorFlags; return stream; } /** * Saves state to update stream */ tcUpdateStream& tcSensorMapTrack::operator>>(tcUpdateStream& stream) { tcTrack::operator>>(stream); stream << mnContributors; for (int n = 0; n < mnContributors; n++) { stream << maSensorReport[n].mfTimestamp; } stream << sensorFlags; return stream; } /** * @return false if id already in engaged vector */ bool tcSensorMapTrack::AddEngagement(long id) { if (id == -1) return false; unsigned nEngaged = engaged.size(); for(unsigned n=0;n<nEngaged;n++) { if (engaged[n] == id) return false; } engaged.push_back(id); return true; } /** * @return false if id already in intercepts vector */ bool tcSensorMapTrack::AddIntercept(long id) { if (id == -1) return false; unsigned nIntercepts = intercepts.size(); for(unsigned n=0;n<nIntercepts;n++) { if (intercepts[n] == id) return false; } intercepts.push_back(id); return true; } void tcSensorMapTrack::Clear() { for (int k=0; k<mnContributors; k++) { tcSensorReport* sensorReport = &maSensorReport[k]; sensorReport->Clear(); } mnContributors = 0; mnEmitters = 0; mnDatabaseID = -1; assessedDamage = 0; intercepts.clear(); engaged.clear(); tcTrack::Clear(); } /** * @return number of contributors to this track */ unsigned tcSensorMapTrack::GetContributorCount() const { return (unsigned)mnContributors; } /** * @return name of contributing platform <idx> or pointer to "" if bad idx */ const char* tcSensorMapTrack::GetContributorName(unsigned idx) const { static const std::string emptyString(""); if (idx >= (unsigned)mnContributors) return emptyString.c_str(); long contributorId = maSensorReport[idx].mnSensorPlatformID; if (tcGameObject* obj = simState->GetObject(contributorId)) { return obj->mzUnit.mz; } else { return emptyString.c_str(); } } unsigned tcSensorMapTrack::GetEngagedCount() const { return engaged.size(); } unsigned tcSensorMapTrack::GetInterceptCount() const { return intercepts.size(); } tc3DModel* tcSensorMapTrack::GetModel() const { return model; } void tcSensorMapTrack::SetModel(tc3DModel* model_) { if (model) delete model; model = model_; } /** * This method is called periodically to cleanup the engaged vector. * There will be some lag between the state of this vector and true * state in the sim. */ void tcSensorMapTrack::UpdateEngagements() { wxASSERT(simState); int nEngaged = (int)engaged.size(); for (int n=nEngaged-1;n>=0;n--) { long id = engaged[n]; tcWeaponObject *weapon = dynamic_cast<tcWeaponObject*>(simState->GetObject(id)); if (weapon) { if (!weapon->IsIntendedTarget(tcTrack::mnID)) { engaged.erase(engaged.begin() + n); // weapon isn't targeting track } } else // weapon doesn't exist anymore, erase engaged id { engaged.erase(engaged.begin() + n); } } } /** * This method is called periodically to cleanup the intercepts vector. * There will be some lag between the state of this vector and true * state in the sim. */ void tcSensorMapTrack::UpdateIntercepts() { wxASSERT(simState); int nIntercepts = (int)intercepts.size(); for (int n=nIntercepts-1;n>=0;n--) { long id = intercepts[n]; tcPlatformObject *platform = dynamic_cast<tcPlatformObject*>(simState->GetObject(id)); if (platform) { if (!platform->IsInterceptingTrack(tcTrack::mnID)) { intercepts.erase(intercepts.begin() + n); // platform isn't intercepting track } } else // platform doesn't exist anymore, erase intercepts id { intercepts.erase(intercepts.begin() + n); } } } bool tcSensorMapTrack::UpdateEmitter(tsEmitterInfo*& rpEmitterInfo, tnPoolIndex anEmitterID) { // search for existing match for(int n=0;n<mnEmitters;n++) { tsEmitterInfo *pEmitterInfo = &maEmitterInfo[n]; if (pEmitterInfo->mnEmitterID == anEmitterID) { rpEmitterInfo = pEmitterInfo; return true; } } // add new emitter if there is room if (mnEmitters < MAX_EMITTERS) { rpEmitterInfo = &maEmitterInfo[mnEmitters++]; rpEmitterInfo->mnEmitterID = anEmitterID; rpEmitterInfo->mfTimestamp = 0; rpEmitterInfo->mnMode = 0; UpdateAmbiguityList(); return true; } return false; } bool tcSensorMapTrack::UpdateActiveReport(Sensor::tcSensorReport*& rpReport, tnPoolIndex anSensorID) { int nPassiveIdx = -1; // search for existing match for(int n=0; n<mnContributors; n++) { tcSensorReport *pSensorReport = &maSensorReport[n]; if (pSensorReport->mnFlags & (TRACK_BEARING_ONLY|TRACK_TRIANGULATED)) { nPassiveIdx = n; // used to have "int nPassiveIdx = n;" here !? } else if (pSensorReport->mnSensorPlatformID == anSensorID) { rpReport = pSensorReport; return true; } } // add new report if there is room if (mnContributors < MAX_SENSOR_REPORTS) { tcSensorReport *pSensorReport = &maSensorReport[mnContributors++]; pSensorReport->Clear(); pSensorReport->mnSensorPlatformID = anSensorID; rpReport = pSensorReport; return true; } // overwrite passive with active if one exists if (nPassiveIdx >= 0) { tcSensorReport *pSensorReport = &maSensorReport[nPassiveIdx]; pSensorReport->Clear(); pSensorReport->mnSensorPlatformID = anSensorID; rpReport = pSensorReport; return true; } rpReport = NULL; return false; } /** * Using database, updates ambiguity list of platforms * consistent with detected emitters */ void tcSensorMapTrack::UpdateAmbiguityList() { ambiguityList.clear(); // return if coarse classification is not available if (mnClassification == PTYPE_UNKNOWN) return; if (mnEmitters < 1) return; std::vector<long> emitterList; for (int n=0; n<mnEmitters; n++) { emitterList.push_back(maEmitterInfo[n].mnEmitterID); } tcDatabaseIterator iter(mnClassification); for (iter.First(); !iter.IsDone(); iter.Next()) { bool platformMatches = false; tcDatabaseObject* obj = iter.Get(); wxASSERT(obj); if (tcGenericDBObject* generic = dynamic_cast<tcGenericDBObject*>(obj)) { if (generic->HasAllEmitters(emitterList)) platformMatches = true; } else if (tcMissileDBObject* missile = dynamic_cast<tcMissileDBObject*>(obj)) { if (missile->HasAllEmitters(emitterList)) platformMatches = true; } if (platformMatches) { ambiguityList.push_back(obj->mnKey); } } /* use esm ambiguity list for identification if platform not ** identified, and there is exactly one entry in ambiguity list */ if ((ambiguityList.size() == 1) && (mnDatabaseID == -1)) { mnDatabaseID = ambiguityList[0]; } ambiguityListUpdates++; } bool tcSensorMapTrack::UpdatePassiveReport(Sensor::tcSensorReport*& rpReport, tnPoolIndex anSensorID) { //int nPassiveIdx = -1; // if track already has active data then do not update with passive data if (tcTrack::mnFlags & TRACK_ACTIVE) {return false;} // search for existing match for(int n=0;n<mnContributors;n++) { tcSensorReport *pSensorReport = &maSensorReport[n]; if ((pSensorReport->mnFlags & (TRACK_BEARING_ONLY|TRACK_TRIANGULATED))&& (pSensorReport->mnSensorPlatformID == anSensorID)) { rpReport = pSensorReport; return true; } } // add new report if there is room if (mnContributors < MAX_SENSOR_REPORTS) { tcSensorReport *pSensorReport = &maSensorReport[mnContributors++]; pSensorReport->Clear(); pSensorReport->mnSensorPlatformID = anSensorID; rpReport = pSensorReport; return true; } rpReport = NULL; return false; } void tcSensorMapTrack::UpdateClassification(UINT16 mnClassification, teAffiliation meAffiliation, tnPoolIndex databaseID) { if (mnClassification != 0) { tcTrack::mnClassification |= mnClassification; } if (meAffiliation != UNKNOWN) { tcTrack::mnAffiliation = meAffiliation; } if (databaseID != -1) { mnDatabaseID = databaseID; } UpdateAmbiguityList(); } /** * check if reporting sensor has reported, if so update report * if not add new report if slots are free */ bool tcSensorMapTrack::AddReport(const Sensor::tcSensorReport& report) { // search for existing match for(int n=0;n<mnContributors;n++) { tcSensorReport *pSensorReport = &maSensorReport[n]; //bool bActivePassiveMatch = (pSensorReport->mnFlags & report.mnFlags & TRACK_BEARING_ONLY); if ((pSensorReport->mnSensorPlatformID == report.mnSensorPlatformID)) { *pSensorReport = report; return true; } } // add new report if there is room if (mnContributors < MAX_SENSOR_REPORTS) { maSensorReport[mnContributors] = report; mnContributors++; return true; } return false; } /** * Queries simState to check if track object exists. If * not the track is marked as destroyed. * This assumes that the track id matches the simState object * id. This assumption will be invalid someday once the two * sets of ids are decoupled. * TODO repair for this */ void tcSensorMapTrack::KillAssess() { if (simState->GetObject(mnID) == 0) { MarkDestroyed(); #ifdef _DEBUG fprintf(stdout, "Track %d marked destroyed\n", mnID); #endif } } /** * check for update reports and update track */ void tcSensorMapTrack::UpdateTrack() { if (autoKillAssess) { if (IsStale() && !IsDestroyed()) { KillAssess(); } } // find first new active report since last update and update track for(int n=0;n<mnContributors;n++) { tcSensorReport *pSensorReport = &maSensorReport[n]; if ((!(pSensorReport->mnFlags & (TRACK_BEARING_ONLY|TRACK_TRIANGULATED))) &&(pSensorReport->mfTimestamp > tcTrack::mfTimestamp)) { int bSpeedValid = (pSensorReport->mnFlags & TRACK_SPEED_VALID) ; int bHeadingValid = (pSensorReport->mnFlags & TRACK_HEADING_VALID); int bAltValid = (pSensorReport->mnFlags & TRACK_ALT_VALID); tcTrack::mnID = pSensorReport->mnTrackID; tcTrack::mfLat_rad = pSensorReport->mfLat_rad; tcTrack::mfLon_rad = pSensorReport->mfLon_rad; tcTrack::mfTimestamp = pSensorReport->mfTimestamp; tcTrack::mnFlags = TRACK_ACTIVE; if (bHeadingValid) { tcTrack::mfHeading_rad = pSensorReport->mfHeading_rad; tcTrack::mnFlags |= TRACK_HEADING_VALID; } if (bSpeedValid) { tcTrack::mfSpeed_kts = pSensorReport->mfSpeed_kts; tcTrack::mnFlags |= TRACK_SPEED_VALID; } if (bAltValid) { tcTrack::mfAlt_m = pSensorReport->mfAlt_m; tcTrack::mnFlags |= TRACK_ALT_VALID; } return; } } // if the track is passive update with first new passive if (tcTrack::mnFlags & TRACK_ACTIVE) {return;} for(int n=0;n<mnContributors;n++) { tcSensorReport *pSensorReport = &maSensorReport[n]; if ((pSensorReport->mnFlags & (TRACK_BEARING_ONLY | TRACK_TRIANGULATED)) &&(pSensorReport->mfTimestamp > tcTrack::mfTimestamp)) { tcTrack::mnID = pSensorReport->mnTrackID; tcTrack::mfLat_rad = pSensorReport->mfLat_rad; tcTrack::mfLon_rad = pSensorReport->mfLon_rad; tcTrack::mfHeading_rad = pSensorReport->mfHeading_rad; tcTrack::mfSpeed_kts = pSensorReport->mfSpeed_kts; tcTrack::mfTimestamp = pSensorReport->mfTimestamp; tcTrack::mnFlags = pSensorReport->mnFlags; tcTrack::mnPassivePlatformID = pSensorReport->mnSensorPlatformID; return; } } } /** * remove report n and shift other reports to fill array from beginning */ void tcSensorMapTrack::RemoveReport(int n) { if ((n<0)||(n>=mnContributors)) {return;} for(int k=n+1;k<mnContributors;k++) { maSensorReport[k-1] = maSensorReport[k]; } mnContributors--; } bool tcSensorMapTrack::IsDestroyed() const { return (sensorFlags & TRACK_DESTROYED) != 0; } bool tcSensorMapTrack::IsStale() const { return (sensorFlags & TRACK_STALE) != 0; } void tcSensorMapTrack::MarkDestroyed() { sensorFlags |= TRACK_DESTROYED; } void tcSensorMapTrack::MarkStale() { sensorFlags |= TRACK_STALE; } void tcSensorMapTrack::ClearStale() { sensorFlags &= (~TRACK_STALE); } tcSensorMapTrack& tcSensorMapTrack::operator= (const tcSensorMapTrack& t) { *(tcTrack*)this = t ; for(int i=0;i<MAX_SENSOR_REPORTS;i++) { maSensorReport[i] = t.maSensorReport[i]; } mnContributors = t.mnContributors; for(int j=0;j<MAX_EMITTERS;j++) { maEmitterInfo[j] = t.maEmitterInfo[j]; } mnEmitters = t.mnEmitters; mnDatabaseID = t.mnDatabaseID; sensorFlags = t.sensorFlags; intercepts = t.intercepts; engaged = t.engaged; assessedDamage = t.assessedDamage; /* model is deliberately not copied to avoid overhead. This is ** a side effect of mixing graphics and data within tcSensorMapTrack */ model = 0; return(*this); } tcSensorMapTrack::tcSensorMapTrack(const tcSensorMapTrack& src) : tcTrack(src), sensorFlags(src.sensorFlags), mnEmitters(src.mnEmitters), mnContributors(src.mnContributors), mnDatabaseID(src.mnDatabaseID), assessedDamage(src.assessedDamage), model(0) { } tcSensorMapTrack::tcSensorMapTrack() : sensorFlags(0), mnEmitters(0), mnContributors(0), mnDatabaseID(-1), assessedDamage(0), model(0) { tcTrack::mnID = NULL_INDEX; tcTrack::mnAffiliation = 0; tcTrack::mnAlliance = 0; tcTrack::mnClassification = 0; tcTrack::mfTimestamp = 0; tcTrack::mnFlags = 0; } tcSensorMapTrack::~tcSensorMapTrack() { /* model is used for multiplayer client and for enemy alliances in single-play, ** otherwise it will remain 0 */ if (model) { model->SetSmokeMode(0); model->UpdateEffects(); // clear smoke particle generator model->DetachFromParent(); delete model; } } |
|
From: Dewitt C. <ddc...@us...> - 2005-05-17 00:21:58
|
Update of /cvsroot/gcblue/gcb_wx/include/graphics In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32418/include/graphics Modified Files: tc3DModel.h tc3DViewer.h Log Message: New feature to display 3D models for sensor tracks based on track position (only generic models for now) Index: tc3DModel.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/graphics/tc3DModel.h,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** tc3DModel.h 21 Feb 2005 18:26:04 -0000 1.14 --- tc3DModel.h 17 May 2005 00:20:39 -0000 1.15 *************** *** 33,36 **** --- 33,37 ---- #include <osg/MatrixTransform> + class tc3DViewer; class tcGameObject; class tcParticleEffect; *************** *** 46,49 **** --- 47,56 ---- //} + namespace Sensor + { + class tcSensorMapTrack; + } + using Sensor::tcSensorMapTrack; + /** * animation description stored in CSV database entry *************** *** 84,87 **** --- 91,105 ---- { public: + /// info needed to locate and orient model within world + struct LocationParams + { + float x; + float y; + float z; + float yaw; + float pitch; + float roll; + bool isVisible; + }; enum { *************** *** 98,107 **** void DetachFromParent(); ! tcGameObject* GetGameObj() {return gameObj;} void GetLauncherInfo(unsigned int idx, osg::Vec3& pos, float& az); osg::ref_ptr<osg::Node> GetNode(); unsigned int GetNumParents(); float GetRadius(); float GetRadiusGeneric(); bool IsSmokeEnabled() const; --- 116,127 ---- void DetachFromParent(); ! tcGameObject* GetGameObj() const {return gameObj;} void GetLauncherInfo(unsigned int idx, osg::Vec3& pos, float& az); + void GetLocationParams(LocationParams& p); osg::ref_ptr<osg::Node> GetNode(); unsigned int GetNumParents(); float GetRadius(); float GetRadiusGeneric(); + tcSensorMapTrack* GetSensorTrack() const; bool IsSmokeEnabled() const; *************** *** 113,116 **** --- 133,137 ---- void SetSmokeMode(int mode) {smokeMode = mode;} void SetupUpdate(tcGameObject *obj); + void SetupUpdate(tcSensorMapTrack* track); void UpdateEffects(); void UpdateSmokePosition(float x, float y, float z); *************** *** 120,127 **** ~tc3DModel(); static void LoadUnknowns(); static void SetWorldFrame(osg::Group* worldFrame); - private: struct LauncherMountInfo --- 141,148 ---- ~tc3DModel(); + static void AttachViewer(tc3DViewer* v) {viewer = v;} static void LoadUnknowns(); static void SetWorldFrame(osg::Group* worldFrame); private: struct LauncherMountInfo *************** *** 147,150 **** --- 168,172 ---- static osg::ref_ptr<osg::Group> world; + static tc3DViewer* viewer; ///< to allow model to calculate its own location /// models for unidentified platforms *************** *** 154,160 **** static osg::ref_ptr<osg::Node> unknownSurface; static bool useSmoothing; ! ! tcGameObject *gameObj; ///< game object to use to update model state float distanceFromCamera; --- 176,183 ---- static osg::ref_ptr<osg::Node> unknownSurface; static bool useSmoothing; + ! tcGameObject* gameObj; ///< game object to use to update model state ! tcSensorMapTrack* sensorTrack; ///< sensor track to update model state float distanceFromCamera; Index: tc3DViewer.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/graphics/tc3DViewer.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** tc3DViewer.h 5 Mar 2005 22:37:51 -0000 1.7 --- tc3DViewer.h 17 May 2005 00:20:39 -0000 1.8 *************** *** 220,223 **** --- 220,225 ---- bool isMouseDown; std::map<int, osgText::Text*> textMap; + tc3DModel* defaultSensorModel; ///< default sensor model for non-ID'd tracks + void InitLight(); *************** *** 233,236 **** --- 235,239 ---- void UpdateModels(); void UpdateProjectionMatrix(const wxSize& windowSize); + void UpdateSensorModels(unsigned int alliance); void UpdateSky(DateZulu& dateZulu); |
|
From: Dewitt C. <ddc...@us...> - 2005-05-17 00:21:57
|
Update of /cvsroot/gcblue/gcb_wx In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32418 Modified Files: GCblue.vcproj Log Message: New feature to display 3D models for sensor tracks based on track position (only generic models for now) Index: GCblue.vcproj =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/GCblue.vcproj,v retrieving revision 1.91 retrieving revision 1.92 diff -C2 -d -r1.91 -r1.92 *** GCblue.vcproj 31 Mar 2005 03:51:10 -0000 1.91 --- GCblue.vcproj 17 May 2005 00:20:38 -0000 1.92 *************** *** 87,93 **** InlineFunctionExpansion="2" EnableIntrinsicFunctions="TRUE" ! FavorSizeOrSpeed="0" OmitFramePointers="TRUE" ! OptimizeForProcessor="2" OptimizeForWindowsApplication="TRUE" AdditionalIncludeDirectories="include;include/sim;include/scriptinterface;include/common;include/graphics;"C:\wxWindows-2.4.1\lib\msw";include\database" --- 87,93 ---- InlineFunctionExpansion="2" EnableIntrinsicFunctions="TRUE" ! FavorSizeOrSpeed="1" OmitFramePointers="TRUE" ! OptimizeForProcessor="3" OptimizeForWindowsApplication="TRUE" AdditionalIncludeDirectories="include;include/sim;include/scriptinterface;include/common;include/graphics;"C:\wxWindows-2.4.1\lib\msw";include\database" *************** *** 434,437 **** --- 434,440 ---- </File> <File + RelativePath=".\src\sim\tcControllableObject.cpp"> + </File> + <File RelativePath=".\src\sim\tcDemTileReader.cpp"> </File> *************** *** 512,515 **** --- 515,521 ---- </File> <File + RelativePath=".\src\sim\tcSensorMapTrack.cpp"> + </File> + <File RelativePath=".\src\sim\tcSensorPlatform.cpp"> </File> *************** *** 561,564 **** --- 567,579 ---- </File> <File + RelativePath=".\src\database\md5c.c"> + </File> + <File + RelativePath=".\src\database\md5class.cpp"> + </File> + <File + RelativePath=".\src\database\tcAccountDatabase.cpp"> + </File> + <File RelativePath="src\database\tcAirDBObject.cpp"> </File> *************** *** 631,634 **** --- 646,652 ---- Filter=""> <File + RelativePath=".\src\network\tcAuthenticationMessageHandler.cpp"> + </File> + <File RelativePath="src\network\tcConnectionData.cpp"> </File> *************** *** 1386,1389 **** --- 1404,1410 ---- </File> <File + RelativePath=".\include\sim\tcControllableObject.h"> + </File> + <File RelativePath=".\include\sim\tcDemTileReader.h"> </File> *************** *** 1467,1470 **** --- 1488,1494 ---- </File> <File + RelativePath=".\include\sim\tcSensorMapTrack.h"> + </File> + <File RelativePath=".\include\sim\tcSensorPlatform.h"> </File> *************** *** 1519,1522 **** --- 1543,1555 ---- </File> <File + RelativePath=".\include\database\md5.h"> + </File> + <File + RelativePath=".\include\database\md5class.h"> + </File> + <File + RelativePath=".\include\database\tcAccountDatabase.h"> + </File> + <File RelativePath="include\database\tcAirDBObject.h"> </File> *************** *** 1564,1567 **** --- 1597,1603 ---- </File> <File + RelativePath=".\include\database\tcPlayerDatabase.h"> + </File> + <File RelativePath="include\database\tcRadarDBObject.h"> </File> *************** *** 1595,1598 **** --- 1631,1637 ---- Filter=""> <File + RelativePath=".\include\network\tcAuthenticationMessageHandler.h"> + </File> + <File RelativePath="include\network\tcConnectionData.h"> </File> |
|
From: Dewitt C. <ddc...@us...> - 2005-05-17 00:21:55
|
Update of /cvsroot/gcblue/gcb_wx/scripts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32418/scripts Modified Files: Menu.py UnitCommands.py Log Message: New feature to display 3D models for sensor tracks based on track position (only generic models for now) Index: UnitCommands.py =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/scripts/UnitCommands.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** UnitCommands.py 29 Mar 2005 00:12:25 -0000 1.16 --- UnitCommands.py 17 May 2005 00:20:40 -0000 1.17 *************** *** 1,3 **** --- 1,9 ---- + def TakeControl(UI): + UI.TakeControl() + + def ReleaseControl(UI): + UI.ReleaseControl() + def AddEngageAllOrder(UI): UI.AddTask('EngageAll', 2.0) Index: Menu.py =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/scripts/Menu.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** Menu.py 29 Mar 2005 00:12:25 -0000 1.12 --- Menu.py 17 May 2005 00:20:40 -0000 1.13 *************** *** 60,63 **** --- 60,76 ---- if (not UnitInfo.IsValid()): return + + + # Multiplayer options + if (UnitInfo.IsMultiplayerActive()): + if (not UnitInfo.IsPlayerControlled()): + if (UnitInfo.IsAvailable()): + UnitMenu.AddItem('Take control', 'TakeControl') + return + else: + UnitMenu.AddItem('Unavailable unit', '') + return + + UnitMenu.AddItemUI('Change heading','SetHeading','Heading') # Speed submenu *************** *** 82,92 **** UnitMenu.AddItem('Tasks','') UnitMenu.BeginSubMenu() ! UnitMenu.AddItem('ZigZag patrol','AddPatrolOrder') UnitMenu.AddItemUI('Patrol station','AddPatrolStation', 'Datum') UnitMenu.AddItemUI('Add waypoint', 'AddWaypointOrder', 'Datum') ! UnitMenu.AddItem('EngageAll', 'AddEngageAllOrder') ! UnitMenu.AddItem('Missile alert', 'AddMissileWarnTask') ! UnitMenu.AddItem('Clear waypoints','ClearWaypoints') ! UnitMenu.AddItem('Clear all tasks','ClearTasks') UnitMenu.EndSubMenu() --- 95,105 ---- UnitMenu.AddItem('Tasks','') UnitMenu.BeginSubMenu() ! UnitMenu.AddItemUI('ZigZag patrol','AddPatrolOrder','Null') UnitMenu.AddItemUI('Patrol station','AddPatrolStation', 'Datum') UnitMenu.AddItemUI('Add waypoint', 'AddWaypointOrder', 'Datum') ! UnitMenu.AddItemUI('EngageAll', 'AddEngageAllOrder','Null') ! UnitMenu.AddItemUI('Missile alert', 'AddMissileWarnTask','Null') ! UnitMenu.AddItemUI('Clear waypoints','ClearWaypoints','Null') ! UnitMenu.AddItemUI('Clear all tasks','ClearTasks','Null') UnitMenu.EndSubMenu() *************** *** 110,113 **** --- 123,128 ---- UnitMenu.AddItem('Flight deck', 'ShowFlightPanel') + if (UnitInfo.IsPlayerControlled()): + UnitMenu.AddItem('Release control', 'ReleaseControl') |
|
From: Dewitt C. <ddc...@us...> - 2005-05-10 02:26:15
|
Update of /cvsroot/gcblue/gcb_wx/src/sim In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1860/src/sim Modified Files: tcFlightPort.cpp Log Message: Fix for aircraft getting stuck on runway at client Index: tcFlightPort.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcFlightPort.cpp,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** tcFlightPort.cpp 29 Apr 2005 18:52:55 -0000 1.16 --- tcFlightPort.cpp 10 May 2005 02:26:06 -0000 1.17 *************** *** 186,189 **** --- 186,192 ---- } + + ResyncSpots(); + /* request recreate if not all updates were matched (new child) ** or if not all children were update (deleted child) *************** *** 757,760 **** --- 760,800 ---- } + /** + * Workaround for multiplayer client. + * This clears spot info and reassigns units to spots based on the info in airstate + */ + void tcFlightPort::ResyncSpots() + { + // first clear the obj_info in each ready and launch spot + for (size_t n=0; n<ready_spots.size(); n++) + { + ready_spots[n].obj_info = 0; + } + + for (size_t n=0; n<launch_spots.size(); n++) + { + launch_spots[n].obj_info = 0; + } + + for (size_t n=0; n<units.size(); n++) + { + tcAirState* airstate = units[n]; + if (airstate->current_location == READY) + { + if ((airstate->current_spot >= 0) && (airstate->current_spot < ready_spots.size())) + { + ready_spots[airstate->current_spot].obj_info = airstate; + } + } + else if (airstate->current_location == LAUNCH) + { + if ((airstate->current_spot >= 0) && (airstate->current_spot < launch_spots.size())) + { + launch_spots[airstate->current_spot].obj_info = airstate; + } + } + } + } + //---------------------------------------------------------------------------- void tcFlightPort::SetObjectDestination(unsigned n, teLocation loc) *************** *** 884,888 **** int spot_idx = FindEmptySpot(airstate->goal_location, loc_vector); airstate->goal_spot = spot_idx; ! airstate->ready_time = afStatusTime + 300.0f; // short times for test MoveObjectToGoal(airstate); } --- 924,928 ---- int spot_idx = FindEmptySpot(airstate->goal_location, loc_vector); airstate->goal_spot = spot_idx; ! airstate->ready_time = afStatusTime + 30.0f; // short times for test MoveObjectToGoal(airstate); } |
|
From: Dewitt C. <ddc...@us...> - 2005-05-10 02:25:55
|
Update of /cvsroot/gcblue/gcb_wx/include/sim In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1746/include/sim Modified Files: tcFlightPort.h Log Message: Fix for aircraft getting stuck on runway at client Index: tcFlightPort.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/tcFlightPort.h,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** tcFlightPort.h 29 Apr 2005 18:52:02 -0000 1.10 --- tcFlightPort.h 10 May 2005 02:25:46 -0000 1.11 *************** *** 168,171 **** --- 168,173 ---- }; std::vector<CommandInfo> commandList; + + void ResyncSpots(); }; |
|
From: Dewitt C. <ddc...@us...> - 2005-05-08 23:29:08
|
Update of /cvsroot/gcblue/gcb_wx/src/sim In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17986/src/sim Modified Files: Game.cpp tcAirObject.cpp tcPlatformObject.cpp tcSimState.cpp Log Message: Landing bug fix, changed /gm create to require starting coords, added fuel to air update Index: tcSimState.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcSimState.cpp,v retrieving revision 1.79 retrieving revision 1.80 diff -C2 -d -r1.79 -r1.80 *** tcSimState.cpp 5 May 2005 02:14:55 -0000 1.79 --- tcSimState.cpp 8 May 2005 23:28:59 -0000 1.80 *************** *** 2626,2630 **** } ! void tcSimState::SetScenarioDescription(std::string s) { if (s.size() < SCEN_STRING_LENGTH) --- 2626,2635 ---- } ! const char* tcSimState::GetScenarioDescription() const ! { ! return msScenarioInfo.mzDescription; ! } ! ! void tcSimState::SetScenarioDescription(const std::string& s) { if (s.size() < SCEN_STRING_LENGTH) *************** *** 2648,2652 **** } ! void tcSimState::SetScenarioName(std::string s) { if (s.size() < 128) --- 2653,2657 ---- } ! void tcSimState::SetScenarioName(const std::string& s) { if (s.size() < 128) Index: tcPlatformObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcPlatformObject.cpp,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** tcPlatformObject.cpp 6 May 2005 23:57:51 -0000 1.44 --- tcPlatformObject.cpp 8 May 2005 23:28:59 -0000 1.45 *************** *** 287,297 **** UpdateFormationGuidance(); // formation heading/speed calculation ! UpdateHeading(dt_s); ! UpdateSpeed(dt_s); ! UpdateClimb(dt_s); ! ApplyRestrictions(); Move(dt_s); --- 287,305 ---- UpdateFormationGuidance(); // formation heading/speed calculation ! /* In multiplayer mode, skip command based updates for client objects not controlled ! ** by client. This will cause object to jump more but avoids having to broadcast command ! ** changes to all alliance clients. The controller of the object will see smoother ! ** behavior. ! */ ! if (!IsClientMode() || IsControlled()) ! { ! UpdateHeading(dt_s); ! UpdateSpeed(dt_s); ! UpdateClimb(dt_s); ! ApplyRestrictions(); ! } Move(dt_s); Index: tcAirObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcAirObject.cpp,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** tcAirObject.cpp 6 May 2005 23:57:51 -0000 1.22 --- tcAirObject.cpp 8 May 2005 23:28:59 -0000 1.23 *************** *** 65,68 **** --- 65,70 ---- tcPlatformObject::operator<<(stream); + stream >> fuel_kg; + stream >> maxPitch_rad; *************** *** 74,77 **** --- 76,81 ---- tcPlatformObject::operator>>(stream); + stream << fuel_kg; + stream << maxPitch_rad; Index: Game.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/Game.cpp,v retrieving revision 1.130 retrieving revision 1.131 diff -C2 -d -r1.130 -r1.131 *** Game.cpp 6 May 2005 23:57:51 -0000 1.130 --- Game.cpp 8 May 2005 23:28:59 -0000 1.131 *************** *** 1725,1729 **** if (isLagging) { ! dateTimeString += "[LAG]"; } --- 1725,1729 ---- if (isLagging) { ! dateTimeString += "L"; } |
|
From: Dewitt C. <ddc...@us...> - 2005-05-08 23:29:07
|
Update of /cvsroot/gcblue/gcb_wx/src/scriptinterface In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17986/src/scriptinterface Modified Files: tcPlatformInterface.cpp tcScenarioInterface.cpp tcSimPythonInterface.cpp Log Message: Landing bug fix, changed /gm create to require starting coords, added fuel to air update Index: tcPlatformInterface.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/scriptinterface/tcPlatformInterface.cpp,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** tcPlatformInterface.cpp 5 May 2005 02:14:53 -0000 1.44 --- tcPlatformInterface.cpp 8 May 2005 23:28:58 -0000 1.45 *************** *** 273,277 **** ** On client machine, only own-alliance objects exist in sim state */ ! if (pGameObj && (mpSimState->mpUserInfo->IsOwnAlliance(pGameObj->GetAlliance()))) { tcKinematics *pTargetKin = &pGameObj->mcKin; --- 273,278 ---- ** On client machine, only own-alliance objects exist in sim state */ ! bool isOwnAlliance = pGameObj && (pGameObj->GetAlliance() == mpPlatformObj->GetAlliance()); ! if (pGameObj && isOwnAlliance) { tcKinematics *pTargetKin = &pGameObj->mcKin; *************** *** 1162,1166 **** { tcGameObject* obj = mpSimState->GetObject(id); ! if ((obj == 0) || !mpSimState->mpUserInfo->IsOwnAlliance(obj->GetAlliance())) { return std::string(""); --- 1163,1169 ---- { tcGameObject* obj = mpSimState->GetObject(id); ! bool isOwnAlliance = mpPlatformObj->GetAlliance() == obj->GetAlliance(); ! ! if ((obj == 0) || !isOwnAlliance) { return std::string(""); *************** *** 1266,1270 **** { tcGameObject* obj = mpSimState->GetObject(id); ! if ((obj == 0) || !mpSimState->mpUserInfo->IsOwnAlliance(obj->GetAlliance())) { tcTrack data; --- 1269,1276 ---- { tcGameObject* obj = mpSimState->GetObject(id); ! ! bool isOwnAlliance = mpPlatformObj->GetAlliance() == obj->GetAlliance(); ! ! if ((obj == 0) || !isOwnAlliance) { tcTrack data; *************** *** 1285,1289 **** } ! tcFlightPortInterface tcPlatformInterface::GetFlightPortInfo(void) { tcFlightPortInterface fpi; --- 1291,1295 ---- } ! tcFlightPortInterface tcPlatformInterface::GetFlightPortInfo() { tcFlightPortInterface fpi; *************** *** 1297,1309 **** } ! void tcPlatformInterface::GetLocalObj(void) ! { ! wxASSERT(mpSimState); ! mpPlatformObj = mpStaticPlatformObj; ! GetSensorMap(); ! isPlatformOwnAlliance = (mpPlatformObj) ? ! (mpSimState->mpUserInfo->IsOwnAlliance(mpPlatformObj->GetAlliance()) != 0) : false; ! } /** --- 1303,1323 ---- } ! void tcPlatformInterface::GetLocalObj() ! { ! wxASSERT(mpSimState); ! mpPlatformObj = mpStaticPlatformObj; ! GetSensorMap(); ! ! if (mpSimState->IsMultiplayerServer()) ! { ! isPlatformOwnAlliance = mpPlatformObj != 0; ! } ! else ! { ! isPlatformOwnAlliance = (mpPlatformObj) ? ! (mpSimState->mpUserInfo->IsOwnAlliance(mpPlatformObj->GetAlliance()) != 0) : false; ! } ! } /** *************** *** 1316,1321 **** mpPlatformObj = obj; GetSensorMap(); ! isPlatformOwnAlliance = (mpPlatformObj) ? ! (mpSimState->mpUserInfo->IsOwnAlliance(mpPlatformObj->GetAlliance()) != 0) : false; } --- 1330,1343 ---- mpPlatformObj = obj; GetSensorMap(); ! ! if (mpSimState->IsMultiplayerServer()) ! { ! isPlatformOwnAlliance = mpPlatformObj != 0; ! } ! else ! { ! isPlatformOwnAlliance = (mpPlatformObj) ? ! (mpSimState->mpUserInfo->IsOwnAlliance(mpPlatformObj->GetAlliance()) != 0) : false; ! } } *************** *** 1339,1344 **** wxASSERT(mpSimState); ! isPlatformOwnAlliance = (mpPlatformObj) ? ! (mpSimState->mpUserInfo->IsOwnAlliance(mpPlatformObj->GetAlliance()) != 0) : false; mpSensorMap = mpSimState->mcSensorMap.GetMap(mpPlatformObj->GetAlliance()); --- 1361,1373 ---- wxASSERT(mpSimState); ! if (mpSimState->IsMultiplayerServer()) ! { ! isPlatformOwnAlliance = mpPlatformObj != 0; ! } ! else ! { ! isPlatformOwnAlliance = (mpPlatformObj) ? ! (mpSimState->mpUserInfo->IsOwnAlliance(mpPlatformObj->GetAlliance()) != 0) : false; ! } mpSensorMap = mpSimState->mcSensorMap.GetMap(mpPlatformObj->GetAlliance()); Index: tcSimPythonInterface.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/scriptinterface/tcSimPythonInterface.cpp,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** tcSimPythonInterface.cpp 6 May 2005 23:57:50 -0000 1.31 --- tcSimPythonInterface.cpp 8 May 2005 23:28:59 -0000 1.32 *************** *** 789,794 **** ! if (!mpSimState->IsMultiplayerClient()) { CallPython(command.c_str(), "Exception occured in ProcessCallbackString\n"); } --- 789,798 ---- ! if (mpSimState->IsMultiplayerServer()) { + #ifdef _DEBUG + fprintf(stdout, "Processed callback string:%s (%d ids)\n", command.c_str(), + id.size()); + #endif CallPython(command.c_str(), "Exception occured in ProcessCallbackString\n"); } *************** *** 876,889 **** void tcSimPythonInterface::SetMenuGroup(const std::vector<long>& unitIds) { ! // if any of the ids are invalid or not own-alliance, then return ! for (unsigned idx=0; idx<unitIds.size(); idx++) { ! tcGameObject* gameObj = mpSimState->GetObject(unitIds[idx]); ! if ((!gameObj) || ! (!mpSimState->mpUserInfo->IsOwnAlliance(gameObj->GetAlliance()))) { ! fprintf(stderr, "tcSimPythonInterface::SetMenuGroup - null or " ! " not own-alliance id\n"); ! return; } } --- 880,897 ---- void tcSimPythonInterface::SetMenuGroup(const std::vector<long>& unitIds) { ! // allow any units to be selected at multiplayer server, otherwise check ! if (!mpSimState->IsMultiplayerServer()) { ! // if any of the ids are invalid or not own-alliance, then return ! for (unsigned idx=0; idx<unitIds.size(); idx++) { ! tcGameObject* gameObj = mpSimState->GetObject(unitIds[idx]); ! if ((!gameObj) || ! (!mpSimState->mpUserInfo->IsOwnAlliance(gameObj->GetAlliance()))) ! { ! fprintf(stderr, "tcSimPythonInterface::SetMenuGroup - null or " ! " not own-alliance id\n"); ! return; ! } } } Index: tcScenarioInterface.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/scriptinterface/tcScenarioInterface.cpp,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** tcScenarioInterface.cpp 5 May 2005 02:14:53 -0000 1.25 --- tcScenarioInterface.cpp 8 May 2005 23:28:59 -0000 1.26 *************** *** 115,118 **** --- 115,123 ---- } + tcMapOverlay* tcScenarioInterface::GetMapOverlay() const + { + return overlay; + } + // Interface class management methods *************** *** 165,168 **** --- 170,174 ---- .def("SetScenarioLoaded",&tcScenarioInterface::SetScenarioLoaded) .def("SetScenarioName",&tcScenarioInterface::SetScenarioName) + .def("SetStartTheater", &tcScenarioInterface::SetStartTheater) .def("SetUserAlliance",&tcScenarioInterface::SetUserAlliance) // time/mode events *************** *** 495,498 **** --- 501,510 ---- } + void tcScenarioInterface::GetStartTheater(double& lon_deg, double& lat_deg) const + { + lon_deg = lon_theater_deg; + lat_deg = lat_theater_deg; + } + /** * Copies and sets root goal for alliance *************** *** 527,530 **** --- 539,550 ---- } + void tcScenarioInterface::SetStartTheater(double lon_deg, double lat_deg) + { + lon_theater_deg = lon_deg; + lat_theater_deg = lat_deg; + + ChangeMapTheater(lon_deg, lat_deg); + } + void tcScenarioInterface::SetUserAlliance(int alliance) { *************** *** 776,779 **** --- 796,809 ---- } + tcScenarioInterface::tcScenarioInterface() + : lon_theater_deg(0), + lat_theater_deg(0) + { + } + + tcScenarioInterface::~tcScenarioInterface() + { + } + } |
|
From: Dewitt C. <ddc...@us...> - 2005-05-08 23:29:07
|
Update of /cvsroot/gcblue/gcb_wx/src/network In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17986/src/network Modified Files: tcMultiplayerInterface.cpp tcTextMessageHandler.cpp tcUpdateMessageHandler.cpp Log Message: Landing bug fix, changed /gm create to require starting coords, added fuel to air update Index: tcUpdateMessageHandler.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/network/tcUpdateMessageHandler.cpp,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** tcUpdateMessageHandler.cpp 5 May 2005 02:14:52 -0000 1.15 --- tcUpdateMessageHandler.cpp 8 May 2005 23:28:58 -0000 1.16 *************** *** 35,38 **** --- 35,40 ---- #include "common/tcObjStream.h" #include "tcSimPythonInterface.h" + #include "tcScenarioInterface.h" + #include "tcMapOverlay.h" #ifdef _DEBUG *************** *** 124,127 **** --- 126,152 ---- } + void tcUpdateMessageHandler::AddScenarioInfo(tcUpdateStream& stream) + { + tcSimState* simState = tcSimState::Get(); + tcSimPythonInterface* pythonInterface = tcSimPythonInterface::Get(); + tcScenarioInterface* scenarioInterface = pythonInterface->GetScenarioInterface(); + tcMapOverlay* overlay = scenarioInterface->GetMapOverlay(); + + std::string scenarioName = simState->GetScenarioName(); + stream << scenarioName; + + std::string scenarioDescription = simState->GetScenarioDescription(); + stream << scenarioDescription; + + double theater_lon; + double theater_lat; + scenarioInterface->GetStartTheater(theater_lon, theater_lat); + stream << theater_lon; + stream << theater_lat; + + overlay->operator>>(stream); + + } + /** * Adds header information to sensor update stream *************** *** 202,205 **** --- 227,232 ---- case SCRIPT_COMMANDS: break; + case SCENARIO_INFO: + break; default: fprintf(stderr, "tcUpdateMessageHandler::InitializeMessage - bad message type\n"); *************** *** 318,321 **** --- 345,355 ---- } break; + case SCENARIO_INFO: + { + tcUpdateStream stream((const char*)data, messageSize); + stream >> messageType; + HandleScenarioInfo(stream); + } + break; default: fprintf(stderr, "tcUpdateMessageHandler::Handle - " *************** *** 606,609 **** --- 640,674 ---- } + void tcUpdateMessageHandler::HandleScenarioInfo(tcUpdateStream& stream) + { + tcSimState* simState = tcSimState::Get(); + tcSimPythonInterface* pythonInterface = tcSimPythonInterface::Get(); + tcScenarioInterface* scenarioInterface = pythonInterface->GetScenarioInterface(); + tcMapOverlay* overlay = scenarioInterface->GetMapOverlay(); + + wxASSERT(simState->IsMultiplayerClient()); + + std::string scenarioName; + stream >> scenarioName; + simState->SetScenarioName(scenarioName); + + std::string scenarioDescription; + stream >> scenarioDescription; + simState->SetScenarioDescription(scenarioDescription); + + simState->SetScenarioLoaded(true); + + double theater_lon; + double theater_lat; + stream >> theater_lon; + stream >> theater_lat; + if ((theater_lon != 0) && (theater_lat != 0)) + { + scenarioInterface->ChangeMapTheater(theater_lon, theater_lat); + } + + overlay->operator<<(stream); + } + /** * Handle SCRIPT_COMMANDS message (server only) Index: tcTextMessageHandler.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/network/tcTextMessageHandler.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** tcTextMessageHandler.cpp 6 May 2005 23:57:50 -0000 1.6 --- tcTextMessageHandler.cpp 8 May 2005 23:28:58 -0000 1.7 *************** *** 67,73 **** // send to tcMessageInterface in client mode (mode based popups of chat text) tcMessageInterface::Get()->PostChatText(text); } - chatText.push(text); } --- 67,73 ---- // send to tcMessageInterface in client mode (mode based popups of chat text) tcMessageInterface::Get()->PostChatText(text); + chatText.push(text); } } Index: tcMultiplayerInterface.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/network/tcMultiplayerInterface.cpp,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** tcMultiplayerInterface.cpp 6 May 2005 23:57:50 -0000 1.26 --- tcMultiplayerInterface.cpp 8 May 2005 23:28:58 -0000 1.27 *************** *** 257,260 **** --- 257,267 ---- playerStatus.isAuthenticated = true; SendSoundEffect(connectionId, "Welcome"); + + std::vector<int> connectionList; + connectionList.push_back(connectionId); + SendScenarioInfo(connectionList); + + wxString s = wxString::Format("*** %s has entered the game", playerStatus.GetNameWithRank().c_str()); + BroadcastChatText(s.c_str()); } else if (loginStatus == tcAccountDatabase::DUPLICATE_LOGIN) *************** *** 398,401 **** --- 405,410 ---- messageLength, (unsigned char*)buff, protocol); } + + chatText.push(message); } *************** *** 426,429 **** --- 435,450 ---- /** + * Broadcasts scenario info to all clients + * Should be used when scenario is changed + */ + void tcMultiplayerInterface::BroadcastScenarioInfo() + { + const std::vector<int>& destinations = GetConnectionVector(); + + SendScenarioInfo(destinations); + } + + + /** * Clears messageMap, deleting all message handlers */ *************** *** 464,467 **** --- 485,489 ---- } + const std::string& tcMultiplayerInterface::GetConnectionStatus(int connectionId) { *************** *** 475,478 **** --- 497,518 ---- } + /** + * Version that returns list of connection ids as vector (more expensive) + */ + const std::vector<int>& tcMultiplayerInterface::GetConnectionVector() const + { + static std::vector<int> connectionVector; + + connectionVector.clear(); + const std::list<int>& connectionList = GetConnectionList(); + for (std::list<int>::const_iterator k=connectionList.begin(); + k != connectionList.end(); ++k) + { + connectionVector.push_back(*k); + } + + return connectionVector; + } + wxEvtHandler* tcMultiplayerInterface::GetEvtHandler() const { *************** *** 728,734 **** // SendChatText(connectionId, " /gm getaccountdata '<username>' '<param>'"); // SendChatText(connectionId, " /gm setaccountdata '<username>' '<param>' <value>"); ! SendChatText(connectionId, " /gm create '<class>' '<unitname>' <alliance>"); SendChatText(connectionId, " /gm destroy <id>"); ! SendChatText(connectionId, " /gm move <id> <lat_deg> <lon_deg> (<alt>)"); // SendChatText(connectionId, " /gm reload <id>"); SendChatText(connectionId, " /gm repair <id>"); --- 768,774 ---- // SendChatText(connectionId, " /gm getaccountdata '<username>' '<param>'"); // SendChatText(connectionId, " /gm setaccountdata '<username>' '<param>' <value>"); ! SendChatText(connectionId, " /gm create '<class>' '<unitname>' <alliance> <lat_deg> <lon_deg> (<alt_m>)"); SendChatText(connectionId, " /gm destroy <id>"); ! SendChatText(connectionId, " /gm move <id> <lat_deg> <lon_deg> (<alt_m>)"); // SendChatText(connectionId, " /gm reload <id>"); SendChatText(connectionId, " /gm repair <id>"); *************** *** 841,851 **** { const char delim = '\''; ! wxString s1 = args.AfterFirst(delim); ! wxString unitClass = s1.BeforeFirst(delim); ! s1 = s1.AfterFirst(delim); ! s1 = s1.AfterFirst(delim); ! wxString unitName = s1.BeforeFirst(delim); ! s1 = s1.AfterFirst(delim); ! s1 = s1.AfterFirst(' '); long alliance = 0; if ((!s1.ToLong(&alliance)) || (alliance < 0)) --- 881,895 ---- { const char delim = '\''; ! wxString params = args.AfterFirst(delim); ! wxString unitClass = params.BeforeFirst(delim); ! params = params.AfterFirst(delim); ! params = params.AfterFirst(delim); ! wxString unitName = params.BeforeFirst(delim); ! params = params.AfterFirst(delim); ! ! ! params = params.AfterFirst(' '); ! wxString s1 = params.BeforeFirst(' '); ! long alliance = 0; if ((!s1.ToLong(&alliance)) || (alliance < 0)) *************** *** 856,859 **** --- 900,932 ---- } + double lat_deg = 0; + params = params.AfterFirst(' '); + s1 = params.BeforeFirst(' '); + if (!s1.ToDouble(&lat_deg)) + { + msg = wxString::Format("*** Bad latitude for /gm create"); + return; + } + + double lon_deg = 0; + params = params.AfterFirst(' '); + s1 = params.BeforeFirst(' '); + if (!s1.ToDouble(&lon_deg)) + { + msg = wxString::Format("*** Bad longitude for /gm create"); + return; + } + + double alt_m = 0; + params = params.AfterFirst(' '); + s1 = params.BeforeFirst(' '); + if (!s1.ToDouble(&alt_m)) + { + alt_m = 0; + } + + + + tcScenarioInterface* scenarioInterface = tcSimPythonInterface::Get()->GetScenarioInterface(); wxASSERT(scenarioInterface); *************** *** 863,869 **** unit.className = unitClass.c_str(); unit.unitName = unitName.c_str(); ! unit.lat = 0; ! unit.lon = 0; ! unit.alt = 0; unit.heading = 0; unit.speed = 0; --- 936,942 ---- unit.className = unitClass.c_str(); unit.unitName = unitName.c_str(); ! unit.lat = lat_deg; ! unit.lon = lon_deg; ! unit.alt = alt_m; unit.heading = 0; unit.speed = 0; *************** *** 1252,1255 **** --- 1325,1341 ---- } + void tcMultiplayerInterface::SendScenarioInfo(const std::vector<int>& destinations) + { + tcUpdateStream stream; + tcUpdateMessageHandler::InitializeMessage(tcUpdateMessageHandler::SCENARIO_INFO, stream); + tcUpdateMessageHandler::AddScenarioInfo(stream); + + for (unsigned n=0; n<destinations.size(); n++) + { + SendUpdateMessageTCP(destinations[n], stream); + } + + } + void tcMultiplayerInterface::SendSoundEffect(const std::string& player, const std::string& effect, long id) { *************** *** 1307,1310 **** --- 1393,1408 ---- } + void tcMultiplayerInterface::SendUpdateMessageTCP(int destination, tcStream& stream) + { + size_t streamSize = stream.size(); + char* buffer = new char[streamSize]; + stream.read(buffer, streamSize); + + networkInterface->SendMessage(destination, MSG_UPDATE, streamSize, (unsigned char*)buffer, + tcNetworkInterface::TCP); + + delete buffer; + } + /** * 0 - UDP, otherwise - TCP *************** *** 1471,1488 **** unsigned updateCount = 0; for (iter.First();iter.NotDone();iter.Next()) ! { ! tcGameObject* obj = iter.Get(); ! if ((pstatus.alliance == obj->GetAlliance()) || !IsServer()) ! { ! if (obj->HasNewCommand()) ! { ! tcUpdateMessageHandler::AddCommandUpdate(obj, commandStream); ! if (clearNewCmdFlag) obj->ClearNewCommand(); ! updateCount++; #ifdef _DEBUG ! fprintf(stdout, "%d ", obj->mnID); #endif ! } ! } // create new message if updateCount gets too large --- 1569,1589 ---- unsigned updateCount = 0; for (iter.First();iter.NotDone();iter.Next()) ! { ! tcGameObject* obj = iter.Get(); ! if (obj->HasNewCommand()) ! { ! if ((pstatus.alliance == obj->GetAlliance()) || !IsServer()) ! { ! tcUpdateMessageHandler::AddCommandUpdate(obj, commandStream); ! ! updateCount++; #ifdef _DEBUG ! fprintf(stdout, "%d ", obj->mnID); #endif ! } ! ! // extremely important! not clearing command will flood network ! if (clearNewCmdFlag) obj->ClearNewCommand(); ! } // create new message if updateCount gets too large *************** *** 1778,1783 **** eraseKeys.push(iter->first); tcSound::Get()->PlayEffect("fslide"); - LogOutPlayer(iter->second.name); } --- 1879,1895 ---- eraseKeys.push(iter->first); tcSound::Get()->PlayEffect("fslide"); LogOutPlayer(iter->second.name); + + if (IsServer()) + { + wxString msg = wxString::Format("*** %s has left the game", + iter->second.GetNameWithRank().c_str()); + BroadcastChatText(msg.c_str()); + } + else + { + chatText.push(std::string("Lost connection to server")); + wxMessageBox("Lost connection to server", "Network", wxICON_WARNING); + } } |
|
From: Dewitt C. <ddc...@us...> - 2005-05-08 23:29:07
|
Update of /cvsroot/gcblue/gcb_wx/src/graphics In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17986/src/graphics Modified Files: tcMapObject.cpp tcMapOverlay.cpp tcScenarioSelectView.cpp Log Message: Landing bug fix, changed /gm create to require starting coords, added fuel to air update Index: tcMapOverlay.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcMapOverlay.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** tcMapOverlay.cpp 31 Mar 2005 03:51:13 -0000 1.1 --- tcMapOverlay.cpp 8 May 2005 23:28:58 -0000 1.2 *************** *** 31,34 **** --- 31,36 ---- #include "tcMapObject.h" #include "tcMapObject.h" + #include "common/tcStream.h" + #include "common/tcObjStream.h" #ifdef _DEBUG *************** *** 36,39 **** --- 38,101 ---- #endif + + /** + * Loads state from stream + */ + tcUpdateStream& tcMapOverlay::operator<<(tcUpdateStream& stream) + { + overlayObjects.clear(); + unsigned int nObjects; + stream >> nObjects; + + for (unsigned int n=0; n<nObjects; n++) + { + unsigned char typeCode; + stream >> typeCode; + + if (typeCode == 1) + { + tcMapObject* obj = new tcMapTextObject(); + obj->operator<<(stream); + + AddMapObject(obj); + } + else + { + fprintf(stderr, "tcMapOverlay::operator<< -- unrecognized type code\n"); + wxASSERT(false); + } + } + + return stream; + } + + /** + * Saves state to stream + */ + tcUpdateStream& tcMapOverlay::operator>>(tcUpdateStream& stream) + { + unsigned int nObjects = overlayObjects.size(); + stream << nObjects; + + for (unsigned int n=0; n<nObjects; n++) + { + unsigned char typeCode = 0; + tcMapObject* obj = overlayObjects[n]; + if (dynamic_cast<tcMapTextObject*>(obj)) + { + typeCode = 1; + stream << typeCode; + overlayObjects[n]->operator>>(stream); + } + else + { + typeCode = 0; + stream << typeCode; + } + } + + return stream; + } + void tcMapOverlay::AddMapObject(tcMapObject *obj) { Index: tcMapObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcMapObject.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** tcMapObject.cpp 31 Mar 2005 03:51:12 -0000 1.7 --- tcMapObject.cpp 8 May 2005 23:28:58 -0000 1.8 *************** *** 33,36 **** --- 33,39 ---- #include "simmath.h" #include <osg/Geometry> + #include "common/tcStream.h" + #include "common/tcObjStream.h" + #ifdef _DEBUG *************** *** 44,47 **** --- 47,88 ---- osg::ref_ptr<osg::Geometry> tcMapObject::marker; + /** + * Loads state from stream + */ + tcUpdateStream& tcMapObject::operator<<(tcUpdateStream& stream) + { + stream >> color._v[0]; + stream >> color._v[1]; + stream >> color._v[2]; + stream >> color._v[3]; + + stream >> isActive; + stream >> markerEnabled; + stream >> useRelativeCoords; + stream >> _x; + stream >> _y; + + return stream; + } + + /** + * Saves state to stream + */ + tcUpdateStream& tcMapObject::operator>>(tcUpdateStream& stream) + { + stream << color._v[0]; + stream << color._v[1]; + stream << color._v[2]; + stream << color._v[3]; + + stream << isActive; + stream << markerEnabled; + stream << useRelativeCoords; + stream << _x; + stream << _y; + + return stream; + } + void tcMapObject::LoadMarker() { *************** *** 170,173 **** --- 211,240 ---- /********** tcMapTextObject **************/ + /** + * Loads state from stream + */ + tcUpdateStream& tcMapTextObject::operator<<(tcUpdateStream& stream) + { + tcMapObject::operator<<(stream); + + stream >> caption; + + return stream; + } + + + /** + * Saves state to stream + */ + tcUpdateStream& tcMapTextObject::operator>>(tcUpdateStream& stream) + { + tcMapObject::operator>>(stream); + + stream << caption; + + return stream; + } + + void tcMapTextObject::Draw(tc3DWindow* host) { Index: tcScenarioSelectView.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcScenarioSelectView.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** tcScenarioSelectView.cpp 27 Jan 2005 01:01:50 -0000 1.9 --- tcScenarioSelectView.cpp 8 May 2005 23:28:58 -0000 1.10 *************** *** 37,40 **** --- 37,41 ---- #include "tcSimPythonInterface.h" #include "common/tinyxml.h" + #include "network/tcMultiplayerInterface.h" #ifdef _DEBUG *************** *** 203,206 **** --- 204,209 ---- void tcScenarioSelectView::LoadScenario(std::string filePath, std::string caption) { + using network::tcMultiplayerInterface; + std::string totalPath = SCENARIO_PATH; totalPath += "\\"; // generalize this for Linux? *************** *** 222,225 **** --- 225,233 ---- tcOptions::Get()->SetOptionString("LastScenarioPath", filePath.c_str()); tcOptions::Get()->SetOptionString("LastScenarioName", caption.c_str()); + + if (mpSimState->IsMultiplayerServer()) + { + tcMultiplayerInterface::Get()->BroadcastScenarioInfo(); + } } else |
|
From: Dewitt C. <ddc...@us...> - 2005-05-08 23:28:12
|
Update of /cvsroot/gcblue/gcb_wx/include/sim In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17728/include/sim Modified Files: tcSimState.h Log Message: Landing bug fix, changed /gm create to require starting coords, added fuel to air update Index: tcSimState.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/tcSimState.h,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** tcSimState.h 5 May 2005 02:14:20 -0000 1.39 --- tcSimState.h 8 May 2005 23:27:57 -0000 1.40 *************** *** 152,155 **** --- 152,156 ---- void GetPlatformsWithinRegion(std::vector<long>& keyList, tcRect *apRegion); long GetRandomPlatform(); + const char* GetScenarioDescription() const; const char* GetScenarioName() const; int GetSeekerTrack(long anKey, tcTrack& track); *************** *** 181,187 **** bool IsMultiplayerServer() const; ! void SetScenarioDescription(std::string s); void SetScenarioLoaded(bool state); ! void SetScenarioName(std::string s); void SetTime(double afNewTime) {mfSimTime=afNewTime;} /////< Sets sim time, normally 0 at start of sim void SetTimeAcceleration(long accel); --- 182,188 ---- bool IsMultiplayerServer() const; ! void SetScenarioDescription(const std::string& s); void SetScenarioLoaded(bool state); ! void SetScenarioName(const std::string& s); void SetTime(double afNewTime) {mfSimTime=afNewTime;} /////< Sets sim time, normally 0 at start of sim void SetTimeAcceleration(long accel); |
|
From: Dewitt C. <ddc...@us...> - 2005-05-08 23:28:12
|
Update of /cvsroot/gcblue/gcb_wx/include/scriptinterface In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17728/include/scriptinterface Modified Files: tcScenarioInterface.h Log Message: Landing bug fix, changed /gm create to require starting coords, added fuel to air update Index: tcScenarioInterface.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/scriptinterface/tcScenarioInterface.h,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** tcScenarioInterface.h 5 May 2005 02:14:19 -0000 1.17 --- tcScenarioInterface.h 8 May 2005 23:27:57 -0000 1.18 *************** *** 106,109 **** --- 106,110 ---- tcDatum GetRandomDatum(double lon, double lat, float min_alt, float max_alt, float rand_offset); + void GetStartTheater(double& lon_deg, double& lat_deg) const; void SetAllianceGoal(int alliance, tcGoal& goal); void SetDateTime(int year, int month, int day, int hour, int min, int sec); *************** *** 111,114 **** --- 112,116 ---- void SetScenarioLoaded(bool state); void SetScenarioName(std::string s); + void SetStartTheater(double lon_deg, double lat_deg); void SetUserAlliance(int alliance); *************** *** 145,148 **** --- 147,152 ---- void Text3D(const std::string& text, double duration, float x, float y, float size, int effect); + tcMapOverlay* GetMapOverlay() const; + // goal class creation methods (cannot find a way to do directly) tcCompoundGoal CompoundGoal(int type); *************** *** 155,159 **** // Interface class management methods static object GetInterface(); ! static void InitPythonClasses(void); static void AddGoalClasses(boost::python::dict *dictionary); static void AttachDirector(tcDirector *dir) {director = dir;} --- 159,163 ---- // Interface class management methods static object GetInterface(); ! static void InitPythonClasses(); static void AddGoalClasses(boost::python::dict *dictionary); static void AttachDirector(tcDirector *dir) {director = dir;} *************** *** 162,169 **** static void AttachSimState(tcSimState *apSS) {simState = apSS;} private: double eventTime; ///< start time for briefing event functions tcGameObject* lastObjectAdded; ///< last object added to sim ! static tcDirector* director; static tcMapData* mapData; --- 166,178 ---- static void AttachSimState(tcSimState *apSS) {simState = apSS;} + tcScenarioInterface(); + ~tcScenarioInterface(); + private: double eventTime; ///< start time for briefing event functions tcGameObject* lastObjectAdded; ///< last object added to sim ! double lon_theater_deg; ///< default starting longitude for theater ! double lat_theater_deg; ///< default starting latitude for theater ! static tcDirector* director; static tcMapData* mapData; |
|
From: Dewitt C. <ddc...@us...> - 2005-05-08 23:28:12
|
Update of /cvsroot/gcblue/gcb_wx/include/graphics In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17728/include/graphics Modified Files: tcMapObject.h tcMapOverlay.h Log Message: Landing bug fix, changed /gm create to require starting coords, added fuel to air update Index: tcMapOverlay.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/graphics/tcMapOverlay.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** tcMapOverlay.h 31 Mar 2005 03:51:11 -0000 1.1 --- tcMapOverlay.h 8 May 2005 23:27:56 -0000 1.2 *************** *** 43,46 **** --- 43,50 ---- class tcMapObject; + class tcStream; + class tcCommandStream; + class tcCreateStream; + class tcUpdateStream; *************** *** 62,65 **** --- 66,72 ---- void Redraw(); + virtual tcUpdateStream& operator<<(tcUpdateStream& stream); + virtual tcUpdateStream& operator>>(tcUpdateStream& stream); + tcMapOverlay(wxWindow *parent, const wxPoint& pos, const wxSize& size, Index: tcMapObject.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/graphics/tcMapObject.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** tcMapObject.h 31 Mar 2005 03:51:11 -0000 1.8 --- tcMapObject.h 8 May 2005 23:27:55 -0000 1.9 *************** *** 38,41 **** --- 38,46 ---- class tc3DWindow; + class tcStream; + class tcCommandStream; + class tcCreateStream; + class tcUpdateStream; + namespace MapView { *************** *** 69,72 **** --- 74,80 ---- static void SetMapView(MapView::tcMapView *mv); + virtual tcUpdateStream& operator<<(tcUpdateStream& stream); + virtual tcUpdateStream& operator>>(tcUpdateStream& stream); + tcMapObject(); tcMapObject(double x, double y, bool useRel = false); *************** *** 97,100 **** --- 105,111 ---- virtual void Draw(tc3DWindow* host); + virtual tcUpdateStream& operator<<(tcUpdateStream& stream); + virtual tcUpdateStream& operator>>(tcUpdateStream& stream); + tcMapTextObject(); tcMapTextObject(const std::string& text, double x, double y, bool useRel = false); |
|
From: Dewitt C. <ddc...@us...> - 2005-05-08 23:28:12
|
Update of /cvsroot/gcblue/gcb_wx/include/network In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17728/include/network Modified Files: tcMultiplayerInterface.h tcUpdateMessageHandler.h Log Message: Landing bug fix, changed /gm create to require starting coords, added fuel to air update Index: tcUpdateMessageHandler.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/network/tcUpdateMessageHandler.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** tcUpdateMessageHandler.h 5 May 2005 02:14:19 -0000 1.8 --- tcUpdateMessageHandler.h 8 May 2005 23:27:56 -0000 1.9 *************** *** 61,65 **** CONTROL_REQUEST = 7, ///< request to take control of obj SOUND_EFFECT = 8, ///< play sound effect for object ! SCRIPT_COMMANDS = 9 ///< script commands to execute on server }; --- 61,66 ---- CONTROL_REQUEST = 7, ///< request to take control of obj SOUND_EFFECT = 8, ///< play sound effect for object ! SCRIPT_COMMANDS = 9, ///< script commands to execute on server ! SCENARIO_INFO = 10 ///< info on scenario }; *************** *** 71,74 **** --- 72,76 ---- static void AddCreateRequest(long id, tcStream& stream); static void AddDestroy(long id, tcStream& stream); + static void AddScenarioInfo(tcUpdateStream& stream); static void AddSensorUpdateHeader(long alliance, tcStream& stream); static void AddSoundEffect(long id, const std::string& effect, tcStream& stream); *************** *** 85,88 **** --- 87,91 ---- void HandleCreateRequest(tcStream& stream, int connectionId); void HandleDestroy(tcStream& stream); + void HandleScenarioInfo(tcUpdateStream& stream); void HandleScriptCommands(tcStream& stream, int connectionId); void HandleSensorUpdate(tcUpdateStream& stream); Index: tcMultiplayerInterface.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/network/tcMultiplayerInterface.h,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** tcMultiplayerInterface.h 6 May 2005 23:57:15 -0000 1.24 --- tcMultiplayerInterface.h 8 May 2005 23:27:56 -0000 1.25 *************** *** 115,121 **** --- 115,123 ---- void BroadcastChatText(const std::string& message); void BroadcastControlMessage(int messageCode); + void BroadcastScenarioInfo(); //std::string GetChatText(); const std::list<int>& GetConnectionList() const; + const std::vector<int>& GetConnectionVector() const; const std::string& GetConnectionStatus(int connectionId); wxEvtHandler* GetEvtHandler() const; *************** *** 148,151 **** --- 150,154 ---- void SendControlRelease(long id); void SendControlRequest(long id); + void SendScenarioInfo(const std::vector<int>& destinations); void SendSoundEffect(const std::string& player, const std::string& effect, long id = -1); void SendSoundEffect(int destination, const std::string& effect, long id = -1); *************** *** 153,156 **** --- 156,160 ---- void SendUpdateMessage(int destination, tcStream& stream); void SendUpdateMessageAck(int destination, tcStream& stream); + void SendUpdateMessageTCP(int destination, tcStream& stream); void SetChatProtocol(int code); void SetEvtHandler(wxEvtHandler *eh); |
|
From: Dewitt C. <ddc...@us...> - 2005-05-06 23:58:31
|
Update of /cvsroot/gcblue/gcb_wx/src/common In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11225/src/common Modified Files: simmath.cpp Log Message: added player name to connection status, update rates are slower for non-controlled objects, non-controlled objects now display as green, added chat text popup Index: simmath.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/common/simmath.cpp,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** simmath.cpp 16 Apr 2005 20:44:42 -0000 1.24 --- simmath.cpp 6 May 2005 23:57:49 -0000 1.25 *************** *** 245,249 **** stream >> mfSpeed_kts; stream >> mfHeading_rad; ! stream >> mfClimbAngle_rad; stream >> mfTimestamp; stream >> mnID; --- 245,250 ---- stream >> mfSpeed_kts; stream >> mfHeading_rad; ! //stream >> mfClimbAngle_rad; ! mfClimbAngle_rad = 0; // use 0 for multiplayer track climb angle stream >> mfTimestamp; stream >> mnID; *************** *** 267,271 **** stream << mfSpeed_kts; stream << mfHeading_rad; ! stream << mfClimbAngle_rad; stream << mfTimestamp; stream << mnID; --- 268,272 ---- stream << mfSpeed_kts; stream << mfHeading_rad; ! //stream << mfClimbAngle_rad; stream << mfTimestamp; stream << mnID; |
|
From: Dewitt C. <ddc...@us...> - 2005-05-06 23:58:02
|
Update of /cvsroot/gcblue/gcb_wx/src/graphics In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11225/src/graphics Modified Files: tcCreditView.cpp tcGameView.cpp tcMapView.cpp tcMessageCenter.cpp tcMessageInterface.cpp Log Message: added player name to connection status, update rates are slower for non-controlled objects, non-controlled objects now display as green, added chat text popup Index: tcMessageCenter.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcMessageCenter.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** tcMessageCenter.cpp 29 Mar 2005 00:12:26 -0000 1.6 --- tcMessageCenter.cpp 6 May 2005 23:57:50 -0000 1.7 *************** *** 133,136 **** --- 133,141 ---- } + bool tcMessageCenter::GetPopupChatText() const + { + return popupChatText; + } + /** * *************** *** 203,206 **** --- 208,225 ---- + void tcMessageCenter::PostChatText(const std::string& msg) + { + if (popupChatText) + { + PopupMessage(msg); + } + } + + + void tcMessageCenter::SetPopupChatText(bool state) + { + popupChatText = state; + } + /** *************** *** 213,217 **** popupBase(205, 70), popupCount(0), ! console(0) { channelTab.Set(10, 140, 10, 30); --- 232,237 ---- popupBase(205, 70), popupCount(0), ! console(0), ! popupChatText(false) { channelTab.Set(10, 140, 10, 30); Index: tcCreditView.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcCreditView.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** tcCreditView.cpp 29 Mar 2005 00:12:26 -0000 1.13 --- tcCreditView.cpp 6 May 2005 23:57:50 -0000 1.14 *************** *** 77,84 **** --- 77,89 ---- AddCredit(s, 60.0f, 1); + + s = "--- Test ---"; AddCredit(s, 25.0f, 1); s = "Dust"; + AddCredit(s, 25.0f, 1); + + s = "Havoc"; AddCredit(s, 125.0f, 1); Index: tcMessageInterface.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcMessageInterface.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** tcMessageInterface.cpp 29 Mar 2005 00:12:26 -0000 1.3 --- tcMessageInterface.cpp 6 May 2005 23:57:50 -0000 1.4 *************** *** 72,75 **** --- 72,89 ---- } + void tcMessageInterface::PostChatText(const std::string& msg) + { + wxASSERT(messageCenter); + + messageCenter->PostChatText(msg); + } + + void tcMessageInterface::SetPopupChatText(bool state) + { + wxASSERT(messageCenter); + + messageCenter->SetPopupChatText(state); + } + /** * Must be called before using DisplayChannelMessage Index: tcMapView.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcMapView.cpp,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** tcMapView.cpp 29 Apr 2005 18:52:53 -0000 1.24 --- tcMapView.cpp 6 May 2005 23:57:50 -0000 1.25 *************** *** 1618,1622 **** * Call after tables are built. */ ! void tcTacticalMapView::CreateFadedSymbols() { for (int nAffiliation=0; nAffiliation<4; nAffiliation++) --- 1618,1622 ---- * Call after tables are built. */ ! void tcTacticalMapView::CreateAlternateSymbols() { for (int nAffiliation=0; nAffiliation<4; nAffiliation++) *************** *** 1633,1636 **** --- 1633,1637 ---- maSymbolA_fade[nAffiliation][nSymbol] = fadedA; + } { *************** *** 1643,1646 **** --- 1644,1667 ---- maSymbolB_fade[nAffiliation][nSymbol] = fadedB; } + { + osg::Geometry* altA = new osg::Geometry(*maSymbolA[nAffiliation][nSymbol]); + + osg::Vec4Array* colors = new osg::Vec4Array; + colors->push_back(osg::Vec4(0.5, 0.8, 0.5, 1.0)); + altA->setColorArray(colors); + altA->setColorBinding(osg::Geometry::BIND_OVERALL); + + maSymbolA_alt[nAffiliation][nSymbol] = altA; + + } + { + osg::Geometry* altB = new osg::Geometry(*maSymbolB[nAffiliation][nSymbol]); + osg::Vec4Array* colors = new osg::Vec4Array; + colors->push_back(osg::Vec4(0.5, 0.8, 0.5, 1.0)); + altB->setColorArray(colors); + altB->setColorBinding(osg::Geometry::BIND_OVERALL); + + maSymbolB_alt[nAffiliation][nSymbol] = altB; + } } *************** *** 1667,1670 **** --- 1688,1712 ---- } + + /** + * Altered version of symbols for objects not controlled by player in multiplayer mode + * @returns symbol image pointer based on symbology mode + */ + osg::Geometry* tcTacticalMapView::GetSymbolAltered(teAffiliation aeAffiliation, teSymbol aeSymbol) + { + int nAffilIdx = (int)aeAffiliation; + int nSymbolIdx = (int)aeSymbol; + + if (meSymbology == NTDS) + { + return maSymbolA_alt[nAffilIdx][nSymbolIdx].get(); + } + else + { + return maSymbolB_alt[nAffilIdx][nSymbolIdx].get(); + } + } + + /** * Faded version of symbols for stale tracks *************** *** 1850,1858 **** { osg::Geometry* pSymbol = 0; ! if (!pMO->isStaleTrack) { pSymbol = tcTacticalMapView::GetSymbol(pMO->meAffiliation, pMO->meSymbol); } ! else { pSymbol = tcTacticalMapView::GetSymbolFaded(pMO->meAffiliation, pMO->meSymbol); --- 1892,1907 ---- { osg::Geometry* pSymbol = 0; ! if ((!pMO->isStaleTrack) && (!pMO->useAltered)) { pSymbol = tcTacticalMapView::GetSymbol(pMO->meAffiliation, pMO->meSymbol); } ! else if (pMO->useAltered) ! { ! pSymbol = tcTacticalMapView::GetSymbolAltered(pMO->meAffiliation, pMO->meSymbol); ! symbolColor._v[0] *= 0.5; ! symbolColor._v[1] *= 0.8; ! symbolColor._v[2] *= 0.5; ! } ! else { pSymbol = tcTacticalMapView::GetSymbolFaded(pMO->meAffiliation, pMO->meSymbol); *************** *** 2166,2170 **** BuildNTDS(); Build2525(); ! CreateFadedSymbols(); } --- 2215,2219 ---- BuildNTDS(); Build2525(); ! CreateAlternateSymbols(); } Index: tcGameView.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcGameView.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** tcGameView.cpp 29 Apr 2005 18:52:53 -0000 1.8 --- tcGameView.cpp 6 May 2005 23:57:50 -0000 1.9 *************** *** 626,629 **** --- 626,631 ---- mpMapView->maMapObj[rnIndex].isStaleTrack = false; mpMapView->maMapObj[rnIndex].isDestroyed = false; + mpMapView->maMapObj[rnIndex].useAltered = (po->IsClientMode() && !po->IsControlled()); + if ((mpMapView->maMapObj[rnIndex].meSymbol != SYMBOL_FIXED) && *************** *** 714,718 **** mpMapView->maMapObj[rnIndex].isStaleTrack = pSMTrack->IsStale(); mpMapView->maMapObj[rnIndex].isDestroyed = pSMTrack->IsDestroyed(); ! tcPoint point(track.mfLon_rad, track.mfLat_rad); --- 716,720 ---- mpMapView->maMapObj[rnIndex].isStaleTrack = pSMTrack->IsStale(); mpMapView->maMapObj[rnIndex].isDestroyed = pSMTrack->IsDestroyed(); ! mpMapView->maMapObj[rnIndex].useAltered = false; tcPoint point(track.mfLon_rad, track.mfLat_rad); |
|
From: Dewitt C. <ddc...@us...> - 2005-05-06 23:58:02
|
Update of /cvsroot/gcblue/gcb_wx/src/database In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11225/src/database Added Files: md5c.c md5class.cpp tcAccountDatabase.cpp Log Message: added player name to connection status, update rates are slower for non-controlled objects, non-controlled objects now display as green, added chat text popup --- NEW FILE: md5class.cpp --- // md5class.cpp: implementation of the CMD5 class. //See internet RFC 1321, "The MD5 Message-Digest Algorithm" // //Use this code as you see fit. It is provided "as is" //without express or implied warranty of any kind. ////////////////////////////////////////////////////////////////////// #include "md5class.h" #include "md5.h" //declarations from RFC 1321 #include <string.h> #include <stdio.h> ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// CMD5::CMD5() { m_digestValid = false; //we don't have a plaintext string yet m_digestString[32]=0; //the digest string is always 32 characters, so put a null in position 32 } CMD5::~CMD5() { } CMD5::CMD5(const char* plainText) { m_plainText = plainText; m_digestString[32] = 0; m_digestValid = calcDigest(); } CMD5::CMD5(const std::string& plainText) { m_plainText = plainText.c_str(); m_digestString[32] = 0; m_digestValid = calcDigest(); } ////////////////////////////////////////////////////////////////////// // Implementation ////////////////////////////////////////////////////////////////////// bool CMD5::operator==(const CMD5& rhs) { if (!isDigestValid() || !rhs.isDigestValid()) { return false; } const char* rhsDigest = rhs.getMD5Digest(); int result = strncmp(m_digestString, rhsDigest , 33); return (result == 0); } bool CMD5::isDigestValid() const { return m_digestValid; } void CMD5::setPlainText(const char* plainText) { //set plaintext with a mutator, it's ok to //to call this multiple times. If casting away the const-ness of plainText //worries you, you could either make a local copy of the plain //text string instead of just pointing at the user's string, or //modify the RFC 1321 code to take 'const' plaintext, see example below. m_plainText = const_cast<char*>(plainText); m_digestValid = calcDigest(); } /* Use a function of this type with your favorite string class if casting away the const-ness of the user's text buffer violates you coding standards. void CMD5::setPlainText(CString& strPlainText) { static CString plaintext(strPlainText); m_plainText = strPlainText.GetBuffer(); m_digestValid = calcDigest(); } */ const char* CMD5::getMD5Digest() const { //access message digest (aka hash), return 0 if plaintext has not been set if(m_digestValid) { return m_digestString; } else { return 0; } } bool CMD5::calcDigest() { //See RFC 1321 for details on how MD5Init, MD5Update, and MD5Final //calculate a digest for the plain text MD5_CTX context; MD5Init(&context); //the alternative to these ugly casts is to go into the RFC code and change the declarations unsigned int plainTextLength = (unsigned int)m_plainText.length(); unsigned char* plainText = reinterpret_cast<unsigned char *>(const_cast<char *>(m_plainText.c_str())); MD5Update(&context, plainText, plainTextLength); MD5Final(reinterpret_cast <unsigned char *>(m_digest),&context); //make a string version of the numeric digest value int p=0; for (int i = 0; i<16; i++) { ::sprintf(&m_digestString[p],"%02x", m_digest[i]); p+=2; } return true; } --- NEW FILE: tcAccountDatabase.cpp --- /** ** @file tcAccountDatabase.cpp */ /* Copyright (C) 2005 Dewitt 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" #include "wx/datetime.h" #include "tcAccountDatabase.h" #include "sqlite/sqlite_plus.h" #include "md5class.h" #include <sstream> #ifdef _DEBUG #define new DEBUG_NEW #endif tcAccountDatabase* tcAccountDatabase::Get() { static tcAccountDatabase instance; return &instance; } int tcAccountDatabase::AddUser(const std::string& user, const std::string& hash, const std::string& email) { try { if (GetUserData(user, cachedUserData)) { return DUPLICATE_USER; } std::string hashStore = ""; if (hash.size() > 0) { hashStore = GetMD5digest(hash); } wxString s = wxString::Format("insert into %s (UserName,PasswordHash,Email) " "values (\'%s\',\'%s\',\'%s\');", tableName.c_str(), user.c_str(), hashStore.c_str(), email.c_str()); accountDatabase->executenonquery(s.c_str()); return SUCCESS; } catch (exception& ex) { wxMessageBox(ex.what(), "Error", wxICON_ERROR); return UNKNOWN_ERROR; } } /** * If password is empty in database, store hash as password and return SUCCESS */ int tcAccountDatabase::AuthenticateUser(const std::string& user, const std::string& hash) { std::string hashCompare = GetMD5digest(hash); if (GetUserData(user, cachedUserData)) { if (cachedUserData.password_hash.size() == 0) { cachedUserData.password_hash = hashCompare; return UpdateDatabaseEntry(cachedUserData); } else if (cachedUserData.password_hash == hashCompare) { return SUCCESS; } else { return PASSWORD_INVALID; } } else { return USER_NOT_FOUND; } } std::string tcAccountDatabase::ErrorCodeToString(int code) { std::string s; if (code == SUCCESS) { s = "Success"; } else if (code == USER_NOT_FOUND) { s = "Username not found"; } else if (code == PASSWORD_INVALID) { s = "Invalid password"; } else if (code == DUPLICATE_USER) { s = "Username already exists"; } else if (code == DUPLICATE_LOGIN) { s = "User already logged in"; } else { s = "Unknown error"; } return s; } const char* tcAccountDatabase::GetMD5digest(const char* plainText) { md5->setPlainText(plainText); return md5->getMD5Digest(); } const char* tcAccountDatabase::GetMD5digest(const std::string& plainText) { return GetMD5digest(plainText.c_str()); } bool tcAccountDatabase::GetUserData(const std::string& user, UserData& userData) { sqlite::reader tableData = accountDatabase->executereader( "select * from %s where UserName='%s';", tableName.c_str(), user.c_str()); if (tableData.read()) { userData.username = user; userData.alliance = (unsigned int)tableData.getint(LookupFieldIndex("Alliance")); userData.email = tableData.getstring(LookupFieldIndex("Email")); userData.last_ip = tableData.getstring(LookupFieldIndex("LastIP")); userData.last_login = (unsigned long)tableData.getlong(LookupFieldIndex("LastLogin")); userData.last_logout = (unsigned long)tableData.getlong(LookupFieldIndex("LastLogout")); userData.login_count = (unsigned int)tableData.getint(LookupFieldIndex("LoginCount")); userData.password_hash = tableData.getstring(LookupFieldIndex("PasswordHash")); userData.score = tableData.getdouble(LookupFieldIndex("Score")); userData.flags = tableData.getdouble(LookupFieldIndex("Flags")); tableData.close(); // VERY important to do this, otherwise prevents future writes to database return true; } else { userData.username = ""; tableData.close(); return false; // user not found, no data available } } tcAccountDatabase::UserData& tcAccountDatabase::GetCachedUserData(const std::string& user) { if (cachedUserData.username != user) { GetUserData(user, cachedUserData); } return cachedUserData; } void tcAccountDatabase::Initialize() { wxASSERT(accountDatabase == 0); try { accountDatabase = new sqlite::connection(databasePath.c_str()); // build column lookup columnLookup.clear(); sqlite::reader tableInfo = accountDatabase->executereader( "pragma table_info(%s);", tableName.c_str()); unsigned int fieldCount = 0; while (tableInfo.read()) { columnLookup[std::string(tableInfo[1])] = fieldCount++; } md5 = new CMD5; } catch (exception& ex) { fprintf(stderr, "%s\n", ex.what()); } } bool tcAccountDatabase::IsUserLoggedIn(const std::string& user) { UserData& data = GetCachedUserData(user); if (data.username.size() == 0) { return false; // user not found } return (data.last_login > data.last_logout); } int tcAccountDatabase::LogIn(const std::string& user, const std::string ipAddress) { UserData& data = GetCachedUserData(user); if (data.username.size() == 0) { return USER_NOT_FOUND; // user not found } wxDateTime now = wxDateTime::Now(); unsigned long currentTime = now.GetTicks(); data.last_ip = ipAddress; data.last_login = currentTime; data.login_count++; return UpdateDatabaseEntry(data); } int tcAccountDatabase::LogOut(const std::string& user) { UserData& data = GetCachedUserData(user); if (data.username.size() == 0) { return USER_NOT_FOUND; // user not found } wxDateTime now = wxDateTime::Now(); unsigned long currentTime = now.GetTicks(); data.last_logout = currentTime; return UpdateDatabaseEntry(data); } /** * @return index of field or -1 if not found */ int tcAccountDatabase::LookupFieldIndex(const std::string& field) { std::map<std::string, unsigned int>::const_iterator mapIter; mapIter = columnLookup.find(field); if (mapIter == columnLookup.end()) { return -1; } else { return mapIter->second; } } int tcAccountDatabase::SetUserAlliance(const std::string& user, unsigned int alliance) { UserData& data = GetCachedUserData(user); if (data.username.size() == 0) { return USER_NOT_FOUND; // user not found } data.alliance = alliance; return UpdateDatabaseEntry(data); } int tcAccountDatabase::UpdateDatabaseEntry(UserData& userData) { std::stringstream valueString; valueString << "PasswordHash='" << userData.password_hash << "',"; valueString << "Email='" << userData.email << "',"; valueString << "LastIP='" << userData.last_ip << "',"; valueString << "LastLogin=" << userData.last_login << ","; valueString << "LastLogout=" << userData.last_logout << ","; valueString << "LoginCount=" << userData.login_count << ","; valueString << "Alliance=" << userData.alliance << ","; valueString << "Score=" << userData.score << ","; valueString << "Flags=" << userData.flags; wxString s = wxString::Format("UPDATE OR IGNORE %s SET %s WHERE UserName='%s';", tableName.c_str(), valueString.str().c_str(), userData.username.c_str()); try { accountDatabase->executenonquery(s.c_str()); } catch (exception& ex) { fprintf(stderr, "UpdateDatabaseEntry - %s (%s)\n", ex.what(), s.c_str()); } return SUCCESS; } void tcAccountDatabase::TestUpdate() { std::stringstream valueString; valueString << "PasswordHash='" << "" << "',"; valueString << "Email='" << "" << "',"; valueString << "LastIP='" << "192.168.0.9" << "',"; valueString << "LastLogin=" << 72 << ","; valueString << "LastLogout=" << 83 << ","; valueString << "LoginCount=" << 5; wxString s = wxString::Format("UPDATE OR IGNORE %s SET %s WHERE UserName='%s';", tableName.c_str(), valueString.str().c_str(), "dewitt"); // wxString s = wxString::Format("UPDATE OR IGNORE account_info SET PasswordHash='64sdkljlskdjfkjsdlkjf',Email='',LoginCount=5,LastIP='blabbity',LastLogin=72,LastLogout=83 WHERE UserName='dewitt';"); try { accountDatabase->executenonquery(s.c_str()); } catch (exception& ex) { fprintf(stderr, "test UpdateDatabaseEntry - %s (%s)\n", ex.what(), s.c_str()); } } tcAccountDatabase::tcAccountDatabase() : accountDatabase(0), md5(0), databasePath("database\\accounts.db"), tableName("account_info") { Initialize(); } tcAccountDatabase::~tcAccountDatabase() { delete accountDatabase; } --- NEW FILE: md5c.c --- //See internet RFC 1321, "The MD5 Message-Digest Algorithm" /* MD5C.C - RSA Data Security, Inc., MD5 message-digest algorithm */ /* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All rights reserved. License to copy and use this software is granted provided that it is identified as the "RSA Data Security, Inc. MD5 Message-Digest Algorithm" in all material mentioning or referencing this software or this function. License is also granted to make and use derivative works provided that such works are identified as "derived from the RSA Data Security, Inc. MD5 Message-Digest Algorithm" in all material mentioning or referencing the derived work. RSA Data Security, Inc. makes no representations concerning either the merchantability of this software or the suitability of this software for any particular purpose. It is provided "as is" without express or implied warranty of any kind. These notices must be retained in any copies of any part of this documentation and/or software. */ #include "md5.h" /* Constants for MD5Transform routine. */ #define S11 7 #define S12 12 #define S13 17 #define S14 22 #define S21 5 #define S22 9 #define S23 14 #define S24 20 #define S31 4 #define S32 11 #define S33 16 #define S34 23 #define S41 6 #define S42 10 #define S43 15 #define S44 21 static void MD5Transform PROTO_LIST ((UINT4 [4],unsigned char [64])); static void Encode PROTO_LIST ((unsigned char *, UINT4 *, unsigned int)); static void Decode PROTO_LIST ((UINT4 *, unsigned char *, unsigned int)); static void MD5_memcpy PROTO_LIST ((POINTER, POINTER, unsigned int)); static void MD5_memset PROTO_LIST ((POINTER, int, unsigned int)); static unsigned char PADDING[64] = { 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; /* F, G, H and I are basic MD5 functions. */ #define F(x, y, z) (((x) & (y)) | ((~x) & (z))) #define G(x, y, z) (((x) & (z)) | ((y) & (~z))) #define H(x, y, z) ((x) ^ (y) ^ (z)) #define I(x, y, z) ((y) ^ ((x) | (~z))) /* ROTATE_LEFT rotates x left n bits. */ #define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n)))) /* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4. Rotation is separate from addition to prevent recomputation. */ #define FF(a, b, c, d, x, s, ac) { \ (a) += F ((b), (c), (d)) + (x) + (UINT4)(ac); \ (a) = ROTATE_LEFT ((a), (s)); \ (a) += (b); \ } #define GG(a, b, c, d, x, s, ac) { \ (a) += G ((b), (c), (d)) + (x) + (UINT4)(ac); \ (a) = ROTATE_LEFT ((a), (s)); \ (a) += (b); \ } #define HH(a, b, c, d, x, s, ac) { \ (a) += H ((b), (c), (d)) + (x) + (UINT4)(ac); \ (a) = ROTATE_LEFT ((a), (s)); \ (a) += (b); \ } #define II(a, b, c, d, x, s, ac) { \ (a) += I ((b), (c), (d)) + (x) + (UINT4)(ac); \ (a) = ROTATE_LEFT ((a), (s)); \ (a) += (b); \ } /* MD5 initialization. Begins an MD5 operation, writing a new context. */ void MD5Init (context) MD5_CTX *context; /* context */ { context->count[0] = context->count[1] = 0; /* Load magic initialization constants. */ context->state[0] = 0x67452301; context->state[1] = 0xefcdab89; context->state[2] = 0x98badcfe; context->state[3] = 0x10325476; } /* MD5 block update operation. Continues an MD5 message-digest operation, processing another message block, and updating the context. */ void MD5Update (context, input, inputLen) MD5_CTX *context; /* context */ unsigned char *input; /* input block */ unsigned int inputLen; /* length of input block */ { unsigned int i, index, partLen; /* Compute number of bytes mod 64 */ index = (unsigned int)((context->count[0] >> 3) & 0x3F); /* Update number of bits */ if ((context->count[0] += ((UINT4)inputLen << 3)) < ((UINT4)inputLen << 3)) context->count[1]++; context->count[1] += ((UINT4)inputLen >> 29); partLen = 64 - index; /* Transform as many times as possible. */ if (inputLen >= partLen) { MD5_memcpy ((POINTER)&context->buffer[index], (POINTER)input, partLen); MD5Transform (context->state, context->buffer); for (i = partLen; i + 63 < inputLen; i += 64) MD5Transform (context->state, &input[i]); index = 0; } else i = 0; /* Buffer remaining input */ MD5_memcpy ((POINTER)&context->buffer[index], (POINTER)&input[i], inputLen-i); } /* MD5 finalization. Ends an MD5 message-digest operation, writing the the message digest and zeroizing the context. */ void MD5Final (digest, context) unsigned char digest[16]; /* message digest */ MD5_CTX *context; /* context */ { unsigned char bits[8]; unsigned int index, padLen; /* Save number of bits */ Encode (bits, context->count, 8); /* Pad out to 56 mod 64. */ index = (unsigned int)((context->count[0] >> 3) & 0x3f); padLen = (index < 56) ? (56 - index) : (120 - index); MD5Update (context, PADDING, padLen); /* Append length (before padding) */ MD5Update (context, bits, 8); /* Store state in digest */ Encode (digest, context->state, 16); /* Zeroize sensitive information. */ MD5_memset ((POINTER)context, 0, sizeof (*context)); } /* MD5 basic transformation. Transforms state based on block. */ static void MD5Transform (state, block) UINT4 state[4]; unsigned char block[64]; { UINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[16]; Decode (x, block, 64); /* Round 1 */ FF (a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */ FF (d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */ FF (c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */ FF (b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */ FF (a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */ FF (d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */ FF (c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */ FF (b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */ FF (a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */ FF (d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */ FF (c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */ FF (b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */ FF (a, b, c, d, x[12], S11, 0x6b901122); /* 13 */ FF (d, a, b, c, x[13], S12, 0xfd987193); /* 14 */ FF (c, d, a, b, x[14], S13, 0xa679438e); /* 15 */ FF (b, c, d, a, x[15], S14, 0x49b40821); /* 16 */ /* Round 2 */ GG (a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */ GG (d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */ GG (c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */ GG (b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */ GG (a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */ GG (d, a, b, c, x[10], S22, 0x2441453); /* 22 */ GG (c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */ GG (b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */ GG (a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */ GG (d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */ GG (c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */ GG (b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */ GG (a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */ GG (d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */ GG (c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */ GG (b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */ /* Round 3 */ HH (a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */ HH (d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */ HH (c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */ HH (b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */ HH (a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */ HH (d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */ HH (c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */ HH (b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */ HH (a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */ HH (d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */ HH (c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */ HH (b, c, d, a, x[ 6], S34, 0x4881d05); /* 44 */ HH (a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */ HH (d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */ HH (c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */ HH (b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */ /* Round 4 */ II (a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */ II (d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */ II (c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */ II (b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */ II (a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */ II (d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */ II (c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */ II (b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */ II (a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */ II (d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */ II (c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */ II (b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */ II (a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */ II (d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */ II (c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */ II (b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */ state[0] += a; state[1] += b; state[2] += c; state[3] += d; /* Zeroize sensitive information. */ MD5_memset ((POINTER)x, 0, sizeof (x)); } /* Encodes input (UINT4) into output (unsigned char). Assumes len is a multiple of 4. */ static void Encode (output, input, len) unsigned char *output; UINT4 *input; unsigned int len; { unsigned int i, j; for (i = 0, j = 0; j < len; i++, j += 4) { output[j] = (unsigned char)(input[i] & 0xff); output[j+1] = (unsigned char)((input[i] >> 8) & 0xff); output[j+2] = (unsigned char)((input[i] >> 16) & 0xff); output[j+3] = (unsigned char)((input[i] >> 24) & 0xff); } } /* Decodes input (unsigned char) into output (UINT4). Assumes len is a multiple of 4. */ static void Decode (output, input, len) UINT4 *output; unsigned char *input; unsigned int len; { unsigned int i, j; for (i = 0, j = 0; j < len; i++, j += 4) output[i] = ((UINT4)input[j]) | (((UINT4)input[j+1]) << 8) | (((UINT4)input[j+2]) << 16) | (((UINT4)input[j+3]) << 24); } /* Note: Replace "for loop" with standard memcpy if possible. */ static void MD5_memcpy (output, input, len) POINTER output; POINTER input; unsigned int len; { unsigned int i; for (i = 0; i < len; i++) output[i] = input[i]; } /* Note: Replace "for loop" with standard memset if possible. */ static void MD5_memset (output, value, len) POINTER output; int value; unsigned int len; { unsigned int i; for (i = 0; i < len; i++) ((char *)output)[i] = (char)value; } |
|
From: Dewitt C. <ddc...@us...> - 2005-05-06 23:58:02
|
Update of /cvsroot/gcblue/gcb_wx/src/network In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11225/src/network Modified Files: tcMultiplayerInterface.cpp tcNetworkInterface.cpp tcTextMessageHandler.cpp Added Files: tcAuthenticationMessageHandler.cpp Log Message: added player name to connection status, update rates are slower for non-controlled objects, non-controlled objects now display as green, added chat text popup Index: tcNetworkInterface.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/network/tcNetworkInterface.cpp,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** tcNetworkInterface.cpp 29 Apr 2005 18:52:54 -0000 1.18 --- tcNetworkInterface.cpp 6 May 2005 23:57:50 -0000 1.19 *************** *** 220,225 **** ! std::string tcNetworkInterface::GetConnectionStatus(int id) { unsigned timeCount = tcTime::Get()->Get30HzCount(); --- 220,227 ---- ! const std::string& tcNetworkInterface::GetConnectionStatus(int id) { + static std::string s; + unsigned timeCount = tcTime::Get()->Get30HzCount(); *************** *** 251,257 **** float ping_ms = 1000.0f * connData->GetPingTime(); ! wxString status = wxString::Format("%s (%.0f) %04d %04d %03d %.0f", ! connData->idString.c_str(), dt_sec, bytesIn, bytesOut, resentCount, ping_ms); ! return std::string(status.c_str()); } --- 253,260 ---- float ping_ms = 1000.0f * connData->GetPingTime(); ! wxString status = wxString::Format("(%.0f) %04d %04d %03d %.0f", ! dt_sec, bytesIn, bytesOut, resentCount, ping_ms); ! s = status.c_str(); ! return s; } Index: tcTextMessageHandler.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/network/tcTextMessageHandler.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** tcTextMessageHandler.cpp 29 Apr 2005 18:52:54 -0000 1.5 --- tcTextMessageHandler.cpp 6 May 2005 23:57:50 -0000 1.6 *************** *** 21,24 **** --- 21,25 ---- #include "network/tcTextMessageHandler.h" #include "network/tcMultiplayerInterface.h" + #include "tcMessageInterface.h" BEGIN_NAMESPACE(network) *************** *** 62,65 **** --- 63,72 ---- text = namedText; } + else + { + // send to tcMessageInterface in client mode (mode based popups of chat text) + tcMessageInterface::Get()->PostChatText(text); + } + chatText.push(text); } Index: tcMultiplayerInterface.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/network/tcMultiplayerInterface.cpp,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** tcMultiplayerInterface.cpp 5 May 2005 02:14:52 -0000 1.25 --- tcMultiplayerInterface.cpp 6 May 2005 23:57:50 -0000 1.26 *************** *** 464,470 **** } ! std::string tcMultiplayerInterface::GetConnectionStatus(int connectionId) { ! return networkInterface->GetConnectionStatus(connectionId); } --- 464,476 ---- } ! const std::string& tcMultiplayerInterface::GetConnectionStatus(int connectionId) { ! static std::string s; ! ! s = GetPlayerName(connectionId).c_str(); ! s += " "; ! s += networkInterface->GetConnectionStatus(connectionId).c_str(); ! ! return s; } *************** *** 1540,1543 **** --- 1546,1550 ---- tcPlayerStatus& pstatus = GetPlayerStatus(connId); + const std::string& playerName = pstatus.GetName(); // create stream for new entities *************** *** 1562,1570 **** if (pstatus.GetLastUpdate(obj->mnID, lastUpdate)) { ! // add check based on object time, etc for variable update rates ! tcUpdateMessageHandler::AddUpdate(obj, updateStream); - pstatus.SetUpdate(obj->mnID, t); - updateCount++; // create new message if updateCount gets too large --- 1569,1583 ---- if (pstatus.GetLastUpdate(obj->mnID, lastUpdate)) { ! unsigned int dt = t - lastUpdate; ! bool doUpdate = (dt >= 90) || ! ((dt >= 25) && (obj->IsControlledBy(playerName))); ! if (doUpdate) ! { ! tcUpdateMessageHandler::AddUpdate(obj, updateStream); ! ! pstatus.SetUpdate(obj->mnID, t); ! updateCount++; ! } // create new message if updateCount gets too large *************** *** 1725,1735 **** stat.entityUpdateTime = 0; stat.sensorUpdateTime = 0; ! stat.name = "anonymous"; stat.isAuthenticated = false; ! playerInfo[connId] = stat; tcSound::Get()->PlayEffect("intercom"); - - if (IsServer()) SendAuthRequest(connId); } else --- 1738,1755 ---- stat.entityUpdateTime = 0; stat.sensorUpdateTime = 0; ! stat.name = "Anonymous"; stat.isAuthenticated = false; ! if (IsServer()) ! { ! SendAuthRequest(connId); ! } ! else ! { ! stat.name = "Server"; ! } ! ! playerInfo[connId] = stat; tcSound::Get()->PlayEffect("intercom"); } else --- NEW FILE: tcAuthenticationMessageHandler.cpp --- /** * @file tcAuthenticationMessageHandler.cpp * * Copyright (C) 2005 Dewitt 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 "wx/event.h" #include "network/tcAuthenticationMessageHandler.h" #include "network/tcMultiplayerInterface.h" #include "common/tcStream.h" #ifdef _DEBUG #define new DEBUG_NEW #endif BEGIN_NAMESPACE(network) /** * A request for authentication from server to client */ void tcAuthenticationMessageHandler::CreateAuthenticationRequest(unsigned& messageSize, unsigned char *data) { int messageCode = AM_REQUEST; messageSize = sizeof(messageCode); memcpy(data, &messageCode, messageSize); } /** * A username, password hash response from client to server. The plain text password is hashed once (MD5) * before sending to server. The server hashes it again before comparing to database value. * Plaintext passwords are not known at the server and are not stored in the database. * Obtaining the account database does not allow access to the account. */ void tcAuthenticationMessageHandler::CreateAuthenticationResponse(const std::string& username, const std::string& hash, unsigned& messageSize, unsigned char *data) { int messageCode = AM_RESPONSE; tcStream stream; stream << messageCode; stream << username; stream << hash; messageSize = stream.size(); stream.read((char*)data, messageSize); } void tcAuthenticationMessageHandler::Handle(int connectionId, unsigned messageSize, const unsigned char *data) { if (messageSize < sizeof(int)) { fprintf(stderr, "Warning - Empty or short control message received by server\n"); return; } /* This constructor makes a copy of the data **/ tcStream stream((const char*)data, messageSize); int messageCode; stream >> messageCode; // if server, check to ensure control message is valid if (isServer) { if (messageCode != AM_RESPONSE) { fprintf(stderr, "Warning - illegal auth message received by server (%d)\n", messageCode); return; } } else { if (messageCode != AM_REQUEST) { fprintf(stderr, "Warning - illegal auth message received by client (%d)\n", messageCode); return; } } switch (messageCode) { case AM_REQUEST: { tcMultiplayerInterface::Get()->SendAuthResponse(connectionId); } break; case AM_RESPONSE: { std::string username; stream >> username; std::string passwordHash; stream >> passwordHash; tcMultiplayerInterface::Get()->AuthenticatePlayer(connectionId, username, passwordHash); } break; default: { fprintf(stderr, "Warning - Unrecognized auth message " "received (src:%d, id:%d)\n", connectionId, messageCode); return; } } } tcAuthenticationMessageHandler::tcAuthenticationMessageHandler() { } tcAuthenticationMessageHandler::~tcAuthenticationMessageHandler() { } END_NAMESPACE |
Update of /cvsroot/gcblue/gcb_wx/src/sim In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11225/src/sim Modified Files: Game.cpp tcAeroAirObject.cpp tcAirObject.cpp tcLauncher.cpp tcPlatformObject.cpp tcSensorMap.cpp Added Files: tcControllableObject.cpp Log Message: added player name to connection status, update rates are slower for non-controlled objects, non-controlled objects now display as green, added chat text popup Index: tcAirObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcAirObject.cpp,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** tcAirObject.cpp 29 Apr 2005 18:52:55 -0000 1.21 --- tcAirObject.cpp 6 May 2005 23:57:51 -0000 1.22 *************** *** 43,46 **** --- 43,48 ---- tcCommandStream& tcAirObject::operator<<(tcCommandStream& stream) { + ClearNewCommand(); + tcPlatformObject::operator<<(stream); Index: tcAeroAirObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcAeroAirObject.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** tcAeroAirObject.cpp 17 Apr 2005 22:35:32 -0000 1.13 --- tcAeroAirObject.cpp 6 May 2005 23:57:51 -0000 1.14 *************** *** 44,47 **** --- 44,49 ---- tcCommandStream& tcAeroAirObject::operator<<(tcCommandStream& stream) { + ClearNewCommand(); + tcAirObject::operator<<(stream); *************** *** 342,346 **** { throttleFraction = 1.0f; ! SetAltitude(k.mfAlt_m - 50.0f*mpDBObject->mfMaxCl); // max throttle and dive to get out of stall Cl = mpDBObject->mfMaxCl; inducedDrag_N = 0; // stall, no induced drag --- 344,349 ---- { throttleFraction = 1.0f; ! mcGS.mfGoalAltitude_m = k.mfAlt_m - 50.0f*mpDBObject->mfMaxCl; // avoid flooding connection with stall adjustments ! //SetAltitude(k.mfAlt_m - 50.0f*mpDBObject->mfMaxCl); // max throttle and dive to get out of stall Cl = mpDBObject->mfMaxCl; inducedDrag_N = 0; // stall, no induced drag *************** *** 349,353 **** { throttleFraction = 1.0f; ! SetAltitude(k.mfAlt_m - 500.0f*(Cl-0.9f*mpDBObject->mfMaxCl)); // max throttle and dive to avoid impending stall inducedDrag_N = mpDBObject->mfKdi * Cl * Cl * lift_N; } --- 352,357 ---- { throttleFraction = 1.0f; ! mcGS.mfGoalAltitude_m = k.mfAlt_m - 500.0f*(Cl-0.9f*mpDBObject->mfMaxCl); ! //SetAltitude(k.mfAlt_m - 500.0f*(Cl-0.9f*mpDBObject->mfMaxCl)); // max throttle and dive to avoid impending stall inducedDrag_N = mpDBObject->mfKdi * Cl * Cl * lift_N; } *************** *** 371,375 **** if (k.mfSpeed_kts > mpDBObject->mfMaxSpeed_kts) k.mfSpeed_kts = mpDBObject->mfMaxSpeed_kts; ! } --- 375,384 ---- if (k.mfSpeed_kts > mpDBObject->mfMaxSpeed_kts) k.mfSpeed_kts = mpDBObject->mfMaxSpeed_kts; ! else if (k.mfSpeed_kts < 40.0) ! { ! // shouldn't happen, but limit speed to 40 and slowly dive in this case ! k.mfSpeed_kts = 40.0; ! if (k.mfClimbAngle_rad > -0.1) k.mfClimbAngle_rad -= dt_s * 0.1f; ! } } Index: Game.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/Game.cpp,v retrieving revision 1.129 retrieving revision 1.130 diff -C2 -d -r1.129 -r1.130 *** Game.cpp 5 May 2005 02:14:53 -0000 1.129 --- Game.cpp 6 May 2005 23:57:51 -0000 1.130 *************** *** 1516,1519 **** --- 1516,1520 ---- viewer->SetActive(false); worldMap->SetActive(false); + tcMessageInterface::Get()->SetPopupChatText(false); } lastMode = meScreenMode; *************** *** 1550,1553 **** --- 1551,1559 ---- { chatBox->Draw(); + tcMessageInterface::Get()->SetPopupChatText(false); + } + else + { + tcMessageInterface::Get()->SetPopupChatText(true); } } *************** *** 1578,1581 **** --- 1584,1592 ---- { chatBox->Draw(); + tcMessageInterface::Get()->SetPopupChatText(false); + } + else + { + tcMessageInterface::Get()->SetPopupChatText(true); } } *************** *** 2391,2394 **** --- 2402,2409 ---- pythonInterface->ProcessCallback(azCallback, id, p.x, p.y, param); } + else if (strcmp(azUserInput,"Null") == 0) // necessary? or always handled in GetUserInput + { + pythonInterface->ProcessCallback(azCallback, id); + } else {} } *************** *** 2413,2416 **** --- 2428,2435 ---- tacticalMap->ActivateCmd(MC_DATUM); } + else if (strcmp(azUserInput, "Null") == 0) + { + pythonInterface->ProcessCallback(azCallback, id); + } else { Index: tcLauncher.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcLauncher.cpp,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** tcLauncher.cpp 5 May 2005 02:14:54 -0000 1.18 --- tcLauncher.cpp 6 May 2005 23:57:51 -0000 1.19 *************** *** 117,121 **** stream >> floor_m; stream >> runToEnable_m; ! fprintf(stdout, "Updating launcher torpedo params (%d/%d)\n", this, parent); } --- 117,121 ---- stream >> floor_m; stream >> runToEnable_m; ! //fprintf(stdout, "Updating launcher torpedo params (%d/%d)\n", this, parent); } Index: tcPlatformObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcPlatformObject.cpp,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -d -r1.43 -r1.44 *** tcPlatformObject.cpp 5 May 2005 02:14:55 -0000 1.43 --- tcPlatformObject.cpp 6 May 2005 23:57:51 -0000 1.44 *************** *** 652,655 **** --- 652,657 ---- tcGameObject::operator<<(stream); + ClearNewCommand(); + unsigned char updateMask; stream >> updateMask; Index: tcSensorMap.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcSensorMap.cpp,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** tcSensorMap.cpp 5 May 2005 02:14:55 -0000 1.19 --- tcSensorMap.cpp 6 May 2005 23:57:52 -0000 1.20 *************** *** 670,674 **** maTrack.GetNextAssoc(pos, key, sensorMapTrack); double dt = mfPreviousStatusTime - sensorMapTrack->mfTimestamp; ! if (dt < 1.0) { stream << sensorMapTrack->mnID; --- 670,674 ---- maTrack.GetNextAssoc(pos, key, sensorMapTrack); double dt = mfPreviousStatusTime - sensorMapTrack->mfTimestamp; ! if (dt < 2.0) { stream << sensorMapTrack->mnID; --- NEW FILE: tcControllableObject.cpp --- /** ** @file tcControllableObject.cpp */ /* Copyright (C) 2005 Dewitt 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" #ifndef WX_PRECOMP #include "wx/wx.h" #endif #include "tcControllableObject.h" #include "tcUserInfo.h" #include "common/tcStream.h" #include "common/tcObjStream.h" #ifdef _DEBUG #define new DEBUG_NEW #endif tcUserInfo* tcControllableObject::userInfo = 0; void tcControllableObject::AttachUserInfo() { userInfo = tcUserInfo::Get(); } /** * Loads state from create stream */ tcCreateStream& tcControllableObject::operator<<(tcCreateStream& stream) { stream >> alliance; return stream; } /** * Saves state to create stream */ tcCreateStream& tcControllableObject::operator>>(tcCreateStream& stream) { stream << alliance; return stream; } /** * Loads state from update stream */ tcUpdateStream& tcControllableObject::operator<<(tcUpdateStream& stream) { stream >> flags; stream >> controller; return stream; } /** * Saves state to update stream */ tcUpdateStream& tcControllableObject::operator>>(tcUpdateStream& stream) { stream << flags; stream << controller; return stream; } unsigned char tcControllableObject::GetAlliance() const { return alliance; } void tcControllableObject::SetAlliance(unsigned char val) { alliance = val; } unsigned char tcControllableObject::GetAccessLevel() const { return flags & ACCESS_LEVEL_MASK; } void tcControllableObject::SetAccessLevel(unsigned char level) { flags |= level; } const std::string& tcControllableObject::GetController() const { return controller; } void tcControllableObject::SetController(const std::string& username) { controller = username; } /** * If object does not have controller, obj is available if * user rank >= access level, otherwise user rank must be > access level */ bool tcControllableObject::IsAvailable() const { return IsAvailable(userInfo->GetOwnAlliance(), userInfo->GetRank()); } bool tcControllableObject::IsAvailable(unsigned char playerAlliance, unsigned char rank) const { if (playerAlliance != alliance) return false; if (controller.size() == 0) { return rank >= GetAccessLevel(); } else { return rank > GetAccessLevel(); } } bool tcControllableObject::IsControlledBy(const std::string& playerName) const { return (controller == playerName); } bool tcControllableObject::IsControlled() const { return controller == userInfo->GetUsername(); } tcControllableObject::tcControllableObject() : controller(""), flags(0), alliance(0) { } tcControllableObject::tcControllableObject(const tcControllableObject& src) : controller(src.controller), flags(src.flags), alliance(src.alliance) { } tcControllableObject::~tcControllableObject() { } |
|
From: Dewitt C. <ddc...@us...> - 2005-05-06 23:58:02
|
Update of /cvsroot/gcblue/gcb_wx/src/scriptinterface In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11225/src/scriptinterface Modified Files: tcSimPythonInterface.cpp Log Message: added player name to connection status, update rates are slower for non-controlled objects, non-controlled objects now display as green, added chat text popup Index: tcSimPythonInterface.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/scriptinterface/tcSimPythonInterface.cpp,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** tcSimPythonInterface.cpp 5 May 2005 02:14:53 -0000 1.30 --- tcSimPythonInterface.cpp 6 May 2005 23:57:50 -0000 1.31 *************** *** 102,107 **** * Adds a menu item that gets a coordinate or target from the user via a mouse click * @param caption caption for menu item ! * @param callback script to call after user data is obtained ! * @param input type of user data: "Heading", "Target", or "Datum" * @param param integer callback parameter for additional information */ --- 102,107 ---- * Adds a menu item that gets a coordinate or target from the user via a mouse click * @param caption caption for menu item ! * @param callback script to call after user data is obtained ! * @param input type of user data: "Null", "Heading", "Target", or "Datum" ("Null" is a way to treat as callback for multiplayer purposes) * @param param integer callback parameter for additional information */ *************** *** 112,116 **** char zBuff[64]; strcpy(zBuff,input.c_str()); ! if ((strcmp(zBuff,"Heading")!=0)&&(strcmp(zBuff,"Target")!=0)&&(strcmp(zBuff,"Datum")!=0)) { return; --- 112,117 ---- char zBuff[64]; strcpy(zBuff,input.c_str()); ! if ((strcmp(zBuff,"Null")!=0) && (strcmp(zBuff,"Heading")!=0) && ! (strcmp(zBuff,"Target")!=0) && (strcmp(zBuff,"Datum")!=0)) { return; *************** *** 606,609 **** --- 607,646 ---- + /** + * Version without any data (added for multiplayer client "Null" callback support) + */ + void tcSimPythonInterface::ProcessCallback(std::string command, const std::vector<long>& id) + { + PushMode(); + SetMenuGroup(id); + + if (mpHookedObj == NULL) + { + PopMode(); + return; + } + char zBuff[128]; + char zObject[64]; + + GetObjectStringByMode(zObject); + + sprintf(zBuff, "Menu.%s(%s)\n", command.c_str(), zObject); + + + if (!mpSimState->IsMultiplayerClient()) + { + CallPython(zBuff, "Exception occured in ProcessCallback\n"); + } + else + { + ClientCommand cmd; + cmd.idList = id; + cmd.commandText = std::string(zBuff); + + clientCommands.push_back(cmd); + } + + PopMode(); + } |
|
From: Dewitt C. <ddc...@us...> - 2005-05-06 23:57:26
|
Update of /cvsroot/gcblue/gcb_wx/include/database In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11073/include/database Added Files: md5.h md5class.h tcAccountDatabase.h tcPlayerDatabase.h Log Message: added player name to connection status, update rates are slower for non-controlled objects, non-controlled objects now display as green, added chat text popup --- NEW FILE: md5.h --- /* MD5.H - header file for MD5C.C */ //See internet RFC 1321, "The MD5 Message-Digest Algorithm" /* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All rights reserved. License to copy and use this software is granted provided that it is identified as the "RSA Data Security, Inc. MD5 Message-Digest Algorithm" in all material mentioning or referencing this software or this function. License is also granted to make and use derivative works provided that such works are identified as "derived from the RSA Data Security, Inc. MD5 Message-Digest Algorithm" in all material mentioning or referencing the derived work. RSA Data Security, Inc. makes no representations concerning either the merchantability of this software or the suitability of this software for any particular purpose. It is provided "as is" without express or implied warranty of any kind. These notices must be retained in any copies of any part of this documentation and/or software. */ /* MD5 context. */ #ifndef _MD5CONTEXT_H #define _MD5CONTEXT_H #ifndef POINTER /* POINTER defines a generic pointer type */ typedef unsigned char *POINTER; #endif #ifndef UINT2 /* UINT2 defines a two byte word */ typedef unsigned short int UINT2; #endif #ifndef UINT4 /* UINT4 defines a four byte word */ typedef unsigned long int UINT4; #endif #define PROTO_LIST(list) list typedef struct { UINT4 state[4]; /* state (ABCD) */ UINT4 count[2]; /* number of bits, modulo 2^64 (lsb first) */ unsigned char buffer[64]; /* input buffer */ } MD5_CTX; #ifdef __cplusplus //added by Jim Howard so that these functions can be called from c++ extern "C" { #endif void MD5Init PROTO_LIST ((MD5_CTX *)); void MD5Update PROTO_LIST ((MD5_CTX *, unsigned char *, unsigned int)); void MD5Final PROTO_LIST ((unsigned char [16], MD5_CTX *)); #ifdef __cplusplus } #endif #endif --- NEW FILE: tcPlayerDatabase.h --- #ifndef _PLAYERDATABASE_H_ #define _PLAYERDATABASE_H_ /** name alliance funds owned entities score */ /** * Interface to player database. The player database has state info for the * current game. */ class tcPlayerDatabase { public: enum { SUCCESS = 0, PLAYER_NOT_FOUND = 1, INVALID_ENTITY = 2, INSUFFICIENT_FUNDS = 3, DUPLICATE_PLAYER = 4 }; /// Add new player to database int AddPlayer(const std::string& player); int AdjustScore(const std::string& player, float amount); int GetPlayerAlliance(const std::string& player); std::vector<long>& GetPlayerEntities(const std::string& player); float GetPlayerFunds(const std::string& player); float GetPlayerScore(const std::string& player); /// @return true if player is in database bool IsPlayerValid(const std::string& player); int RemovePlayer(const std::string& player); int SetPlayerAlliance(const std::string& player, int alliance); /// use empty string to add or delete without transferring int TransferEntity(long entity, const std::string& from, const std::string& to); /// use empty string to add or delete without transferring int TransferMultipleEntities(std::vector<long>& entityList, const std::string& from, const std::string& to); /// use empty string to add or remove without transferring int TransferFunds(float amount, const std::string& from, const std::string& to); private: std::vector<long> temporaryEntityList; }; #endif --- NEW FILE: md5class.h --- // md5class.h: interface for the CMD5 class. // ////////////////////////////////////////////////////////////////////// #ifndef _MD5CLASS_H_ #define _MD5CLASS_H_ #if _MSC_VER > 1000 #pragma once #endif #include <string> /*************************************************************************** This class is a utility wrapper for 'C' code contained in internet RFC 1321, "The MD5 Message-Digest Algorithm". It calculates a cryptological hash value, called a "digest" from a character string. For every unique character string the MD5 hash is guaranteed to be unique. The MD5 hash has the property that given the digest, it's thought to be impossible to get back to the plain text string with existing technology. In this implementation the digest is always a 32 digit hex number, regardless of the length of the input plaintext. This class is helpful for programs which store passwords. Rather than storing the password directly, the programmer should store the MD5 digest of the password. Then when the user enters a password, compute the MD5 digest of the input password. If it is identical to the stored digest, then the user has entered the correct password. It doesn't matter if an evil person sees the digest, since he or she can't get from the digest to the password. At least not unless the user enters a word out of the dictionary, since the evil person could hash the whole dictionary. One way to defeat a dictionary attack is to append a non-text character onto the password, so that even if the user enters a dumb password like "password", you just append some non alpha character to the entered password, i.e. password = "password" + "$". By always appending a nonalpha character, your stored digest isn't in the attacker's dictionary. You can then safely post the digest of the password on a highway billboard. Example pseudocode: { std::string storedPasswordDigest = GetPasswordDigestFromStorage(); std::string passwordEnteredbyUser; cout << "Enter password:" ; cin >> passwordEnteredbyUser; CMD5 md5(passwordEnteredbyUser.c_str()); //note c_str() returns a pointer to the std::string's character buffer, just like CString's "GetBuffer" member function. if(md5.getMD5Digest != storedPasswordDigest) { //user has entered an invalid password cout << "Incorrect password!"; exit(1); } //if we get here, then the user entered a valid password } ************************************************************************** Use this code as you see fit. It is provided "as is" without express or implied warranty of any kind. Jim Howard, jn...@ju... ***************************************************************************/ class CMD5 { public: CMD5(); //default ctor CMD5(const char* plainText); //set plaintext in ctor CMD5(const std::string& plainText); void setPlainText(const std::string& plainText); void setPlainText(const char* plainText); //set plaintext with a mutator, it's ok to //to call this multiple times, the digest is recalculated after each call. const char* getMD5Digest() const; //access message digest (aka hash), return 0 if plaintext has not been set bool isDigestValid() const; bool operator==(const CMD5& rhs); virtual ~CMD5(); private: bool calcDigest(); //this function computes the digest by calling the RFC 1321 'C' code bool m_digestValid; //false until the plaintext has been set and digest computed unsigned char m_digest[16]; //the numerical value of the digest char m_digestString[33]; //Null terminated string value of the digest expressed in hex digits std::string m_plainText; //char* m_plainText; //a pointer to the plain text. If casting away the const-ness //worries you, you could either make a local copy of the plain //text string instead of just pointing at the user's string or //modify the RFC 1321 code to take 'const' plaintext. }; #endif --- NEW FILE: tcAccountDatabase.h --- /** ** @file tcAccountDatabase.h */ /* Copyright (C) 2005 Dewitt 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 _ACCOUNTDATABASE_H_ #define _ACCOUNTDATABASE_H_ #include <map> #include <string> class CMD5; namespace sqlite { class connection; } /** * Interface to account database. Currently this mixes the database interface with * game-related use of data. Eventually may want to separate this. */ class tcAccountDatabase { public: /// status codes enum { SUCCESS = 0, USER_NOT_FOUND = 1, PASSWORD_INVALID = 2, DUPLICATE_USER = 3, DUPLICATE_LOGIN = 4, INSUFFICIENT_PERMISSION = 5, UNKNOWN_ERROR = 99 }; struct UserData { /// permission flags enum { ALLIANCE_SWITCH = 1, ///< allows user to switch alliance PLATFORM_CONTROL = 2, ///< allows user to take control of entities }; std::string username; std::string password_hash; std::string email; std::string last_ip; unsigned int login_count; unsigned long last_login; ///< seconds since Jan 1, 1970 unsigned long last_logout; ///< seconds since Jan 1, 1970 unsigned int alliance; ///< 0 for no alliance selected float score; int flags; ///< permission flags bool CanControlPlatforms() const {return (flags & PLATFORM_CONTROL) != 0;} bool CanSwitchAlliance() const {return (alliance==0) || ((flags & ALLIANCE_SWITCH) != 0);} }; /// Add new user to account database int AddUser(const std::string& user, const std::string& hash, const std::string& email); /// @return SUCCESS if user is authenticated, otherwise error code int AuthenticateUser(const std::string& user, const std::string& hash); std::string ErrorCodeToString(int code); bool GetUserData(const std::string& user, UserData& userData); /// loads user to cachedUserData (if nessessary) and returns reference UserData& GetCachedUserData(const std::string& user); bool IsUserLoggedIn(const std::string& user); /// Call once at login to update database with login info for user int LogIn(const std::string& user, const std::string ipAddress); /// Call once to log out user int LogOut(const std::string& user); int LookupFieldIndex(const std::string& field); /// @return SUCCESS if alliance changed, otherwise error code int SetUserAlliance(const std::string& user, unsigned int alliance); /// Updates all fields of database entry (user name cannot be changed this way) int UpdateDatabaseEntry(UserData& userData); const char* GetMD5digest(const char* plainText); const char* GetMD5digest(const std::string& plainText); static tcAccountDatabase* Get(); ///< singleton instance accessor private: sqlite::connection* accountDatabase; std::map<std::string, unsigned int> columnLookup; // for faster access of data CMD5* md5; UserData cachedUserData; ///< all columns from last read are stored in this structure const std::string databasePath; const std::string tableName; void Initialize(); ///< open connection to database and initialize columnLookup void TestUpdate(); tcAccountDatabase(); ~tcAccountDatabase(); }; #endif |
|
From: Dewitt C. <ddc...@us...> - 2005-05-06 23:57:26
|
Update of /cvsroot/gcblue/gcb_wx/include/graphics In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11073/include/graphics Modified Files: tcMapView.h tcMessageCenter.h tcMessageInterface.h Log Message: added player name to connection status, update rates are slower for non-controlled objects, non-controlled objects now display as green, added chat text popup Index: tcMessageCenter.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/graphics/tcMessageCenter.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** tcMessageCenter.h 29 Mar 2005 00:12:23 -0000 1.3 --- tcMessageCenter.h 6 May 2005 23:57:15 -0000 1.4 *************** *** 46,49 **** --- 46,56 ---- void ConsoleMessage(const std::string& msg); void PopupMessage(const std::string& msg); + + /// chat text messages to popup (if enabled) + void PostChatText(const std::string& msg); + + bool GetPopupChatText() const; + void SetPopupChatText(bool state); + void Clear(); virtual void Draw(); *************** *** 63,66 **** --- 70,74 ---- unsigned int popupCount; tcSoundConsole* console; + bool popupChatText; tcMessageChannel* GetChannel(const std::string& channelName); Index: tcMapView.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/graphics/tcMapView.h,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** tcMapView.h 31 Mar 2005 03:51:11 -0000 1.17 --- tcMapView.h 6 May 2005 23:57:15 -0000 1.18 *************** *** 104,108 **** bool isStaleTrack; ///< true for stale track bool isDestroyed; ///< true for destroyed track ! UINT8 mnFlags; void Clear() { --- 104,109 ---- bool isStaleTrack; ///< true for stale track bool isDestroyed; ///< true for destroyed track ! bool useAltered; ///< use altered symbol (e.g. for objects not controlled by player in multiplayer mode) ! UINT8 mnFlags; void Clear() { *************** *** 111,116 **** mbExists=0;mbFocus=0;mnColor=0;mfHeading=0;mfLon=0;mfLat=0;mnID=0; mnFlags = 0; ! isStaleTrack = 0; ! isDestroyed = 0; } }; --- 112,118 ---- mbExists=0;mbFocus=0;mnColor=0;mfHeading=0;mfLon=0;mfLat=0;mnID=0; mnFlags = 0; ! isStaleTrack = false; ! isDestroyed = false; ! useAltered = false; } }; *************** *** 353,360 **** --- 355,366 ---- osg::ref_ptr<osg::Geometry> maSymbolA[4][MAX_SYMBOL]; osg::ref_ptr<osg::Geometry> maSymbolB[4][MAX_SYMBOL]; + /// faded versions for stale tracks osg::ref_ptr<osg::Geometry> maSymbolA_fade[4][MAX_SYMBOL]; osg::ref_ptr<osg::Geometry> maSymbolB_fade[4][MAX_SYMBOL]; + /// altered versions of symbols (e.g. objects not under control of player) + osg::ref_ptr<osg::Geometry> maSymbolA_alt[4][MAX_SYMBOL]; + osg::ref_ptr<osg::Geometry> maSymbolB_alt[4][MAX_SYMBOL]; teSymbology meSymbology; *************** *** 367,370 **** --- 373,377 ---- osg::Geometry* GetSymbol(teAffiliation aeAffiliation, teSymbol aeSymbol); + osg::Geometry* GetSymbolAltered(teAffiliation aeAffiliation, teSymbol aeSymbol); osg::Geometry* GetSymbolFaded(teAffiliation aeAffiliation, teSymbol aeSymbol); osg::Image* LoadSymbolImage(const char *azSymbolName); *************** *** 373,377 **** float xc, float yc, float width, float height, float startAngle, float stopAngle, unsigned int nPoints); ! void CreateFadedSymbols(); osg::Geometry* CreateSymbolGeometry(); osg::Geometry* CreateTexturedSymbol(const char* symbolName); --- 380,384 ---- float xc, float yc, float width, float height, float startAngle, float stopAngle, unsigned int nPoints); ! void CreateAlternateSymbols(); osg::Geometry* CreateSymbolGeometry(); osg::Geometry* CreateTexturedSymbol(const char* symbolName); Index: tcMessageInterface.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/graphics/tcMessageInterface.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** tcMessageInterface.h 29 Mar 2005 00:12:23 -0000 1.3 --- tcMessageInterface.h 6 May 2005 23:57:15 -0000 1.4 *************** *** 42,46 **** --- 42,48 ---- void ChannelMessage(const std::string& channelName, const std::string& msg); void ConsoleMessage(const std::string& msg); + void PostChatText(const std::string& msg); void PopupMessage(const std::string& msg); + void SetPopupChatText(bool state); static tcMessageInterface* Get(); ///< singleton accessor |
|
From: Dewitt C. <ddc...@us...> - 2005-05-06 23:57:25
|
Update of /cvsroot/gcblue/gcb_wx/include/network In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11073/include/network Modified Files: tcMultiplayerInterface.h tcNetworkInterface.h Added Files: tcAuthenticationMessageHandler.h Log Message: added player name to connection status, update rates are slower for non-controlled objects, non-controlled objects now display as green, added chat text popup Index: tcMultiplayerInterface.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/network/tcMultiplayerInterface.h,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** tcMultiplayerInterface.h 5 May 2005 02:14:19 -0000 1.23 --- tcMultiplayerInterface.h 6 May 2005 23:57:15 -0000 1.24 *************** *** 118,122 **** const std::list<int>& GetConnectionList() const; ! std::string GetConnectionStatus(int connectionId); wxEvtHandler* GetEvtHandler() const; const std::string& GetName() const; --- 118,122 ---- const std::list<int>& GetConnectionList() const; ! const std::string& GetConnectionStatus(int connectionId); wxEvtHandler* GetEvtHandler() const; const std::string& GetName() const; Index: tcNetworkInterface.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/network/tcNetworkInterface.h,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** tcNetworkInterface.h 17 Apr 2005 22:34:59 -0000 1.11 --- tcNetworkInterface.h 6 May 2005 23:57:15 -0000 1.12 *************** *** 64,68 **** const std::map<int, tcConnectionData*>& GetConnectionMap(); ! std::string GetConnectionStatus(int id); tcMessage* GetMessage(int id); unsigned int GetNumConnections(); --- 64,68 ---- const std::map<int, tcConnectionData*>& GetConnectionMap(); ! const std::string& GetConnectionStatus(int id); tcMessage* GetMessage(int id); unsigned int GetNumConnections(); --- NEW FILE: tcAuthenticationMessageHandler.h --- /** ** @file tcAuthenticationMessageHandler.h */ /* Copyright (C) 2005 Dewitt 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 _AUTHENTICATIONMESSAGEHANDLER_H_ #define _AUTHENTICATIONMESSAGEHANDLER_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 tcAuthenticationMessageHandler : public tcMessageHandler { public: enum { AM_REQUEST = 1, ///< request user name, password hash pair AM_RESPONSE = 2 }; static void CreateAuthenticationRequest(unsigned& messageSize, unsigned char *data); static void CreateAuthenticationResponse(const std::string& username, const std::string& hash, unsigned& messageSize, unsigned char *data); virtual void Handle(int connectionId, unsigned messageSize, const unsigned char *data); tcAuthenticationMessageHandler(); virtual ~tcAuthenticationMessageHandler(); }; END_NAMESPACE #endif |