//Wyrmgus start //void SendCommandBuildBuilding(CUnit &unit, const Vec2i &pos, CUnitType &what, int flush) void SendCommandBuildBuilding(CUnit &unit, const Vec2i &pos, CUnitType &what, int flush, int z) //Wyrmgus end { if (!IsNetworkGame()) { CommandLog("build", &unit, flush, pos.x, pos.y, NoUnitP, what.Ident.c_str(), -1); //Wyrmgus start // CommandBuildBuilding(unit, pos, what, flush); CommandBuildBuilding(unit, pos, what, flush, z); //Wyrmgus end } else { NetworkSendCommand(MessageCommandBuild, unit, pos.x, pos.y, NoUnitP, &what, flush); } }
//Wyrmgus start //void SendCommandPatrol(CUnit &unit, const Vec2i &pos, int flush) void SendCommandPatrol(CUnit &unit, const Vec2i &pos, int flush, int z) //Wyrmgus end { if (!IsNetworkGame()) { CommandLog("patrol", &unit, flush, pos.x, pos.y, NoUnitP, NULL, -1); //Wyrmgus start // CommandPatrolUnit(unit, pos, flush); CommandPatrolUnit(unit, pos, flush, z); //Wyrmgus end } else { NetworkSendCommand(MessageCommandPatrol, unit, pos.x, pos.y, NoUnitP, 0, flush); } }
//Wyrmgus start //void SendCommandUnload(CUnit &unit, const Vec2i &pos, CUnit *what, int flush) void SendCommandUnload(CUnit &unit, const Vec2i &pos, CUnit *what, int flush, int z) //Wyrmgus end { if (!IsNetworkGame()) { CommandLog("unload", &unit, flush, pos.x, pos.y, what, NULL, -1); //Wyrmgus start // CommandUnload(unit, pos, what, flush); CommandUnload(unit, pos, what, flush, z); //Wyrmgus end } else { NetworkSendCommand(MessageCommandUnload, unit, pos.x, pos.y, what, 0, flush); } }
//Wyrmgus start //void SendCommandAttack(CUnit &unit, const Vec2i &pos, CUnit *attack, int flush) void SendCommandAttack(CUnit &unit, const Vec2i &pos, CUnit *attack, int flush, int z) //Wyrmgus end { if (!IsNetworkGame()) { CommandLog("attack", &unit, flush, pos.x, pos.y, attack, NULL, -1); //Wyrmgus start // CommandAttack(unit, pos, attack, flush); CommandAttack(unit, pos, attack, flush, z); //Wyrmgus end } else { NetworkSendCommand(MessageCommandAttack, unit, pos.x, pos.y, attack, 0, flush); } }
//Wyrmgus start //void SendCommandAttackGround(CUnit &unit, const Vec2i &pos, int flush) void SendCommandAttackGround(CUnit &unit, const Vec2i &pos, int flush, int z) //Wyrmgus end { if (!IsNetworkGame()) { CommandLog("attack-ground", &unit, flush, pos.x, pos.y, NoUnitP, NULL, -1); //Wyrmgus start // CommandAttackGround(unit, pos, flush); CommandAttackGround(unit, pos, flush, z); //Wyrmgus end } else { NetworkSendCommand(MessageCommandGround, unit, pos.x, pos.y, NoUnitP, 0, flush); } }
//Wyrmgus start //void SendCommandResourceLoc(CUnit &unit, const Vec2i &pos, int flush) void SendCommandResourceLoc(CUnit &unit, const Vec2i &pos, int flush, int z) //Wyrmgus end { if (!IsNetworkGame()) { CommandLog("resource-loc", &unit, flush, pos.x, pos.y, NoUnitP, NULL, -1); //Wyrmgus start // CommandResourceLoc(unit, pos, flush); CommandResourceLoc(unit, pos, flush, z); //Wyrmgus end } else { NetworkSendCommand(MessageCommandResourceLoc, unit, pos.x, pos.y, NoUnitP, 0, flush); } }
//Wyrmgus start //void SendCommandRepair(CUnit &unit, const Vec2i &pos, CUnit *dest, int flush) void SendCommandRepair(CUnit &unit, const Vec2i &pos, CUnit *dest, int flush, int z) //Wyrmgus end { if (!IsNetworkGame()) { CommandLog("repair", &unit, flush, pos.x, pos.y, dest, NULL, -1); //Wyrmgus start // CommandRepair(unit, pos, dest, flush); CommandRepair(unit, pos, dest, flush, z); //Wyrmgus end } else { NetworkSendCommand(MessageCommandRepair, unit, pos.x, pos.y, dest, 0, flush); } }
//Wyrmgus start //void SendCommandSpellCast(CUnit &unit, const Vec2i &pos, CUnit *dest, int spellid, int flush) void SendCommandSpellCast(CUnit &unit, const Vec2i &pos, CUnit *dest, int spellid, int flush, int z) //Wyrmgus end { if (!IsNetworkGame()) { CommandLog("spell-cast", &unit, flush, pos.x, pos.y, dest, NULL, spellid); //Wyrmgus start // CommandSpellCast(unit, pos, dest, *SpellTypeTable[spellid], flush); CommandSpellCast(unit, pos, dest, *SpellTypeTable[spellid], flush, z); //Wyrmgus end } else { NetworkSendCommand(MessageCommandSpellCast + spellid, unit, pos.x, pos.y, dest, NULL, flush); } }
//Wyrmgus start //void SendCommandTrainUnit(CUnit &unit, CUnitType &what, int flush) void SendCommandTrainUnit(CUnit &unit, CUnitType &what, int player, int flush) //Wyrmgus end { if (!IsNetworkGame()) { //Wyrmgus start // CommandLog("train", &unit, flush, -1, -1, NoUnitP, what.Ident.c_str(), -1); // CommandTrainUnit(unit, what, flush); CommandLog("train", &unit, flush, -1, -1, NoUnitP, what.Ident.c_str(), player); CommandTrainUnit(unit, what, player, flush); //Wyrmgus end } else { //Wyrmgus start // NetworkSendCommand(MessageCommandTrain, unit, 0, 0, NoUnitP, &what, flush); NetworkSendCommand(MessageCommandTrain, unit, player, 0, NoUnitP, &what, flush); //Wyrmgus end } }
//Wyrmgus start //void SendCommandResearch(CUnit &unit, CUpgrade &what, int flush) void SendCommandResearch(CUnit &unit, CUpgrade &what, int player, int flush) //Wyrmgus end { if (!IsNetworkGame()) { //Wyrmgus start // CommandLog("research", &unit, flush, -1, -1, NoUnitP, what.Ident.c_str(), -1); // CommandResearch(unit, what, flush); CommandLog("research", &unit, flush, -1, -1, NoUnitP, what.Ident.c_str(), player); CommandResearch(unit, what, player, flush); //Wyrmgus end } else { NetworkSendCommand(MessageCommandResearch, unit, //Wyrmgus start // what.ID, 0, NoUnitP, NULL, flush); what.ID, player, NoUnitP, NULL, flush); //Wyrmgus end } }
/** ** Send command: Diplomacy changed. ** ** @param player Player which changes his state. ** @param state New diplomacy state. ** @param opponent Opponent. */ void SendCommandDiplomacy(int player, int state, int opponent) { if (!IsNetworkGame()) { switch (state) { case DiplomacyNeutral: CommandLog("diplomacy", NoUnitP, 0, player, opponent, NoUnitP, "neutral", -1); break; case DiplomacyAllied: CommandLog("diplomacy", NoUnitP, 0, player, opponent, NoUnitP, "allied", -1); break; case DiplomacyEnemy: CommandLog("diplomacy", NoUnitP, 0, player, opponent, NoUnitP, "enemy", -1); break; //Wyrmgus start case DiplomacyOverlord: CommandLog("diplomacy", NoUnitP, 0, player, opponent, NoUnitP, "overlord", -1); break; case DiplomacyVassal: CommandLog("diplomacy", NoUnitP, 0, player, opponent, NoUnitP, "vassal", -1); break; //Wyrmgus end case DiplomacyCrazy: CommandLog("diplomacy", NoUnitP, 0, player, opponent, NoUnitP, "crazy", -1); break; } CommandDiplomacy(player, state, opponent); } else { NetworkSendExtendedCommand(ExtendedMessageDiplomacy, -1, player, state, opponent, 0); } }
/** ** Execute a command (from network). ** ** @param msgnr Network message type ** @param unum Unit number (slot) that receive the command. ** @param x optional X map position. ** @param y optional y map position. ** @param dstnr optional destination unit. */ void ExecCommand(unsigned char msgnr, UnitRef unum, unsigned short x, unsigned short y, UnitRef dstnr) { CUnit &unit = UnitManager.GetSlotUnit(unum); const Vec2i pos(x, y); const int arg1 = x; const int arg2 = y; // // Check if unit is already killed? // if (unit.Destroyed) { DebugPrint(" destroyed unit skipping %d\n" _C_ UnitNumber(unit)); return; } Assert(unit.Type); const int status = (msgnr & 0x80) >> 7; // Note: destroyed destination unit is handled by the action routines. switch (msgnr & 0x7F) { case MessageSync: return; case MessageQuit: return; case MessageChat: return; case MessageCommandStop: CommandLog("stop", &unit, FlushCommands, -1, -1, NoUnitP, NULL, -1); CommandStopUnit(unit); break; case MessageCommandStand: CommandLog("stand-ground", &unit, status, -1, -1, NoUnitP, NULL, -1); CommandStandGround(unit, status); break; case MessageCommandDefend: { if (dstnr != (unsigned short)0xFFFF) { CUnit &dest = UnitManager.GetSlotUnit(dstnr); Assert(dest.Type); CommandLog("defend", &unit, status, -1, -1, &dest, NULL, -1); CommandDefend(unit, dest, status); } break; } case MessageCommandFollow: { if (dstnr != (unsigned short)0xFFFF) { CUnit &dest = UnitManager.GetSlotUnit(dstnr); Assert(dest.Type); CommandLog("follow", &unit, status, -1, -1, &dest, NULL, -1); CommandFollow(unit, dest, status); } break; } case MessageCommandMove: //Wyrmgus start // CommandLog("move", &unit, status, pos.x, pos.y, NoUnitP, NULL, -1); // CommandMove(unit, pos, status); if (!unit.CanMove()) { //FIXME: find better way to identify whether the unit should move or set a rally point CommandLog("rally-point", &unit, status, pos.x, pos.y, NoUnitP, NULL, -1); CommandRallyPoint(unit, pos); } else { CommandLog("move", &unit, status, pos.x, pos.y, NoUnitP, NULL, -1); CommandMove(unit, pos, status); } //Wyrmgus end break; //Wyrmgus start case MessageCommandPickUp: { if (dstnr != (unsigned short)0xFFFF) { CUnit &dest = UnitManager.GetSlotUnit(dstnr); Assert(dest.Type); CommandLog("pick-up", &unit, status, -1, -1, &dest, NULL, -1); CommandPickUp(unit, dest, status); } break; } //Wyrmgus end case MessageCommandRepair: { CUnit *dest = NoUnitP; if (dstnr != (unsigned short)0xFFFF) { dest = &UnitManager.GetSlotUnit(dstnr); Assert(dest && dest->Type); } CommandLog("repair", &unit, status, pos.x, pos.y, dest, NULL, -1); CommandRepair(unit, pos, dest, status); break; } case MessageCommandAutoRepair: CommandLog("auto-repair", &unit, status, arg1, arg2, NoUnitP, NULL, 0); CommandAutoRepair(unit, arg1); break; case MessageCommandAttack: { CUnit *dest = NoUnitP; if (dstnr != (unsigned short)0xFFFF) { dest = &UnitManager.GetSlotUnit(dstnr); Assert(dest && dest->Type); } CommandLog("attack", &unit, status, pos.x, pos.y, dest, NULL, -1); CommandAttack(unit, pos, dest, status); break; } case MessageCommandGround: CommandLog("attack-ground", &unit, status, pos.x, pos.y, NoUnitP, NULL, -1); CommandAttackGround(unit, pos, status); break; //Wyrmgus start case MessageCommandUse: { if (dstnr != (unsigned short)0xFFFF) { CUnit &dest = UnitManager.GetSlotUnit(dstnr); Assert(dest.Type); CommandLog("use", &unit, status, -1, -1, &dest, NULL, -1); CommandUse(unit, dest, status); } break; } //Wyrmgus end case MessageCommandPatrol: CommandLog("patrol", &unit, status, pos.x, pos.y, NoUnitP, NULL, -1); CommandPatrolUnit(unit, pos, status); break; case MessageCommandBoard: { if (dstnr != (unsigned short)0xFFFF) { CUnit &dest = UnitManager.GetSlotUnit(dstnr); Assert(dest.Type); CommandLog("board", &unit, status, arg1, arg2, &dest, NULL, -1); CommandBoard(unit, dest, status); } break; } case MessageCommandUnload: { CUnit *dest = NULL; if (dstnr != (unsigned short)0xFFFF) { dest = &UnitManager.GetSlotUnit(dstnr); Assert(dest && dest->Type); } CommandLog("unload", &unit, status, pos.x, pos.y, dest, NULL, -1); CommandUnload(unit, pos, dest, status); break; } case MessageCommandBuild: CommandLog("build", &unit, status, pos.x, pos.y, NoUnitP, UnitTypes[dstnr]->Ident.c_str(), -1); CommandBuildBuilding(unit, pos, *UnitTypes[dstnr], status); break; case MessageCommandDismiss: CommandLog("dismiss", &unit, FlushCommands, -1, -1, NULL, NULL, -1); CommandDismiss(unit); break; case MessageCommandResourceLoc: CommandLog("resource-loc", &unit, status, pos.x, pos.y, NoUnitP, NULL, -1); CommandResourceLoc(unit, pos, status); break; case MessageCommandResource: { if (dstnr != (unsigned short)0xFFFF) { CUnit &dest = UnitManager.GetSlotUnit(dstnr); Assert(dest.Type); CommandLog("resource", &unit, status, -1, -1, &dest, NULL, -1); CommandResource(unit, dest, status); } break; } case MessageCommandReturn: { CUnit *dest = (dstnr != (unsigned short)0xFFFF) ? &UnitManager.GetSlotUnit(dstnr) : NULL; CommandLog("return", &unit, status, -1, -1, dest, NULL, -1); CommandReturnGoods(unit, dest, status); break; } case MessageCommandTrain: //Wyrmgus start // CommandLog("train", &unit, status, -1, -1, NoUnitP, UnitTypes[dstnr]->Ident.c_str(), -1); // CommandTrainUnit(unit, *UnitTypes[dstnr], status); CommandLog("train", &unit, status, -1, -1, NoUnitP, UnitTypes[dstnr]->Ident.c_str(), arg1); // use X as a way to mark the player CommandTrainUnit(unit, *UnitTypes[dstnr], arg1, status); //Wyrmgus end break; case MessageCommandCancelTrain: // We need (short)x for the last slot -1 if (dstnr != (unsigned short)0xFFFF) { CommandLog("cancel-train", &unit, FlushCommands, -1, -1, NoUnitP, UnitTypes[dstnr]->Ident.c_str(), (short)x); CommandCancelTraining(unit, (short)x, UnitTypes[dstnr]); } else { CommandLog("cancel-train", &unit, FlushCommands, -1, -1, NoUnitP, NULL, (short)x); CommandCancelTraining(unit, (short)x, NULL); } break; case MessageCommandUpgrade: //Wyrmgus start /* CommandLog("upgrade-to", &unit, status, -1, -1, NoUnitP, UnitTypes[dstnr]->Ident.c_str(), -1); CommandUpgradeTo(unit, *UnitTypes[dstnr], status); break; */ if (arg1 == 2) { //use X as a way to mark whether this is an upgrade or a transformation CommandLog("transform-into", &unit, status, -1, -1, NoUnitP, UnitTypes[dstnr]->Ident.c_str(), -1); CommandTransformIntoType(unit, *UnitTypes[dstnr]); } else { CommandLog("upgrade-to", &unit, status, -1, -1, NoUnitP, UnitTypes[dstnr]->Ident.c_str(), -1); CommandUpgradeTo(unit, *UnitTypes[dstnr], status); } break; //Wyrmgus end case MessageCommandCancelUpgrade: CommandLog("cancel-upgrade-to", &unit, FlushCommands, -1, -1, NoUnitP, NULL, -1); CommandCancelUpgradeTo(unit); break; case MessageCommandResearch: CommandLog("research", &unit, status, -1, -1, NoUnitP, AllUpgrades[arg1]->Ident.c_str(), -1); CommandResearch(unit, *AllUpgrades[arg1], status); break; case MessageCommandCancelResearch: CommandLog("cancel-research", &unit, FlushCommands, -1, -1, NoUnitP, NULL, -1); CommandCancelResearch(unit); break; //Wyrmgus start case MessageCommandQuest: { CommandLog("quest", &unit, 0, 0, 0, NoUnitP, Quests[arg1]->Ident.c_str(), -1); CommandQuest(unit, Quests[arg1]); break; } case MessageCommandBuy: { if (dstnr != (unsigned short)0xFFFF) { CUnit &dest = UnitManager.GetSlotUnit(dstnr); Assert(dest.Type); CommandLog("buy", &unit, 0, -1, -1, &dest, NULL, arg1); CommandBuy(unit, &dest, arg1); } break; } //Wyrmgus end default: { int id = (msgnr & 0x7f) - MessageCommandSpellCast; if (arg2 != (unsigned short)0xFFFF) { CUnit *dest = NULL; if (dstnr != (unsigned short)0xFFFF) { dest = &UnitManager.GetSlotUnit(dstnr); Assert(dest && dest->Type); } CommandLog("spell-cast", &unit, status, pos.x, pos.y, dest, NULL, id); CommandSpellCast(unit, pos, dest, *SpellTypeTable[id], status); } else { CommandLog("auto-spell-cast", &unit, status, arg1, -1, NoUnitP, NULL, id); CommandAutoSpellCast(unit, id, arg1); } break; } } }
/** ** Handle keys in input mode. ** ** @param key Key scancode. ** @return True input finished. */ static int InputKey(int key) { char ChatMessage[sizeof(Input) + 40]; int i; char *namestart; char *p; char *q; switch (key) { case SDLK_RETURN: case SDLK_KP_ENTER: // RETURN // Replace ~~ with ~ for (p = q = Input; *p;) { if (*p == '~') { ++p; } *q++ = *p++; } *q = '\0'; #ifdef DEBUG if (Input[0] == '-') { if (!GameObserve && !GamePaused) { CommandLog("input", NoUnitP, FlushCommands, -1, -1, NoUnitP, Input, -1); CclCommand(Input + 1, false); } } else #endif if (!IsNetworkGame()) { if (!GameObserve && !GamePaused) { if (HandleCheats(Input)) { CommandLog("input", NoUnitP, FlushCommands, -1, -1, NoUnitP, Input, -1); } } } // Check for Replay and ffw x #ifdef DEBUG if (strncmp(Input, "ffw ", 4) == 0) { #else if (strncmp(Input, "ffw ", 4) == 0 && ReplayGameType != ReplayNone) { #endif FastForwardCycle = atoi(&Input[4]); } if (Input[0]) { // Replace ~ with ~~ for (p = Input; *p; ++p) { if (*p == '~') { q = p + strlen(p); q[1] = '\0'; while (q > p) { *q = *(q - 1); --q; } ++p; } } snprintf(ChatMessage, sizeof(ChatMessage), "~%s~<%s>~> %s", PlayerColorNames[ThisPlayer->Index].c_str(), ThisPlayer->Name.c_str(), Input); // FIXME: only to selected players ... NetworkChatMessage(ChatMessage); } // FALL THROUGH case SDLK_ESCAPE: KeyState = KeyStateCommand; UI.StatusLine.Clear(); return 1; case SDLK_BACKSPACE: if (InputIndex) { if (Input[InputIndex - 1] == '~') { Input[--InputIndex] = '\0'; } InputIndex = UTF8GetPrev(Input, InputIndex); if (InputIndex >= 0) { Input[InputIndex] = '\0'; ShowInput(); } } return 1; case SDLK_TAB: namestart = strrchr(Input, ' '); if (namestart) { ++namestart; } else { namestart = Input; } if (!strlen(namestart)) { return 1; } for (i = 0; i < PlayerMax; ++i) { if (Players[i].Type != PlayerPerson) { continue; } if (!strncasecmp(namestart, Players[i].Name.c_str(), strlen(namestart))) { InputIndex += strlen(Players[i].Name.c_str()) - strlen(namestart); strcpy_s(namestart, sizeof(Input) - (namestart - Input), Players[i].Name.c_str()); if (namestart == Input) { InputIndex += 2; strcat_s(namestart, sizeof(Input) - (namestart - Input), ": "); } ShowInput(); } } return 1; default: if (key >= ' ') { gcn::Key k(key); std::string kstr = k.toString(); if (key == '~') { if (InputIndex < (int)sizeof(Input) - 2) { Input[InputIndex++] = key; Input[InputIndex++] = key; Input[InputIndex] = '\0'; ShowInput(); } } else if (InputIndex < (int)(sizeof(Input) - kstr.size())) { for (size_t i = 0; i < kstr.size(); ++i) { Input[InputIndex++] = kstr[i]; } Input[InputIndex] = '\0'; ShowInput(); } return 1; } break; } return 0; } /** ** Save a screenshot. */ static void Screenshot() { CFile fd; char filename[30]; int i; for (i = 1; i <= 99; ++i) { // FIXME: what if we can't write to this directory? snprintf(filename, sizeof(filename), "screen%02d.png", i); if (fd.open(filename, CL_OPEN_READ) == -1) { break; } fd.close(); } SaveScreenshotPNG(filename); }
bool CDebuggerWin::ExecCommand(char *linetext) { char emptystring[]=" "; char tmptext[MAX_LINE_SIZE+1]; char *arglist[MAX_COMMAND_ARGS+1]; int argcount=0,loop=0; bool cmd_ok=TRUE; enum { COMMAND_QUIT, COMMAND_RUN, COMMAND_STOP, COMMAND_STEP, COMMAND_BPOINT, COMMAND_BPOINTC, COMMAND_RESET, COMMAND_REGISTERS, COMMAND_MEM_SET, COMMAND_MEM_DUMP, COMMAND_MEM_LOAD, COMMAND_MEM_SAVE, COMMAND_CART_SET, COMMAND_CART_DUMP, COMMAND_CART_LOAD, COMMAND_CART_SAVE, COMMAND_HELP, COMMAND_SCRIPT, COMMAND_SEARCH, COMMAND_REM, COMMAND_EXECUTE, COMMAND_LOG, COMMAND_UNKNOWN }; const struct command_list commands[]= { { COMMAND_QUIT, "QUIT" ,"QUIT - Immediate exit from the emulator back to windows" ,"" }, { COMMAND_RUN, "RUN" ,"RUN [xxxx] - Run from xxxx (optional)" ,"Usage: RUN [addr]" }, { COMMAND_STOP, "STOP" ,"STOP - Halt CPU" ,"" }, { COMMAND_STEP, "STEP" ,"STEP [xxxx] - Single Step the CPU from addr xxxx (optional)" ,"" }, { COMMAND_SCRIPT, "SCRIPT","SCRIPT <file> - Run a script file" ,"Usage: SCRIPT <file>" }, { COMMAND_BPOINT, "BP" ,"BP [n] [xxxx]/CLR - Set/List/Clear breakpoint n to xxxx" ,"Usage: BP [n] [xxxx]/CLR" }, { COMMAND_RESET, "RESET" ,"RESET - Reset CPU, also halts" ,"" }, { COMMAND_REGISTERS, "REG" ,"REG [PC/SP/PS/X/Y/A] [Value] - Display/Set registers" ,"Usage: REG [PC/SP/PS/X/Y/A] [Value]" }, { COMMAND_MEM_SET, "MS" ,"MS <xxxx> <aa> [bb]..[ff] - Set RAM xxxx to aa.bb,cc,etc" ,"Usage: MS <xxxx> <aa> [bb]..[ff]" }, { COMMAND_MEM_DUMP, "MD" ,"MD [xxxx] [yyyy] - Dump RAM from xxxx to yyyy" ,"Usage: MD <xxxx> [yyyy]" }, { COMMAND_MEM_LOAD, "MLOAD" ,"MLOAD <xxxx> <file> - Load RAM from file starting at xxxx" ,"Usage: MLOAD <xxxx> <file>" }, { COMMAND_MEM_SAVE, "MSAVE" ,"MSAVE <xxxx> <yyyy> <file> - Save RAM to file from xxxx-yyyy" ,"Usage: MSAVE <xxxx> <yyyy> <file>" }, { COMMAND_SEARCH, "MSRCH" ,"MSRCH <xxxx> <yyyy> \"param\" - Search RAM for string" ,"Usage: MSRCH <xxxx> <yyyy> \"param\"\\<aa bb cc ...>" }, { COMMAND_SEARCH, "MSRCH" ,"MSRCH <xxxx> <yyyy> <aa bb ..> - Search RAM for bytes" ,"Usage: MSRCH <xxxx> <yyyy> \"param\"\\<aa bb cc ...>" }, { COMMAND_CART_SET, "CS" ,"CS <xxxx> <aa> [bb]..[ff] - Set cartridge memory xxxx to aa.bb,cc,etc" ,"Usage: CS <xxxx> <aa> [bb]..[ff]" }, { COMMAND_CART_DUMP, "CD" ,"CD [xxxxxx] [yyyyyy] - Dump cartridge memory from xxxxxx to yyyyyy" ,"Usage: CD <xxxxxx> [yyyyyy]" }, { COMMAND_CART_LOAD, "CLOAD" ,"CLOAD <xxxxxx> <file> - Load cartridge from file starting at xxxxxx" ,"Usage: CLOAD <xxxxxx> <file>" }, { COMMAND_CART_SAVE, "CSAVE" ,"CSAVE <xxxxxx> <yyyyyy> <file> - Save cartridge to file from xxxxxx-yyyyyy" ,"Usage: CSAVE <xxxxxx> <yyyyyy> <file>" }, { COMMAND_SEARCH, "CSRCH" ,"CSRCH <xxxx> <yyyy> \"param\" - Search cartridge for string" ,"Usage: CSRCH <xxxx> <yyyy> \"param\"\\<aa bb cc ...>" }, { COMMAND_SEARCH, "CSRCH" ,"CSRCH <xxxx> <yyyy> <aa bb ..> - Search cartridge for bytes" ,"Usage: CSRCH <xxxx> <yyyy> \"param\"\\<aa bb cc ...>" }, { COMMAND_REM, "REM" ,"REM - Some comments - Script Remark/Comments, will be ignored " ,"" }, { COMMAND_EXECUTE, "EXEC" ,"EXEC .... - Execute/Spawn external command" ,"Usage: EXEC (args....)" }, { COMMAND_LOG, "LOG" ,"LOG [filename] .... - Log all output to a file" ,"Usage: LOG [filename]" }, { COMMAND_HELP, "HELP" ,"HELP - Prints this text" ,"" }, { COMMAND_UNKNOWN, "" ,"" ,"" } }; // Dump back to the edit window strcpy(tmptext,">"); strncat(tmptext,linetext,MAX_LINE_SIZE-1); tmptext[MAX_LINE_SIZE]=0; LineOutput(tmptext); // Splat remaining arg array to null for(loop=0;loop<MAX_COMMAND_ARGS;loop++) arglist[loop]=&emptystring[0]; arglist[MAX_COMMAND_ARGS]=NULL; loop=0; // Put all to upper case while(linetext[loop]!=0x00) { linetext[loop]=toupper(linetext[loop]); loop++; } if((arglist[0]=Tokenize(linetext))!=NULL) { argcount++; while(argcount<MAX_COMMAND_ARGS) { if((arglist[argcount]=Tokenize(NULL))==NULL) { // Fix up the null string on the end arglist[argcount]=emptystring; break; } argcount++; } } // Process into argc/argv if(argcount) { loop=0; for(;;) { // Check for the end of the list if(strcmp(commands[loop].command,"")==0) break; // Check our command if(strcmp(commands[loop].command,arglist[0])==0) break; loop++; } switch(commands[loop].command_id) { case COMMAND_REM: cmd_ok=TRUE; break; case COMMAND_QUIT: cmd_ok=CommandQuit(argcount,arglist); break; case COMMAND_RUN: cmd_ok=CommandRun(argcount,arglist); break; case COMMAND_STOP: cmd_ok=CommandStop(argcount,arglist); break; case COMMAND_STEP: cmd_ok=CommandStep(argcount,arglist); break; case COMMAND_BPOINT: cmd_ok=CommandBpoint(argcount,arglist); break; case COMMAND_SCRIPT: cmd_ok=CommandScript(argcount,arglist); break; case COMMAND_SEARCH: cmd_ok=CommandSearch(argcount,arglist); break; case COMMAND_RESET: cmd_ok=CommandReset(argcount,arglist); break; case COMMAND_REGISTERS: cmd_ok=CommandRegisters(argcount,arglist); break; case COMMAND_MEM_SET: cmd_ok=CommandMemSet(argcount,arglist); break; case COMMAND_MEM_DUMP: cmd_ok=CommandMemDump(argcount,arglist); break; case COMMAND_MEM_LOAD: cmd_ok=CommandMemLoad(argcount,arglist); break; case COMMAND_MEM_SAVE: cmd_ok=CommandMemSave(argcount,arglist); break; case COMMAND_CART_SET: cmd_ok=CommandCartSet(argcount,arglist); break; case COMMAND_CART_DUMP: cmd_ok=CommandCartDump(argcount,arglist); break; case COMMAND_CART_LOAD: cmd_ok=CommandCartLoad(argcount,arglist); break; case COMMAND_CART_SAVE: cmd_ok=CommandCartSave(argcount,arglist); break; case COMMAND_EXECUTE: cmd_ok=CommandExecute(argcount,arglist); break; case COMMAND_LOG: cmd_ok=CommandLog(argcount,arglist); break; case COMMAND_HELP: { int loop=0; LineOutput("Supported Command Line Functions are:"); do { if(strcmp(commands[loop].help,"")!=0) LineOutput(commands[loop].help); loop++; } while(commands[loop].command_id!=COMMAND_UNKNOWN); LineOutput(" ( <xx> - Mandatory agrument, [xx] - Optional argument )"); LineOutput(""); cmd_ok=TRUE; } break; default: case COMMAND_UNKNOWN: cmd_ok=CommandNotFound(argcount,arglist); break; } // Redraw all debug windows incase global data change AfxGetMainWnd()->PostMessage(WM_COMMAND,IDM_DRAW_DEBUG_WINDOWS); if(cmd_ok) { // Clear the command line mpEditLine->SetWindowText(""); } else { // Provide usage text if available if(strcmp(commands[loop].help,"")!=0) LineOutput(commands[loop].usage); } } return cmd_ok; }
/** ** CreateGame. ** ** Load map, graphics, sounds, etc ** ** @param filename map filename ** @param map map loaded ** ** @todo FIXME: use in this function InitModules / LoadModules!!! */ void CreateGame(const char *filename, CMap *map) { int i; if (SaveGameLoading) { SaveGameLoading = 0; // Load game, already created game with Init/LoadModules CommandLog(NULL, NoUnitP, FlushCommands, -1, -1, NoUnitP, NULL, -1); return; } InitVisionTable(); // build vision table for fog of war InitPlayers(); if (Map.Info.Filename.empty() && filename) { char path[PATH_MAX]; Assert(filename); LibraryFileName(filename, path, sizeof(path)); if(strcasestr(filename, ".smp")) { LuaLoadFile(path); } } for (i = 0; i < PlayerMax; ++i) { int playertype = Map.Info.PlayerType[i]; // Network games only: if (GameSettings.Presets[i].Type != SettingsPresetMapDefault) { playertype = GameSettings.Presets[i].Type; } CreatePlayer(playertype); } if (filename) { if (CurrentMapPath != filename) { strcpy_s(CurrentMapPath, sizeof(CurrentMapPath), filename); } // // Load the map. // InitUnitTypes(1); LoadMap(filename, map); // HARDCODING FOG OF WAR TRUE. It doesn't currently use preferences on a game restart - Should be changed map->NoFogOfWar = true; Map.Reveal(); } GameCycle = 0; FastForwardCycle = 0; SyncHash = 0; InitSyncRand(); if (IsNetworkGame()) { // Prepare network play DebugPrint("Client setup: Calling InitNetwork2\n"); InitNetwork2(); } else { if (LocalPlayerName && strcmp(LocalPlayerName, "Anonymous")) { ThisPlayer->SetName(LocalPlayerName); } } CallbackMusicOn(); #if 0 GamePaused = true; #endif if (FlagRevealMap) { Map.Reveal(); } // // Setup game types // // FIXME: implement more game types if (GameSettings.GameType != SettingsGameTypeMapDefault) { switch (GameSettings.GameType) { case SettingsGameTypeMelee: break; case SettingsGameTypeFreeForAll: GameTypeFreeForAll(); break; case SettingsGameTypeTopVsBottom: GameTypeTopVsBottom(); break; case SettingsGameTypeLeftVsRight: GameTypeLeftVsRight(); break; case SettingsGameTypeManVsMachine: GameTypeManVsMachine(); break; case SettingsGameTypeManTeamVsMachine: GameTypeManTeamVsMachine(); // Future game type ideas #if 0 case SettingsGameTypeOneOnOne: break; case SettingsGameTypeCaptureTheFlag: break; case SettingsGameTypeGreed: break; case SettingsGameTypeSlaughter: break; case SettingsGameTypeSuddenDeath: break; case SettingsGameTypeTeamMelee: break; case SettingsGameTypeTeamCaptureTheFlag: break; #endif } } // // Graphic part // SetPlayersPalette(); InitIcons(); LoadIcons(); LoadCursors(PlayerRaces.Name[ThisPlayer->Race]); UnitUnderCursor = NoUnitP; InitMissileTypes(); #ifndef DYNAMIC_LOAD LoadMissileSprites(); #endif InitConstructions(); LoadConstructions(); LoadUnitTypes(); LoadDecorations(); InitSelections(); InitUserInterface(); UI.Load(); UI.Minimap.Create(); Map.Init(); PreprocessMap(); // // Sound part // LoadUnitSounds(); MapUnitSounds(); if (SoundEnabled()) { InitSoundClient(); } // // Spells // InitSpells(); // // Init units' groups // InitGroups(); // // Init players? // DebugPlayers(); PlayersInitAi(); // // Upgrades // InitUpgrades(); // // Dependencies // InitDependencies(); // // Buttons (botpanel) // InitButtons(); // // Triggers // InitTriggers(); SetDefaultTextColors(UI.NormalFontColor, UI.ReverseFontColor); #if 0 if (!UI.SelectedViewport) { UI.SelectedViewport = UI.Viewports; } #endif UI.SelectedViewport->Center( ThisPlayer->StartX, ThisPlayer->StartY, TileSizeX / 2, TileSizeY / 2); // // Various hacks wich must be done after the map is loaded. // // FIXME: must be done after map is loaded InitAStar(); // // FIXME: The palette is loaded after the units are created. // FIXME: This loops fixes the colors of the units. // for (i = 0; i < NumUnits; ++i) { // I don't really think that there can be any rescued // units at this point. if (Units[i]->RescuedFrom) { Units[i]->Colors = &Units[i]->RescuedFrom->UnitColors; } else { Units[i]->Colors = &Units[i]->Player->UnitColors; } } GameResult = GameNoResult; CommandLog(NULL, NoUnitP, FlushCommands, -1, -1, NoUnitP, NULL, -1); Video.ClearScreen(); }