Hooman, I'll look some of the options you pointed out for replacing the functions.
I roped my wife into playing Outpost Monopoly with me to test it out. After making it around the board about 2-3 time, the game crashed due to a divide by zero error. So, there is currently at least one crashing bug.
After playing for a while, we thing the dice is rolling multiple times per turn and just using the final roll. Hopefully it won't be too far to fix this.
I'm having difficulty modifying the code due to the colorful formatting practices of the previous author. See the Hook function below for an example (the entire code block is one function).
void Hook (char* chatText, int sourcePlayerNum)
{
char string[10] = "", argument1[10] = "", argument2[10] = "";;
int wordLength;
bool errored = false, targetPlayerFound = false, cardFound = false;
if (strncmp (chatText, "/trade", 6) == false) //If the message starts with the trade command
{
//Skip the /trade tag from the message string
wordLength = strcspn(chatText, " .,?!");
strncpy(string, chatText, wordLength);
strcpy (chatText, chatText + wordLength + 1);
//Store the first argument, be it the words "lot" or "goojf" or the amount of money to be traded.
wordLength = strcspn(chatText, " .,?!");
strncpy(string, chatText, wordLength);
strcpy (chatText, chatText + wordLength + 1);
if (strncmp (string, "lot", 3) == false) //If lot trading has been called
{
//Store the number of the lot to be traded
wordLength = strcspn(chatText, " .,?!");
strncpy(argument1, chatText, wordLength);
strcpy (chatText, chatText + wordLength + 1);
//Skip the intermediate word, formally "to"
wordLength = strcspn(chatText, " .,?!");
strncpy(argument2, chatText, wordLength);
strcpy (chatText, chatText + wordLength + 1);
//Store the target player, who will receive the lot
wordLength = strcspn(chatText, " .,?!");
strncpy(argument2, chatText, wordLength);
if (isdigit(argument2[0]) != false)
if (atoi(argument2) > 0 && atoi(argument2) <= TethysGame::NoPlayers()) //If the target player exists
{
for (i = 0; i < noActivePlayers; i++)
if (PlayerOrder[i].IsPlayerNo == atoi(argument2) - 1)
{
if (atoi(argument2) != Lands[atoi(argument1)].Owner + 1) //If the target is not the sender
if (Lands[atoi(argument1)].Owner == sourcePlayerNum) //If the sender owns the lot to be traded
if (isdigit(argument1[0]) != false)
if (atoi(argument1) > 0 && atoi(argument1) < 40) //If in the list
if (atoi(argument1) == 5 || atoi(argument1) == 12 || atoi(argument1) == 15 || atoi(argument1) == 25 || atoi(argument1) == 28 || atoi(argument1) == 35) //If Utility/Railroad, simply trade
TradeLot(atoi(argument1), atoi(argument2) - 1, sourcePlayerNum, chatText);
else if (Lands[atoi(argument1)].Housing == 0) TradeLot(atoi(argument1), atoi(argument2) - 1, sourcePlayerNum, chatText); //If upgradable lot, check for 0 houses and trade
else {strcpy(chatText, "Can't trade upgraded lots."); TethysGame::AddGameSound (sndBld_not, -1);}
else {strcpy(chatText, "Not a lot."); TethysGame::AddGameSound (sndBld_not, -1);}
else {strcpy(chatText, "Must input a lot &n&u&m&b&e&r."); TethysGame::AddGameSound (sndBld_not, -1);}
else {strcpy(chatText, "You don't own that lot."); TethysGame::AddGameSound (sndBld_not, -1);}
else {strcpy(chatText, "Can't trade to yourself."); TethysGame::AddGameSound (sndBld_not, -1);}
targetPlayerFound = true;
break;
} else;
if (targetPlayerFound == false) {strcpy (chatText, "Player is no longer active."); TethysGame::AddGameSound (sndBld_not, -1);}
}
else {strcpy (chatText, "No such player."); TethysGame::AddGameSound (sndBld_not, -1);}
else {strcpy(chatText, "Must input a player &n&u&m&b&e&r."); TethysGame::AddGameSound (sndBld_not, -1);}
}
else if (strncmp (string, "goojf", 5) == false) // If GOoJF card trading is called
{
//Skip the intermediate word, formally "to"
wordLength = strcspn(chatText, " .,?!");
strncpy(argument1, chatText, wordLength);
strcpy (chatText, chatText + wordLength + 1);
//Store the target player, who will receive the card
wordLength = strcspn(chatText, " .,?!");
strncpy(argument1, chatText, wordLength);
for (j = 2; j >= 0; j--) //Find an owned GOoJF card
if (GOOJF[j] == sourcePlayerNum) //Make sure it's owned by the sender
{
if (isdigit(argument1[0]) != false)
if (atoi(argument1) > 0 && atoi(argument1) <= TethysGame::NoPlayers()) // If the target player exists
{
for (i = 0; i < noActivePlayers; i++)
if (PlayerOrder[i].IsPlayerNo == atoi(argument1) - 1)
{
if (atoi(argument1) != sourcePlayerNum + 1) TradeGOoJF(j, atoi(argument1) - 1, sourcePlayerNum, chatText); //If the target is not the sender, send card
else {strcpy(chatText, "Can't trade to yourself."); TethysGame::AddGameSound (sndBld_not, -1);}
targetPlayerFound = true;
break;
}
if (targetPlayerFound == false) {strcpy (chatText, "Player is no longer active."); TethysGame::AddGameSound (sndBld_not, -1);}
}
else {strcpy(chatText, "No such player."); TethysGame::AddGameSound (sndBld_not, -1);}
else {strcpy(chatText, "Must input a player &n&u&m&b&e&r."); TethysGame::AddGameSound (sndBld_not, -1);}
cardFound = true;
break;
}
if (cardFound == false) {strcpy (chatText, "You don't own a GOoJF card."); TethysGame::AddGameSound (sndBld_not, -1);}
}
else if (atoi(string) > 0) //If ore trading is called
{
//Skip the intermediate word, formally "to"
wordLength = strcspn(chatText, " .,?!");
strncpy(argument1, chatText, wordLength);
strcpy (chatText, chatText + wordLength + 1);
//Store the target player, who will receive the ore
wordLength = strcspn(chatText, " .,?!");
strncpy(argument1, chatText, wordLength);
if (isdigit(argument1[0]) != false)
if (atoi(argument1) > 0 && atoi(argument1) <= TethysGame::NoPlayers()) // If the target player exists
{
for (i = 0; i < noActivePlayers; i++)
if (PlayerOrder[i].IsPlayerNo == atoi(argument1) - 1)
{
if (atoi(argument1) != sourcePlayerNum + 1) //If the target is not the sender
if (Player[sourcePlayerNum].Ore() >= atoi(string)) TradeOre(atoi(string), atoi(argument1) - 1, sourcePlayerNum, chatText); //If the sender has enough ore, trade
else {strcpy (chatText, "You do not have enough ore!"); TethysGame::AddGameSound (sndBld_not, -1);} //Errors
else {strcpy(chatText, "Can't trade to yourself."); TethysGame::AddGameSound (sndBld_not, -1);}
targetPlayerFound = true;
break;
}
if (targetPlayerFound == false) {strcpy (chatText, "Player is no longer active."); TethysGame::AddGameSound (sndBld_not, -1);}
}
else {strcpy(chatText, "No such player."); TethysGame::AddGameSound (sndBld_not, -1);}
else {strcpy(chatText, "Must input a player &n&u&m&b&e&r."); TethysGame::AddGameSound (sndBld_not, -1);}
}
else errored = true; //Worst error possible
}
else if (strncmp (chatText, "/pay jail", 9) == false)
if (PlayerOrder[playerTurn].IsPlayerNo == sourcePlayerNum)
if (Jail[sourcePlayerNum].Jailed == true)
{
for (i = 0; i < 3; i++)
if (GOOJF[i] == sourcePlayerNum)
{
GOOJF[i] = -1;
Jail[sourcePlayerNum].Jailed = false;
strcpy (chatText, "Released from jail with a GOoJF.");
TethysGame::AddGameSound (sndSavnt277, -1);
break;
}
else {strcpy (chatText, "You don't own a GOoJF."); TethysGame::AddGameSound (sndBld_not, -1);}
if (Player[sourcePlayerNum].Ore() >= 50 && Jail[sourcePlayerNum].Jailed == true)
{
Player[sourcePlayerNum].SetOre(Player[sourcePlayerNum].Ore()-50);
Jail[sourcePlayerNum].Jailed = false;
strcpy (chatText, "Released from jail on bail of 50.");
TethysGame::AddGameSound (sndSavnt277, -1);
}
}
else {strcpy(chatText, "Not Jailed."); TethysGame::AddGameSound (sndBld_not, -1);}
else {strcpy(chatText, "Not your turn."); TethysGame::AddGameSound (sndBld_not, -1);}
else if (strncmp (chatText, "/kick", 5) == false)
if (sourcePlayerNum == 0)
{
//Skip the /kick tag
wordLength = strcspn(chatText, " .,?!");
strncpy(argument1, chatText, wordLength);
strcpy (chatText, chatText + wordLength + 1);
//Store the target player, who will be kicked
wordLength = strcspn(chatText, " .,?!");
strncpy(argument1, chatText, wordLength);
if (atoi(argument1) > 0 && atoi(argument1) <= TethysGame::NoPlayers())
if (atoi(argument1) != sourcePlayerNum + 1)
{
RemovePlayer (atoi(argument1) - 1);
if (leavingPlayerFound == true)
{
strcpy (chatText, "Player ");
char dumpstring[8] = "";
strcat (chatText, argument1); strcat (chatText, " has been kicked from the game.");
}
else {strcpy(chatText, "Already left the game."); TethysGame::AddGameSound (sndBld_not, -1);}
}
else {strcpy(chatText, "Can't kick yourself."); TethysGame::AddGameSound (sndBld_not, -1);}
else {strcpy(chatText, "No such player."); TethysGame::AddGameSound (sndBld_not, -1);}
}
else {strcpy(chatText, "Only the host can kick."); TethysGame::AddGameSound (sndBld_not, -1);}
else if (strncmp (chatText, "/quit", 5) == false)
{
RemovePlayer (sourcePlayerNum);
if (leavingPlayerFound == true)
{
strcpy (chatText, "Player ");
char dumpstring[8] = "";
strcat (chatText, itoa(sourcePlayerNum + 1, dumpstring, 10)); strcat (chatText, " has quit the game.");
}
else {strcpy(chatText, "Already left the game."); TethysGame::AddGameSound (sndBld_not, -1);}
}
else if (strncmp (chatText, "/start", 6) == false)
{
//Skip the /start tag
wordLength = strcspn(chatText, " .,?!");
strncpy(argument1, chatText, wordLength);
strcpy (chatText, chatText + wordLength + 1);
//Store the multiplier
wordLength = strcspn(chatText, " .,?!");
strncpy(argument1, chatText, wordLength);
if (sourcePlayerNum == 0)
if (isdigit(argument1[0]) != false)
if (boolMustInsert == true)
{
for (i = 0; i < noActivePlayers; i++)
Player[i].SetOre(Player[i].Ore() * atoi(argument1) / 10);
strcpy(chatText, "Starting ore altered by host.");
}
else {strcpy(chatText, "Can no longer alter starting money."); TethysGame::AddGameSound (sndBld_not, -1);}
else {strcpy(chatText, "Must input a &n&u&m&b&e&r."); TethysGame::AddGameSound (sndBld_not, -1);}
else {strcpy(chatText, "Only host can alter starting money."); TethysGame::AddGameSound (sndBld_not, -1);}
}
if (errored == true) {strcpy(chatText, "Unrecognized trade command."); TethysGame::AddGameSound (sndBld_not, -1);}//Send the worst error psossible
}