BOOL CArrayMatrix::ProcessInput(CString DataString) { //获得等号右边的字符串 CString RightString=DataString; if(!SetStringName(RightString,m_Name)) return FALSE; //获得变量名称,存储到m_Name中去 ProcString(RightString); int tipnum=0; int len=lstrlen(RightString); if(len==0) return FALSE;//表示矩阵没有数据 if(!InputRow(RightString)) return FALSE; CString * SPtBuffer=NULL;//指向矩阵每行字符串CString的指针 if(!InputCon(RightString,SPtBuffer)) return FALSE; m_Array.SetSize(m_wCon*m_wRow); for(int i=0;i<(int)m_wRow;i++) { for(int j=0;j<(int)m_wCon;j++) { float temp=0.0; if(!ConvertToNum(SPtBuffer[i],j,temp)) return FALSE; m_Array[i*m_wCon+j]=temp; } } if(SPtBuffer!=NULL) delete []SPtBuffer; return true; }
bool KOTHCommands::handle(int playerID, bz_ApiString _command, bz_ApiString _message, bz_APIStringList * /*_param*/ ) { std::string command = _command.c_str(); std::string message = _message.c_str(); const char *kingmessage = _message.c_str(); if (command == "kingsay") { if (koth.id != -1) bz_sendTextMessage(playerID, koth.id, kingmessage); else bz_sendTextMessage(BZ_SERVER, playerID, "There is no one attempting to be king right now."); return true; } bz_BasePlayerRecord *fromPlayer = bz_getPlayerByIndex(playerID); if (fromPlayer) { if (!fromPlayer->admin) { bz_sendTextMessage(BZ_SERVER, playerID, "You must be admin to use the koth commands."); bz_freePlayerRecord(fromPlayer); return true; } bz_freePlayerRecord(fromPlayer); } if (command == "kothon") { koth.enabled = true; bz_sendTextMessagef(BZ_SERVER, BZ_ALLUSERS, "King of the Hill is enabled."); return true; } if (command == "kothoff") { koth.enabled = false; bz_sendTextMessagef(BZ_SERVER, BZ_ALLUSERS, "King of the Hill is disabled."); return true; } if (command == "kothsoundon") { koth.soundEnabled = true; bz_sendTextMessagef(BZ_SERVER, BZ_ALLUSERS, "King of the Hill sounds are enabled."); return true; } if (command == "kothsoundoff") { koth.soundEnabled = false; bz_sendTextMessagef(BZ_SERVER, BZ_ALLUSERS, "King of the Hill sounds are disabled."); return true; } if (command == "kothtimemult") { double inputvalue = ConvertToNum(message, 1, 99); if (inputvalue > 0) { koth.timeMult = (inputvalue / 100); bz_sendTextMessagef(BZ_SERVER, playerID, "Auto time multiplier set to %i percent.", (int) (koth.timeMult * 100 + 0.5)); } else { bz_sendTextMessagef(BZ_SERVER, playerID, "Auto time multiplier (%i) must be between 1 and 99 percent.", (int) (koth.timeMult * 100 + 0.5)); } autoTime(); return true; } if (command == "kothtimemultmin") { double inputvalue = ConvertToNum(message, 1, 99); if (inputvalue > 0) { koth.timeMultMin = (inputvalue / 100); bz_sendTextMessagef(BZ_SERVER, playerID, "Auto time multiplier minimum set to %i percent.", (int) (koth.timeMultMin * 100 + 0.5)); } else { bz_sendTextMessagef(BZ_SERVER, playerID, "Auto time multiplier minimum must be between 1 and 99 percent."); } autoTime(); return true; } if (command == "kothstatus") { if (koth.enabled) bz_sendTextMessagef(BZ_SERVER, playerID, "King of the Hill is currently enabled."); if (!koth.enabled) bz_sendTextMessagef(BZ_SERVER, playerID, "King of the Hill is currently disabled."); if (koth.soundEnabled) bz_sendTextMessagef(BZ_SERVER, playerID, "King of the Hill sounds are currently enabled."); if (!koth.soundEnabled) bz_sendTextMessagef(BZ_SERVER, playerID, "King of the Hill sounds are currently disabled."); if (koth.autoTimeOn) bz_sendTextMessagef(BZ_SERVER, playerID, "Automatic time adjustment is currently enabled."); if (!koth.autoTimeOn) bz_sendTextMessagef(BZ_SERVER, playerID, "Automatic time adjustment is currently disabled."); bz_sendTextMessagef(BZ_SERVER, playerID, "Time multiplier = %i percent.", (int) (koth.timeMult * 100 + 0.5)); bz_sendTextMessagef(BZ_SERVER, playerID, "Time multiplier minimum = %i percent.", (int) (koth.timeMultMin * 100 + 0.5)); int AdjTime = (int) (koth.adjustedTime + 0.5); bz_sendTextMessagef(BZ_SERVER, playerID, "King of the Hill hold time is currently set to: %i seconds", AdjTime); return true; } // explicit time command handler: if (command == "kothtime") { double inputvalue = ConvertToNum(message, 1, 7200); if (inputvalue > 0) { koth.TTH = inputvalue; autoTime(); int AdjTime = (int) (inputvalue + 0.5); bz_sendTextMessagef(BZ_SERVER, BZ_ALLUSERS, "King of the Hill hold time has been set to %i seconds.", AdjTime); } else { bz_sendTextMessagef(BZ_SERVER, playerID, "King of the Hill hold time invalid: must be between 1 and 7200 seconds."); } autoTime(); return true; } if (command == "kothautotimeon") { koth.autoTimeOn = true; autoTime(); bz_sendTextMessagef(BZ_SERVER, BZ_ALLUSERS, "King of the Hill automatic time adjustment on."); return true; } if (command == "kothautotimeoff") { koth.autoTimeOn = false; koth.adjustedTime = koth.TTH; autoTime(); bz_sendTextMessagef(BZ_SERVER, BZ_ALLUSERS, "King of the Hill automatic time adjustment off."); return true; } return false; }
bool KeepAwayCommands::SlashCommand ( int playerID, bz_ApiString _command, bz_ApiString _message, bz_APIStringList * /*_param*/ ) { std::string command = _command.c_str(); std::string message = _message.c_str(); const char* keepermessage = _message.c_str(); if ( command == "kas" ) { if (keepaway.id != -1) bz_sendTextMessage (playerID, keepaway.id, keepermessage); else bz_sendTextMessage(BZ_SERVER, playerID, "There is no one keeping the flag right now."); return true; } if ( command == "kaf" ) { if (keepaway.id == -1) bz_sendTextMessagef (BZ_SERVER, playerID, "The Keep Away flag is: %s", convertFlag(keepaway.flagToKeep).c_str()); else bz_sendTextMessagef (BZ_SERVER, playerID, "%s has Keep Away flag: %s", keepaway.callsign.c_str(), convertFlag(keepaway.flagToKeep).c_str()); return true; } bz_BasePlayerRecord *fromPlayer = bz_getPlayerByIndex(playerID); if (fromPlayer) { if (!fromPlayer->admin) { bz_sendTextMessage(BZ_SERVER, playerID, "You must be admin to use the keepaway commands."); bz_freePlayerRecord(fromPlayer); return true; } bz_freePlayerRecord(fromPlayer); } if ( command == "kasoundoff" ) { keepaway.soundEnabled = false; bz_sendTextMessage (BZ_SERVER, playerID, "Keep Away sounds are disabled."); return true; } if ( command == "kasoundon" ) { keepaway.soundEnabled = true; bz_sendTextMessage (BZ_SERVER, playerID, "Keep Away sounds are enabled."); return true; } if ( command == "kaflagresetoff" ) { keepaway.flagResetEnabled = false; bz_sendTextMessage (BZ_SERVER, playerID, "Keep Away flag reset is disabled."); return true; } if ( command == "kaflagreseton" ) { keepaway.flagResetEnabled = true; bz_sendTextMessage (BZ_SERVER, playerID, "Keep Away flag reset is enabled."); return true; } if ( command == "kaf+" ) { if (!keepaway.forcedFlags) // this will always create an open spot for getFlag(), if it's needed bz_removePlayerFlag (keepaway.id); keepaway.id = -1; keepaway.team = eNoTeam; keepaway.toldFlagFree = false; keepaway.flagToKeep = getFlag(); keepaway.lastReminder = bz_getCurrentTime(); bz_sendTextMessagef(BZ_SERVER, playerID, "Keep Away flag advanced to: %s", convertFlag(keepaway.flagToKeep).c_str()); return true; } if ( command == "kaon") { keepaway.enabled = true; bz_sendTextMessagef (BZ_SERVER, BZ_ALLUSERS, "Keep Away is enabled."); return true; } if ( command == "kaoff") { keepaway.enabled = false; bz_sendTextMessagef (BZ_SERVER, BZ_ALLUSERS, "Keep Away is disabled."); return true; } if ( command == "katimemult") { double inputvalue = ConvertToNum(message, 1, 99); if (inputvalue > 0) { keepaway.timeMult = (inputvalue/100); bz_sendTextMessagef (BZ_SERVER, playerID, "Keep Away auto time multiplier set to %i percent.", (int)(keepaway.timeMult*100 + 0.5)); } else bz_sendTextMessagef (BZ_SERVER, playerID, "Keep Away auto time multiplier must be between 1 and 99 percent.", (int)(keepaway.timeMult*100 + 0.5)); autoTime(); return true; } if ( command == "katimemultmin") { double inputvalue = ConvertToNum(message, 1, 99); if (inputvalue > 0) { keepaway.timeMultMin = (inputvalue/100); bz_sendTextMessagef (BZ_SERVER, playerID, "Keep Away auto time multiplier minimum set to %i percent.", (int)(keepaway.timeMultMin*100 + 0.5)); } else bz_sendTextMessagef (BZ_SERVER, playerID, "Keep Away auto time multiplier minimum must be between 1 and 99 percent."); autoTime(); return true; } if ( command == "kastatus") { if (keepaway.enabled) bz_sendTextMessagef (BZ_SERVER, playerID, "Keep Away is currently enabled."); if (!keepaway.enabled) bz_sendTextMessagef (BZ_SERVER, playerID, "Keep Away is currently disabled."); if (keepaway.autoTimeOn) bz_sendTextMessagef (BZ_SERVER, playerID, "Keep Away automatic time adjustment is currently enabled."); if (!keepaway.autoTimeOn) bz_sendTextMessagef (BZ_SERVER, playerID, "Keep Away automatic time adjustment is currently disabled."); bz_sendTextMessagef (BZ_SERVER, playerID, "Keep Away time multiplier = %i percent.", (int)(keepaway.timeMult*100 + 0.5)); bz_sendTextMessagef (BZ_SERVER, playerID, "Keep Away time multiplier minimum = %i percent.", (int)(keepaway.timeMultMin*100 + 0.5)); int AdjTime = (int)(keepaway.adjustedTime + 0.5); bz_sendTextMessagef (BZ_SERVER, playerID, "Keep Away hold time is currently set to: %i seconds", AdjTime); if (keepaway.forcedFlags) bz_sendTextMessagef (BZ_SERVER, playerID, "Keep Away forced flags is enabled."); if (!keepaway.forcedFlags) bz_sendTextMessagef (BZ_SERVER, playerID, "Keep Away forced flags is disabled."); if (keepaway.soundEnabled) bz_sendTextMessagef (BZ_SERVER, playerID, "Keep Away sounds are enabled."); if (!keepaway.soundEnabled) bz_sendTextMessagef (BZ_SERVER, playerID, "Keep Away sounds are disabled."); if (keepaway.flagResetEnabled) bz_sendTextMessagef (BZ_SERVER, playerID, "Keep Away flag reset is enabled."); if (!keepaway.flagResetEnabled) bz_sendTextMessagef (BZ_SERVER, playerID, "Keep Away flag reset is disabled."); return true; } // explicit time command handler: if ( command == "katime" ) { double inputvalue = ConvertToNum(message, 1, 7200); if (inputvalue > 0 ) { keepaway.TTH = inputvalue; autoTime(); int AdjTime = (int)(inputvalue + 0.5); bz_sendTextMessagef (BZ_SERVER, BZ_ALLUSERS, "Keep Away hold time has been set to %i seconds.", AdjTime); } else bz_sendTextMessagef (BZ_SERVER, playerID, "Keep Away hold time invalid: must be between 1 and 7200 seconds."); autoTime(); return true; } if ( command == "kaautotimeon") { keepaway.autoTimeOn = true; autoTime(); bz_sendTextMessagef (BZ_SERVER, BZ_ALLUSERS, "Keep Away automatic time adjustment on."); return true; } if ( command == "kaautotimeoff") { keepaway.autoTimeOn = false; keepaway.adjustedTime = keepaway.TTH; autoTime(); bz_sendTextMessagef (BZ_SERVER, BZ_ALLUSERS, "Keep Away automatic time adjustment off."); return true; } if ( command == "kaffon") { keepaway.forcedFlags = true; bz_sendTextMessagef (BZ_SERVER, BZ_ALLUSERS, "Forced flags on."); return true; } if ( command == "kaffoff") { keepaway.forcedFlags = false; bz_sendTextMessagef (BZ_SERVER, BZ_ALLUSERS, "Forced flags off."); return true; } return false; }