[Gcblue-commits] gcb_wx/src/scriptinterface tcSimPythonInterface.cpp, 1.45, 1.46 tcTrackInterface.c
Status: Alpha
Brought to you by:
ddcforge
From: Dewitt C. <ddc...@us...> - 2006-12-01 03:39:56
|
Update of /cvsroot/gcblue/gcb_wx/src/scriptinterface In directory sc8-pr-cvs2.sourceforge.net:/tmp/cvs-serv9232/src/scriptinterface Modified Files: tcSimPythonInterface.cpp tcTrackInterface.cpp Log Message: Index: tcSimPythonInterface.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/scriptinterface/tcSimPythonInterface.cpp,v retrieving revision 1.45 retrieving revision 1.46 diff -C2 -d -r1.45 -r1.46 *** tcSimPythonInterface.cpp 20 Nov 2006 00:17:43 -0000 1.45 --- tcSimPythonInterface.cpp 1 Dec 2006 03:39:54 -0000 1.46 *************** *** 38,41 **** --- 38,42 ---- #include "tcMessageInterface.h" #include "tcTime.h" + #include "network/tcMultiplayerInterface.h" #include "ai/ScriptedTask.h" *************** *** 45,54 **** --- 46,59 ---- #include "common/tcOptions.h" + + #ifdef _DEBUG #define new DEBUG_NEW #endif + using namespace boost::python; using namespace ai; + using namespace network; namespace scriptinterface *************** *** 195,198 **** --- 200,226 ---- const std::string& playerName = stream.GetMetaString(); + tcMultiplayerInterface* multiplayerInterface = tcMultiplayerInterface::Get(); + int connId = multiplayerInterface->GetPlayerConnectionId(playerName); + if (connId == -1) + { + fprintf(stderr, "tcSimPythonInterface::operator<< - Bad playername (%s)\n", + playerName.c_str()); + return stream; + } + tcPlayerStatus playerStatus = multiplayerInterface->GetPlayerStatus(connId); + + tcAllianceSensorMap* playerSensorMap = mpSimState->GetSensorMap()->GetMap(playerStatus.alliance); + if (playerSensorMap == 0) + { + fprintf(stderr, "tcSimPythonInterface::operator<< - Player has no sensor map, bad alliance? (%s, %d)\n", + playerName.c_str(), playerStatus.alliance); + return stream; + } + tcAllianceSensorMap* previousSensorMap = tcTrackInterface::GetSensorMap(); // save current map + tcTrackInterface::SetSensorMap(playerSensorMap); + + unsigned char prevAlliance = mpSimState->mpUserInfo->GetOwnAlliance(); + mpSimState->mpUserInfo->SetOwnAlliance(playerStatus.alliance); + unsigned char nCommands; stream >> nCommands; *************** *** 200,203 **** --- 228,234 ---- for (unsigned char n=0; n<nCommands; n++) { + char menuMode; + stream >> menuMode; + unsigned char nId; stream >> nId; *************** *** 220,238 **** { tcGameObject* obj = mpSimState->GetObject(idList[n]); ! playerHasControl = obj->IsControlledBy(playerName); } ! if (playerHasControl) ! { #ifdef _DEBUG ! long id0 = (idList.size() > 0) ? idList[0] : -1; ! fprintf(stdout, "Script cmd (%d/%d): %s\n", id0, idList.size(), command.c_str()); #endif ! ProcessCallbackString(command, idList); ! } ! else ! { ! fprintf(stderr, "Script command issued for obj that player does not control, " ! "player: %s\n", playerName.c_str()); ! } } else --- 251,296 ---- { tcGameObject* obj = mpSimState->GetObject(idList[n]); ! playerHasControl = (obj != 0) ? obj->IsControlledBy(playerName) : false; ! if (obj == 0) ! { ! fprintf(stderr, "tcSimPythonInterface::operator<< - bad idList passed, menuMode: %d\n", ! int(menuMode)); ! } } ! ! bool trackMode = menuMode == TRACK_MENU; ! ! if (!trackMode) ! { ! if (playerHasControl) ! { #ifdef _DEBUG ! long id0 = (idList.size() > 0) ? idList[0] : -1; ! fprintf(stdout, "Script cmd (%d/%d): %s\n", id0, idList.size(), command.c_str()); #endif ! ProcessCallbackString(command, idList); ! } ! else ! { ! fprintf(stderr, "Script command issued for obj that player does not control, " ! "player: %s\n", playerName.c_str()); ! } ! } ! else // track mode ! { ! if (!playerHasControl) ! { ! #ifdef _DEBUG ! long id0 = (idList.size() > 0) ? idList[0] : -1; ! fprintf(stdout, "Script track cmd (%d/%d): %s\n", id0, idList.size(), command.c_str()); ! #endif ! ProcessCallbackString(command, idList); ! } ! else ! { ! fprintf(stderr, "Script track command issued for obj that player controls, " ! "player: %s\n", playerName.c_str()); ! } ! } } else *************** *** 243,246 **** --- 301,307 ---- } + tcTrackInterface::SetSensorMap(previousSensorMap); // restore sensor map + mpSimState->mpUserInfo->SetOwnAlliance(prevAlliance); + return stream; } *************** *** 263,266 **** --- 324,329 ---- ClientCommand& cmd = clientCommands[n]; + stream << cmd.menuMode; + wxASSERT(cmd.idList.size() < 256); unsigned char nId = cmd.idList.size(); *************** *** 612,615 **** --- 675,681 ---- int param, std::string textParam) { + PushMode(); + SetMenuGroup(id); + std::string s = "Menu."; *************** *** 624,628 **** { char zBuff[64]; ! sprintf(zBuff,", %d",param); s += zBuff; } --- 690,694 ---- { char zBuff[64]; ! sprintf(zBuff,", %d", param); s += zBuff; } *************** *** 635,639 **** s += ")\n"; ! CallPython(s.c_str(),"Exception occurred in ProcessCommand\n"); } --- 701,727 ---- s += ")\n"; ! ! ! if (!mpSimState->IsMultiplayerClient()) ! { ! CallPython(s.c_str(), "Exception occurred in ProcessCommand\n"); ! } ! else ! { ! ClientCommand cmd; ! cmd.menuMode = meMenuMode; ! cmd.idList = id; ! cmd.commandText = s; ! ! if (cmd.idList.size() == 0) ! { ! cmd.idList = groupInterface->GetUnits(); ! } ! ! clientCommands.push_back(cmd); ! } ! ! ! PopMode(); } *************** *** 728,731 **** --- 816,820 ---- { ClientCommand cmd; + cmd.menuMode = meMenuMode; cmd.idList = id; cmd.commandText = std::string(zBuff); *************** *** 756,760 **** - GetObjectStringByMode(zObject); --- 845,848 ---- *************** *** 779,782 **** --- 867,871 ---- { ClientCommand cmd; + cmd.menuMode = meMenuMode; cmd.idList = id; cmd.commandText = std::string(zBuff); *************** *** 831,834 **** --- 920,924 ---- { ClientCommand cmd; + cmd.menuMode = meMenuMode; cmd.idList = id; unsigned nId = id.size(); *************** *** 882,885 **** --- 972,976 ---- { ClientCommand cmd; + cmd.menuMode = meMenuMode; cmd.idList = id; cmd.commandText = std::string(zBuff); *************** *** 920,923 **** --- 1011,1015 ---- { ClientCommand cmd; + cmd.menuMode = meMenuMode; cmd.idList = id; cmd.commandText = std::string(zBuff); *************** *** 955,958 **** --- 1047,1051 ---- { ClientCommand cmd; + cmd.menuMode = meMenuMode; cmd.idList = id; cmd.commandText = command; Index: tcTrackInterface.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/scriptinterface/tcTrackInterface.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** tcTrackInterface.cpp 23 Mar 2006 01:11:02 -0000 1.11 --- tcTrackInterface.cpp 1 Dec 2006 03:39:54 -0000 1.12 *************** *** 43,53 **** ! void tcTrackInterface::AttachSensorMap(tcAllianceSensorMap *apSM) { wxASSERT(apSM); mpSensorMap = apSM; ! fprintf(stdout, "tcTrackInterface - Attaching sensor map for alliance: %d\n", ! mpSensorMap->GetAlliance()); } --- 43,58 ---- ! void tcTrackInterface::SetSensorMap(tcAllianceSensorMap *apSM) { wxASSERT(apSM); mpSensorMap = apSM; ! fprintf(stdout, "tcTrackInterface - Attaching sensor map for alliance: %d\n", ! mpSensorMap->GetAlliance()); ! } ! ! tcAllianceSensorMap* tcTrackInterface::GetSensorMap() ! { ! return mpSensorMap; } |