Skip to content

Commit

Permalink
Fixed outputting of death events - printing score overwrites prior me…
Browse files Browse the repository at this point in the history
…ssages e.g. ADV08 player killed by stone (unlock door)
  • Loading branch information
TheTextAdventurer committed Jun 3, 2018
1 parent 4756ae3 commit 482bd18
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions Adventurer/Advent - Game.cs
Original file line number Diff line number Diff line change
Expand Up @@ -763,11 +763,11 @@ private static void PerformActionComponent(int pAct, int pArg1, int pArg2)
SetGameOutput(string.Format(
_Sysmessages[13]
, storedItems
, Math.Floor((storedItems * 1.0 / _GameData.Header.TotalTreasures) * 100)), true);
, Math.Floor((storedItems * 1.0 / _GameData.Header.TotalTreasures) * 100)), false);

if (storedItems == _GameData.Header.TotalTreasures)
{
SetGameOutput(_Sysmessages[26], false);
SetGameOutput(_Sysmessages[26], true);
PerformActionComponent(63, 0, 0);
}

Expand Down
23 changes: 12 additions & 11 deletions Adventurer/GameData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,28 +120,28 @@ public static GameData LoadSnapShot(string pAdvGame, string pSnapShot)
Datafile.Load(pSnapShot);
Datafile.getTokens(1);//skip the first line.

int[] header = Datafile.GetTokensAsInt(5);
int[] header = Datafile.GetTokensAsInt(4);

//header[0] = changed items - multiply number by two as they are in pairs of index id and new location
//header[1] = input history
//header[2] = bitflags - pairs index, value
//header[3] = counters - pairs index, value
//header[4] = saved rooms - pairs index, value
//header[1] = bitflags - pairs index, value
//header[2] = counters - pairs index, value
//header[3] = saved rooms - pairs index, value

//get header
int[] intarray = Datafile.GetTokensAsInt(header[0] * 2);
for (int i = 0; i < intarray.Length; i += 2)
gd.Items[intarray[i]].Location = intarray[i + 1];

intarray = Datafile.GetTokensAsInt(header[2] * 2);
//bit glags
intarray = Datafile.GetTokensAsInt(header[1] * 2);
for (int i = 0; i < intarray.Length; i += 2)
gd.BitFlags[intarray[i]] = intarray[i + 1] == 1;

intarray = Datafile.GetTokensAsInt(header[3] * 2);
intarray = Datafile.GetTokensAsInt(header[2] * 2);
for (int i = 0; i < intarray.Length; i += 2)
gd.Counters[intarray[i]] = intarray[i + 1];

intarray = Datafile.GetTokensAsInt(header[4] * 2);
intarray = Datafile.GetTokensAsInt(header[3] * 2);
for (int i = 0; i < intarray.Length; i += 2)
gd.SavedRooms[intarray[i]] = intarray[i + 1];

Expand Down Expand Up @@ -743,6 +743,7 @@ public void SaveAsFormattedXML()
static int[] twoArgActions = { 62, 72, 75 };
static int[] oneActionArgs = { 52, 53, 54, 55, 58, 59, 60, 74, 78, 81, 82, 83, 79 };


static int[] actionArgsWithOneItem = { 52, 53, 55, 59, 74, 62 }; //note 62, a two arg action which moves item arg1 to room arg2
static int[] actionsWithTwoItems = { 72, 65 };

Expand Down Expand Up @@ -792,10 +793,10 @@ private XElement MakeAction(Action pAction, int pIndex, bool pIsChild)
? String.Format("A Output message: {0}", replaceChars(Messages[act[0]-50], new char[] {'\r','\n' })) //output message
//vvv Output a string based on the number of args the action has
: oneActionArgs.Contains(act[0])
? string.Format("A {0}: {1}", actions[act[0] - 52], act[1])
? string.Format("{0}: {1}", actions[act[0] - 52], act[1])
: twoArgActions.Contains(act[0])
? string.Format("A {0}: {1} {2}", actions[act[0] - 52], act[1], act[2])
: string.Format("A {0}", actions[act[0] - 52])
? string.Format("{0}: {1} {2}", actions[act[0] - 52], act[1], act[2])
: string.Format("{0}", actions[act[0] - 52])



Expand Down
3 changes: 1 addition & 2 deletions Adventurer/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,7 @@ static void Main(string[] args)
}
else
{
Console.WriteLine("ERROR: Must specify game to load with -g");
OutputHelp();
Console.WriteLine("ERROR: When using -l must specify game to load with -g");
return;
}

Expand Down

0 comments on commit 482bd18

Please sign in to comment.