Sir R. M8gic1an
2010-03-14 07:19:17
Okay, I was going through the include today, particularly the mainloop, and there was something that just screamed FUNCTIONS at me. :)
Do not replace directly the fail walks. Notice this part is not included in the new procedure:
Players[CurrentPlayer].Integers[P_LOC] := LOC_LOST;
Today's Lesson: Whenever code is repeated, make a function for it.
~RM
MSI_Debug('MSI_MainLoop', 'Failed to bank materials!', Debug_PlayerActions);
Players[CurrentPlayer].Active := False;
ProgressReport;
MSI_Debug('MSI_MainLoop', 'Failed to walk to bank!', Debug_PlayerActions);
Players[CurrentPlayer].Active := False;
ProgressReportArray[CurrentPlayer].FalseReason := 'Failed to walk to bank';
Players[CurrentPlayer].Integers[P_LOC] := LOC_LOST;
ProgressReport;
MSI_Debug('MSI_MainLoop', 'Failed to perform skill!', Debug_PlayerActions);
Players[CurrentPlayer].Active := False;
ProgressReportArray[CurrentPlayer].FalseReason := 'Failed to perform skill: ' + IntToStr(CurrentSkill);
ProgressReport;
Procedure UnsetPlayer(func, reason: string);
begin
MSI_Debug(func, reason, Debug_PlayerActions);
Players[CurrentPlayer].Active := False;
ProgressReportArray[CurrentPlayer].FalseReason := reason;
ProgressReport;
LogOut;
end;
Do not replace directly the fail walks. Notice this part is not included in the new procedure:
Players[CurrentPlayer].Integers[P_LOC] := LOC_LOST;
Today's Lesson: Whenever code is repeated, make a function for it.
~RM