PageRenderTime 36ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/622/Final/Almonaster/HtmlRenderer/HtmlRenderer.h

http://almonaster.codeplex.com
C++ Header | 1459 lines | 1151 code | 263 blank | 45 comment | 28 complexity | 37a61e66fe6672739622dd7e05a413de MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.0

Large files files are truncated, but you can click here to view the full file

  1. //
  2. // GameEngine.dll: a component of Almonaster
  3. // Copyright (c) 1998 Max Attar Feingold (maf6@cornell.edu)
  4. //
  5. // This program is free software; you can redistribute it and/or
  6. // modify it under the terms of the GNU General Public License
  7. // as published by the Free Software Foundation; either version 2
  8. // of the License, or (at your option) any later version.
  9. // This program is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU General Public License
  15. // along with this program; if not, write to the Free Software
  16. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  17. #ifndef _HtmlRenderer_H_
  18. #define _HtmlRenderer_H_
  19. #include "Alajar.h"
  20. #include "../Almonaster.h"
  21. #include "../GameEngine/GameEngine.h"
  22. #include "../Chatroom/CChatroom.h"
  23. #include "Osal/String.h"
  24. #include "Osal/Time.h"
  25. #define OutputText(string) m_pHttpResponse->WriteText (string, sizeof(string) - 1);
  26. struct PartialMapInfo {
  27. unsigned int iCenterKey;
  28. unsigned int iXRadius;
  29. unsigned int iYRadius;
  30. bool bDontShowPartialOptions;
  31. };
  32. struct ShipsInMapScreen {
  33. unsigned int iPlanetKey;
  34. unsigned int iCurrentShip;
  35. unsigned int iCurrentFleet;
  36. };
  37. struct AlmonasterStatistics {
  38. // Empires and games
  39. unsigned int Logins;
  40. unsigned int EmpiresCreated;
  41. unsigned int EmpiresDeleted;
  42. unsigned int GamesStarted;
  43. unsigned int GamesEnded;
  44. // Server data
  45. unsigned int NumPageScriptRenders;
  46. unsigned int TotalScriptTime;
  47. };
  48. // Mini-maps
  49. enum IconIndicator {
  50. ICON_NONE,
  51. ICON_INDEPENDENT,
  52. ICON_LIVEPLANET,
  53. ICON_DEADPLANET,
  54. ICON_EMPIREPLANET,
  55. };
  56. struct MiniMapEntry {
  57. IconIndicator iiIcon;
  58. unsigned int iOwnerKey;
  59. unsigned int iAlienKey;
  60. unsigned int iPlanetKey;
  61. unsigned int iPlanetProxyKey;
  62. int iX;
  63. int iY;
  64. };
  65. // Page id's
  66. enum PageId {
  67. MIN_PAGE_ID = 0,
  68. ACTIVE_GAME_LIST = 1,
  69. LOGIN = 2,
  70. NEW_EMPIRE = 3,
  71. OPEN_GAME_LIST = 4,
  72. SYSTEM_GAME_LIST = 5,
  73. PROFILE_EDITOR = 6,
  74. TOP_LISTS = 7,
  75. PROFILE_VIEWER = 8,
  76. SERVER_ADMINISTRATOR = 9,
  77. EMPIRE_ADMINISTRATOR = 10,
  78. GAME_ADMINISTRATOR = 11,
  79. THEME_ADMINISTRATOR = 12,
  80. PERSONAL_GAME_CLASSES = 13,
  81. CHATROOM = 14,
  82. SYSTEM_SERVER_INFORMATION = 15,
  83. SYSTEM_DOCUMENTATION = 16,
  84. SYSTEM_NEWS = 17,
  85. INFO = 18,
  86. TECH = 19,
  87. DIPLOMACY = 20,
  88. MAP = 21,
  89. PLANETS = 22,
  90. OPTIONS = 23,
  91. BUILD = 24,
  92. SHIPS = 25,
  93. GAME_SERVER_INFORMATION = 26,
  94. GAME_DOCUMENTATION = 27,
  95. GAME_NEWS = 28,
  96. GAME_PROFILE_VIEWER = 29,
  97. GAME_CONTRIBUTIONS = 30,
  98. GAME_CREDITS = 31,
  99. GAME_TERMS_OF_SERVICE = 32,
  100. QUIT = 33,
  101. LATEST_NUKES = 34,
  102. SPECTATOR_GAMES = 35,
  103. SYSTEM_CONTRIBUTIONS = 36,
  104. SYSTEM_CREDITS = 37,
  105. LATEST_GAMES = 38,
  106. TOURNAMENT_ADMINISTRATOR = 39,
  107. PERSONAL_TOURNAMENTS = 40,
  108. TOURNAMENTS = 41,
  109. SYSTEM_TERMS_OF_SERVICE = 42,
  110. MAX_PAGE_ID = 43,
  111. };
  112. #define FIRST_GAME_PAGE INFO
  113. #define EMPIRE_NAME_HASH_LIMIT (0x00ffffff)
  114. #define MAX_HTML_TIME_LENGTH 512
  115. #define FIRST_VALID_PASSWORD_CHAR ('#')
  116. #define LAST_VALID_PASSWORD_CHAR ('~')
  117. #define FIRST_VALID_EMPIRE_NAME_CHAR (' ')
  118. #define LAST_VALID_EMPIRE_NAME_CHAR ('~')
  119. #define FIRST_VALID_SHIP_OR_FLEET_NAME_CHAR (' ')
  120. #define LAST_VALID_SHIP_OR_FLEET_CHAR ('~')
  121. #define FIRST_VALID_CATEGORY_NAME_CHAR (' ')
  122. #define LAST_VALID_CATEGORY_NAME_CHAR ('~')
  123. #define FIRST_VALID_SERVER_NAME_CHAR (' ')
  124. #define LAST_VALID_SERVER_NAME_CHAR ('~')
  125. #define INVALID_PASSWORD_STRING "!!!!!!!!!!"
  126. #define MAX_SPECIFIC_EMPIRE_BLOCKS 25
  127. #define UNSTARTED_GAMEPAGE_REFRESH_SEC (120)
  128. enum ButtonId {
  129. BID_FIRST,
  130. BID_ACTIVEGAMELIST,
  131. BID_ADMINISTERGAME,
  132. BID_ADVANCEDSEARCH,
  133. BID_ALL,
  134. BID_ALMONASTERSCORE,
  135. BID_ATTACK,
  136. BID_BACKUP,
  137. BID_BLANKEMPIRESTATISTICS,
  138. BID_BUILD,
  139. BID_CANCEL,
  140. BID_CANCELALLBUILDS,
  141. BID_CHANGEEMPIRESPASSWORD,
  142. BID_CHANGEPASSWORD,
  143. BID_CHATROOM,
  144. BID_CHOOSE,
  145. BID_CLASSICSCORE,
  146. BID_CLOAKER,
  147. BID_COLONY,
  148. BID_CREATEALIENICON,
  149. BID_CREATEEMPIRE,
  150. BID_CREATENEWGAMECLASS,
  151. BID_CREATENEWSUPERCLASS,
  152. BID_CREATENEWTHEME,
  153. BID_DELETEALIENICON,
  154. BID_DELETEBACKUP,
  155. BID_DELETEEMPIRE,
  156. BID_DELETEGAMECLASS,
  157. BID_DELETESUPERCLASS,
  158. BID_DELETETHEME,
  159. BID_DIPLOMACY,
  160. BID_DOOMSDAY,
  161. BID_EMPIRE,
  162. BID_EMPIREADMINISTRATOR,
  163. BID_ENDTURN,
  164. BID_ENGINEER,
  165. BID_ENTER,
  166. BID_EXIT,
  167. BID_DOCUMENTATION,
  168. BID_FLUSH,
  169. BID_FORCEUPDATE,
  170. BID_GAMEADMINISTRATOR,
  171. BID_HALTGAMECLASS,
  172. BID_INFO,
  173. BID_KILLGAME,
  174. BID_LEAVETHECHATROOM,
  175. BID_LOGIN,
  176. BID_MAP,
  177. BID_MINEFIELD,
  178. BID_MINESWEEPER,
  179. BID_OBLITERATEEMPIRE,
  180. BID_OPENGAMELIST,
  181. BID_OPTIONS,
  182. BID_PAUSEALLGAMES,
  183. BID_PAUSEGAME,
  184. BID_PERSONALGAMECLASSES,
  185. BID_PLANETS,
  186. BID_PROFILEEDITOR,
  187. BID_PROFILEVIEWER,
  188. BID_PURGE,
  189. BID_QUIT,
  190. BID_REFRESHMESSAGES,
  191. BID_RESTARTALMONASTER,
  192. BID_RESTARTSERVER,
  193. BID_RESTOREBACKUP,
  194. BID_RESTOREEMPIRE,
  195. BID_SATELLITE,
  196. BID_SCIENCE,
  197. BID_SEARCH,
  198. BID_SELECTION,
  199. BID_SENDMESSAGE,
  200. BID_SERVERADMINISTRATOR,
  201. BID_SERVERNEWS,
  202. BID_SERVERINFORMATION,
  203. BID_SHIPS,
  204. BID_SHUTDOWNSERVER,
  205. BID_SPEAK,
  206. BID_STARGATE,
  207. BID_START,
  208. BID_SYSTEM,
  209. BID_SYSTEMGAMELIST,
  210. BID_TECH,
  211. BID_TERRAFORMER,
  212. BID_THEMEADMINISTRATOR,
  213. BID_TOPLISTS,
  214. BID_TROOPSHIP,
  215. BID_UNDELETEEMPIRE,
  216. BID_UNDELETEGAMECLASS,
  217. BID_UNENDTURN,
  218. BID_UNHALTGAMECLASS,
  219. BID_UNPAUSEALLGAMES,
  220. BID_UNPAUSEGAME,
  221. BID_VIEWEMPIRESGAMECLASSES,
  222. BID_VIEWEMPIRESNUKEHISTORY,
  223. BID_VIEWGAMEINFORMATION,
  224. BID_VIEWMAP,
  225. BID_VIEWMESSAGES,
  226. BID_VIEWPROFILE,
  227. BID_SEARCHIPADDRESSES,
  228. BID_SEARCHSESSIONIDS,
  229. BID_VIEWEMPIREINFORMATION,
  230. BID_RESIGN,
  231. BID_STARTCUSTOMGAME,
  232. BID_RENAMESUPERCLASS,
  233. BID_CLEARMESSAGES,
  234. BID_SURRENDER,
  235. BID_CARRIER,
  236. BID_BUILDER,
  237. BID_MORPHER,
  238. BID_JUMPGATE,
  239. BID_LATESTNUKES,
  240. BID_BRIDIERSCORE,
  241. BID_BRIDIERSCOREESTABLISHED,
  242. BID_SPECTATORGAMES,
  243. BID_BLOCK,
  244. BID_RESET,
  245. BID_CONTRIBUTIONS,
  246. BID_CREDITS,
  247. BID_LATESTGAMES,
  248. BID_TOURNAMENTADMINISTRATOR,
  249. BID_PERSONALTOURNAMENTS,
  250. BID_CREATENEWTOURNAMENT,
  251. BID_DELETETOURNAMENT,
  252. BID_ADMINISTERTOURNAMENT,
  253. BID_INVITEEMPIRE,
  254. BID_CREATETEAM,
  255. BID_VIEWTOURNAMENTINFORMATION,
  256. BID_DECLINE,
  257. BID_ACCEPT,
  258. BID_ADMINISTERTEAM,
  259. BID_DELETETEAM,
  260. BID_ADDEMPIRE,
  261. BID_UPDATE,
  262. BID_CHOOSEICON,
  263. BID_CHOOSETHEME,
  264. BID_TOURNAMENTS,
  265. BID_JOIN,
  266. BID_VIEWEMPIRESTOURNAMENTS,
  267. BID_REBUILD,
  268. BID_LOOKUP,
  269. BID_VIEWMINIMAP,
  270. BID_MINIBUILD,
  271. BID_PLUS,
  272. BID_MINUS,
  273. BID_TOS,
  274. BID_TOS_ACCEPT,
  275. BID_TOS_DECLINE,
  276. BID_ADD_ASSOCIATION,
  277. BID_REMOVE_ASSOCIATION,
  278. BID_LAST,
  279. };
  280. extern const char* ButtonText[];
  281. extern const char* ButtonName[];
  282. extern const char* ButtonImageName[];
  283. extern const char* ButtonFileName[];
  284. extern const ButtonId PageButtonId[];
  285. extern const char* PageName[];
  286. enum SearchFieldType {
  287. SEARCHFIELD_INTEGER,
  288. SEARCHFIELD_INTEGER64,
  289. SEARCHFIELD_FLOAT,
  290. SEARCHFIELD_DATE,
  291. SEARCHFIELD_STRING,
  292. SEARCHFIELD_PRIVILEGE,
  293. SEARCHFIELD_AGE,
  294. SEARCHFIELD_GENDER,
  295. };
  296. struct SearchField {
  297. bool bCheckedByDefault;
  298. const char* pszName;
  299. const char* pszInputCheckBox;
  300. const char* pszInput1;
  301. const char* pszInput2;
  302. unsigned int iSystemEmpireDataColumn;
  303. SearchFieldType sftType;
  304. Privilege prvMinPriv;
  305. };
  306. extern const SearchField g_AdvancedSearchFields[];
  307. #define MAX_NUM_SEARCH_COLUMNS 31
  308. //
  309. // Globals
  310. //
  311. class HtmlRenderer {
  312. protected:
  313. // Data
  314. PageId m_pgPageId;
  315. IHttpRequest* m_pHttpRequest;
  316. IHttpResponse* m_pHttpResponse;
  317. Variant m_vEmpireName;
  318. Variant m_vPassword;
  319. Variant m_vPreviousIPAddress;
  320. int64 m_i64SecretKey;
  321. UTCTime m_tOldSalt;
  322. UTCTime m_tNewSalt;
  323. String m_strMessage;
  324. unsigned int m_iEmpireKey;
  325. unsigned int m_iGameClass;
  326. int m_iGameNumber;
  327. unsigned int m_iButtonKey;
  328. unsigned int m_iBackgroundKey;
  329. unsigned int m_iSeparatorKey;
  330. int m_iPrivilege;
  331. unsigned int m_iAlienKey;
  332. unsigned int m_iThemeKey;
  333. int m_iGameState;
  334. int m_iGameRatios;
  335. int m_iReserved;
  336. int m_iSystemOptions;
  337. int m_iSystemOptions2;
  338. int m_iGameOptions;
  339. int m_iDefaultSystemIcon;
  340. Variant m_vTableColor;
  341. Variant m_vTextColor;
  342. Variant m_vGoodColor;
  343. Variant m_vBadColor;
  344. Variant m_vPrivateMessageColor;
  345. Variant m_vBroadcastMessageColor;
  346. Variant m_vLocalPath;
  347. char m_pszGameClassName [MAX_FULL_GAME_CLASS_NAME_LENGTH];
  348. bool m_bRedirection;
  349. bool m_bRepeatedButtons;
  350. bool m_bTimeDisplay;
  351. bool m_bNotifiedProfileLink;
  352. bool m_bNotifiedTournamentInvitation;
  353. bool m_bNotifiedTournamentJoinRequest;
  354. bool m_bOwnPost;
  355. bool m_bLoggedIntoGame;
  356. bool m_bAuthenticated;
  357. bool m_bAutoLogon;
  358. Timer m_tmTimer;
  359. Seconds m_sSecondsUntil;
  360. Seconds m_sSecondsSince;
  361. int64 m_i64SessionId;
  362. // Submission control
  363. int m_iNumOldUpdates;
  364. int m_iNumNewUpdates;
  365. // Lock control
  366. GameEmpireLock* m_pgeLock;
  367. // Methods
  368. void WriteGameListHeader (const char** ppszHeaders, size_t stNumHeaders, const char* pszTableColor);
  369. void AddEmpiresInGame (int iGameState, int iNumActiveEmpires, const char* pszEmpires, int iMinEmpires, int iMaxEmpires);
  370. int AddGameClassDescription (int iWhichList, const Variant* pvGameClassInfo,
  371. int iGameClass, int iGameNumber, int iGameState, const char* pszEmpiresInGame,
  372. int iNumEmpiresInGame, bool bAdmin, bool bSpectators);
  373. int WriteInPlayGameListData (int iGameClass, int iGameNumber, const Variant* pvGameClassInfo,
  374. bool bAdmin, bool bSpectator);
  375. void AddOptions (int iWhichList, const Variant* pvGameClassInfo, int iGameOptions);
  376. void AddResources (const Variant* pvGameClassInfo);
  377. void AddDiplomacy (const Variant* pvGameClassInfo);
  378. void AddTechList (int iTechs, int iInitial);
  379. void AddBridier (int iGameClass, int iGameNumber, const Variant* pvGameClassInfo,
  380. int iGameOptions, const Variant* pvMin, const Variant* pvMax, bool bDisplayGainLoss);
  381. void AddBridierGame (int iGameClass, int iGameNumber, const Variant* pvGameClassInfo, int iGameOptions,
  382. bool bDisplayGainLoss);
  383. void AddScore (int iGameOptions, const Variant* pvMin, const Variant* pvMax);
  384. void AddSecurity (int iGameOptions);
  385. int PostGamePageInformation();
  386. void WriteGameButtons();
  387. void WriteGameNextUpdateString();
  388. int WriteTextFile (bool bTextArea, const char* pszFile, const char* pszFileForm, const char* pszFileHashForm);
  389. int TryUpdateFile (const char* pszFile, const char* pszFileForm, const char* pszFileHashForm);
  390. int UpdateCachedFile (const char* pszFileName, const char* pszText);
  391. void RenderSearchField (const SearchField& sfField, bool fAdvanced);
  392. void RenderDateField (const char* pszField);
  393. bool ParseDateField (const char* pszField, UTCTime* ptTime);
  394. void RenderHiddenSearchVariant (unsigned int iColumn, const char* pszColName, const Variant& vData);
  395. static bool ms_bLocksInitialized;
  396. static ReadWriteLock ms_mTextFileLock;
  397. public:
  398. // Statics
  399. static AlmonasterStatistics m_sStats;
  400. static UTCTime m_stEmpiresInGamesCheck;
  401. static UTCTime m_stServerNewsLastUpdate;
  402. static Mutex m_slockEmpiresInGames;
  403. static unsigned int m_siNumGamingEmpires;
  404. // Constructor
  405. HtmlRenderer (PageId pageId, IHttpRequest* pHttpRequest, IHttpResponse* pHttpResponse);
  406. ~HtmlRenderer();
  407. static int Initialize();
  408. int Render();
  409. int Redirect (PageId pageId);
  410. void ShutdownServer();
  411. void RestartServer();
  412. void RestartAlmonaster();
  413. bool IsGamePage (PageId pageId);
  414. static int OnCreateEmpire (int iEmpireKey);
  415. static int OnDeleteEmpire (int iEmpireKey);
  416. static int OnLoginEmpire (int iEmpireKey);
  417. static int OnCreateGame (int iGameClass, int iGameNumber);
  418. static int OnCleanupGame (int iGameClass, int iGameNumber);
  419. static int OnDeleteTournament (unsigned int iTournamentKey);
  420. static int OnDeleteTournamentTeam (unsigned int iTournamentKey, unsigned int iTeamKey);
  421. static int OnPageRender (MilliSeconds msTime);
  422. static void ZeroStatistics();
  423. void WriteFormattedMessage (const char* pszText);
  424. int GetUIData (int iThemeKey);
  425. int GetTextColorData (int iEmpireColorKey);
  426. bool IsColor (const char* pszNewValue);
  427. void WriteBackgroundImageSrc (int iThemeKey);
  428. void WriteLivePlanetImageSrc (int iThemeKey);
  429. void WriteDeadPlanetImageSrc (int iThemeKey);
  430. void WriteSeparatorSrc (int iThemeKey);
  431. void WriteHorzSrc (int iThemeKey);
  432. void WriteVertSrc (int iThemeKey);
  433. int GetHorzString (int iThemeKey, String* pstrString, bool bBlowup = true);
  434. int GetVertString (int iThemeKey, String* pstrString, bool bBlowup = true);
  435. void WriteButtonImageSrc (int iRealThemeKey, const char* pszButtonName);
  436. void WriteThemeDownloadSrc (int iRealThemeKey, const char* pszFileName);
  437. int StandardizeEmpireName (const char* pszName, char pszFinalName[MAX_EMPIRE_NAME_LENGTH + 1]);
  438. int VerifyPassword (const char* pszPassword, bool bPrintErrors = true);
  439. int VerifyEmpireName (const char* pszEmpireName, bool bPrintErrors = true);
  440. int VerifyCategoryName (const char* pszCategory, const char* pszName, size_t stMaxLen, bool bPrintErrors);
  441. bool ShipOrFleetNameFilter (const char* pszName);
  442. void WriteVersionString();
  443. void WriteAlmonasterBanner();
  444. void WriteContactLine();
  445. void WriteBodyString (Seconds iSecondsUntil);
  446. void WriteSeparatorString (int iSeparatorKey);
  447. void WriteButtonString (int iButtonKey, const char* pszButtonFileName, const char* pszButtonText,
  448. const char* pszButtonName);
  449. int GetButtonName (const char* pszFormName, int iButtonKey, String* pstrButtonName);
  450. void OpenForm();
  451. void SendWelcomeMessage (const char* pszEmpireName);
  452. // Password hashing
  453. int GetPasswordHashForAutologon (int64* pi64Hash);
  454. int GetPasswordHashForGamePage (const UTCTime& tSalt, int64* pi64Hash);
  455. int GetPasswordHashForSystemPage (const UTCTime& tSalt, int64* pi64Hash);
  456. void HashIPAddress (const char* pszIPAddress, char* pszHashedIPAddress);
  457. bool RedirectOnSubmit (PageId* ppageRedirect);
  458. void WriteTime (Seconds sNumSeconds);
  459. int ConvertTime (Seconds sNumSeconds, char pszTime[MAX_HTML_TIME_LENGTH]);
  460. void WriteEmpireIcon (int iIconKey, int iEmpireKey, const char* pszAlt, bool bVerifyUpload);
  461. void WriteTournamentIcon (int iIconKey, int iTournamentKey, const char* pszAlt, bool bVerifyUpload);
  462. void WriteTournamentTeamIcon (int iIconKey, int iTournamentKey, int iTournamentTeamKey, const char* pszAlt, bool bVerifyUpload);
  463. void WriteIcon (int iIconKey, int iEntityKey, int iEntityKey2, const char* pszAlt, const char* pszUploadDir, bool bVerifyUpload);
  464. void WriteProfileAlienString (int iAlienKey, int iEmpireKey, const char* pszEmpireName, int iBorder,
  465. const char* pszFormName, const char* pszAlt, bool bVerifyUpload, bool bKeyAndHash);
  466. void NotifyProfileLink();
  467. bool NotifiedProfileLink();
  468. void NotifyTournamentInvitation (int iMessageKey, int iTournamentKey);
  469. bool NotifiedTournamentInvitation();
  470. void NotifyTournamentJoinRequest (int iMessageKey, int iTournamentKey);
  471. bool NotifiedTournamentJoinRequest();
  472. unsigned int GetEmpireNameHashValue (const char* pszEmpireName);
  473. int HTMLFilter (const char* pszSource, String* pstrFiltered, size_t stNumChars, bool bAddMarkups);
  474. bool VerifyGIF (const char* pszFileName);
  475. int CopyUploadedIcon (const char* pszFileName, const char* pszUploadDir, int iKey1, int iKey2);
  476. int CopyNewAlien (const char* pszFileName, int iAlienKey);
  477. int DeleteAlien (int iAlienKey);
  478. void ReportLoginFailure (IReport* pReport, const char* pszEmpireName);
  479. void ReportLoginSuccess (IReport* pReport, const char* pszEmpireName, bool bAutoLogon);
  480. void ReportEmpireCreation (IReport* pReport, const char* pszEmpireName);
  481. void WriteSystemTitleString();
  482. void WriteSystemHeaders (bool bFileUpload);
  483. void WriteSystemButtons(int iButtonKey, int iPrivilege);
  484. void WriteSystemMessages();
  485. bool RenderSystemMessage (int iMessageKey, const Variant* pvMessage);
  486. void WriteBackupMessage();
  487. int InitializeEmpire (bool bAutoLogon);
  488. int InitializeSessionId (bool* pbUpdateSessionId, bool* pbUpdateCookie);
  489. void CloseSystemPage();
  490. int PostSystemPageInformation();
  491. void WriteActiveGameListHeader (const char* pszTableColor);
  492. void WriteOpenGameListHeader (const char* pszTableColor);
  493. void WriteSpectatorGameListHeader (const char* pszTableColor);
  494. void WriteSystemGameListHeader (const char* pszTableColor);
  495. void WriteGameAdministratorListHeader (const char* pszTableColor);
  496. int WriteActiveGameListData (int iGameClass, int iGameNumber, const Variant* pvGameClassInfo);
  497. int WriteOpenGameListData (int iGameClass, int iGameNumber, const Variant* pvGameClassInfo);
  498. int WriteSpectatorGameListData (int iGameClass, int iGameNumber, const Variant* pvGameClassInfo);
  499. int WriteGameAdministratorListData (int iGameClass, int iGameNumber, const Variant* pvGameClassInfo);
  500. int WriteSystemGameListData (int iGameClass, const Variant* pvGameClassInfo);
  501. void WriteCreateGameClassString (int iEmpireKey, unsigned int iTournamentKey, bool bPersonalGame);
  502. int ProcessCreateGameClassForms (unsigned int iOwnerKey, unsigned int iTournamentKey);
  503. int ProcessCreateDynamicGameClassForms (unsigned int iOwnerKey, int* piGameClass, int* piGameNumber,
  504. bool* pbGameCreated);
  505. int ParseCreateGameClassForms (Variant* pvSubmitArray, int iOwnerKey, unsigned int iTournamentKey, bool bDynamic);
  506. void WriteCreateTournament (int iEmpireKey);
  507. int ProcessCreateTournament (int iEmpireKey);
  508. int ParseCreateTournamentForms (Variant* pvSubmitArray, int iEmpireKey);
  509. void WriteCreateTournamentTeam (unsigned int iTournamentKey);
  510. int ProcessCreateTournamentTeam (unsigned int iTournamentKey);
  511. int ParseCreateTournamentTeamForms (Variant* pvSubmitArray, unsigned int iTournamentKey);
  512. void WriteTournamentAdministrator (int iEmpireKey);
  513. void WriteAdministerTournament (unsigned int iTournamentKey);
  514. void WriteAdministerTournamentTeam (unsigned int iTournamentKey, unsigned int iTeamKey);
  515. int StartTournamentGame(unsigned int iTournamentKey, int iTeamOptions, bool bAdvanced);
  516. void WriteProfile (unsigned int iEmpireKey, unsigned int iTargetEmpireKey, bool bEmpireAdmin, bool bSendMessage, bool bShowButtons);
  517. void WriteGameTitleString();
  518. int WriteGameHeaderString();
  519. bool RedirectOnSubmitGame (PageId* ppageRedirect);
  520. void CloseGamePage();
  521. int InitializeGame (PageId* ppageRedirect);
  522. void WriteGameMessages();
  523. int GetDefaultSystemIcon();
  524. void GetAlienPlanetButtonString (int iAlienKey, int iEmpireKey, bool bBorder, int iPlanetKey, int iProxyKey,
  525. const char* pszAlt, const char* pszExtraTag, String* pstrAlienButtonString);
  526. void WriteAlienButtonString (int iAlienKey, bool bBorder, const char* pszNamePrefix,
  527. const char* pszAuthorName);
  528. void GetLivePlanetButtonString (int iLivePlanetKey, int iPlanetKey, int iProxyKey, const char* pszAlt,
  529. const char* pszExtraTag, String* pstrLivePlanet);
  530. void GetDeadPlanetButtonString (int iDeadPlanetKey, int iPlanetKey, int iProxyKey, const char* pszAlt,
  531. const char* pszExtraTag, String* pstrDeadPlanet);
  532. void GetIndependentPlanetButtonString (int iPlanetKey, int iProxyKey, const char* pszAlt,
  533. const char* pszExtraTag, String* pstrPlanetString);
  534. void WriteLivePlanetString (int iLivePlanetKey);
  535. void WriteDeadPlanetString (int iDeadPlanetKey);
  536. void WriteIndependentPlanetString();
  537. int WriteUpClosePlanetString (unsigned int iEmpireKey, int iPlanetKey, int iProxyPlanetKey, int iLivePlanetKey,
  538. int iDeadPlanetKey, int iPlanetCounter, bool bVisibleBuilds, int iGoodAg, int iBadAg, int iGoodMin,
  539. int iBadMin, int iGoodFuel, int iBadFuel, float fEmpireAgRatio, bool bIndependence, bool bAdmin,
  540. bool bSpectator, const Variant* pvPlanetData, bool* pbOurPlanet);
  541. int WriteRatiosString (RatioInformation* pratInfo);
  542. int RenderUnsafeHyperText (const char* pszText, const char* pszUrl);
  543. int RenderHyperText (const char* pszText, const char* pszUrl);
  544. void WriteServerRules();
  545. void WriteFaq();
  546. void WriteServerNews();
  547. void WriteContributions();
  548. void WriteCredits();
  549. void WriteIntro();
  550. void WriteIntroUpper (bool bTextArea);
  551. void WriteIntroLower (bool bTextArea);
  552. void WriteServerNewsFile (bool bTextArea);
  553. void WriteContributorsFile (bool bTextArea);
  554. void WriteTOS();
  555. void WriteTOSFile();
  556. void WriteConfirmTOSDecline();
  557. int TryUpdateIntroUpper();
  558. int TryUpdateIntroLower();
  559. int TryUpdateServerNews();
  560. int TryUpdateContributors();
  561. int WriteShip (unsigned int iShipKey, const Variant* pvData, unsigned int iIndex, bool bFleet,
  562. const GameConfiguration& gcConfig, const ShipOrderPlanetInfo& planetInfo,
  563. const ShipOrderShipInfo& shipInfo, const ShipOrderGameInfo& gameInfo,
  564. const BuildLocation* pblLocations, unsigned int iNumLocations);
  565. int GetGoodBadResourceLimits (int iGameClass, int iGameNumber, int* piGoodAg, int* piBadAg, int* piGoodMin,
  566. int* piBadMin, int* piGoodFuel, int* piBadFuel);
  567. void WriteNukeHistory (int iTargetEmpireKey);
  568. void WritePersonalGameClasses (int iTargetEmpireKey);
  569. void WritePersonalTournaments (int iTargetEmpireKey);
  570. void WritePersonalTournaments();
  571. void WriteGameAdministratorGameData (const char* pszGameClassName,
  572. int iGameNumber, Seconds iSeconds, Seconds iSecondsUntil, int iNumUpdates, bool bOpen, bool bPaused,
  573. bool bAdminPaused, bool bStarted, const char* pszGamePassword, Variant* pvEmpireName,
  574. int iNumActiveEmpires, const UTCTime& tCreationTime, bool bAdmin);
  575. int PopulatePlanetInfo (unsigned int iGameClass, unsigned int iGameNumber, unsigned int iShipPlanet,
  576. ShipOrderPlanetInfo& planetInfo, String& strPlanetName);
  577. int RenderMap (int iGameClass, int iGameNumber, int iEmpireKey, bool bAdmin,
  578. const PartialMapInfo* pPartialMapInfo, bool bSpectators);
  579. void RenderMiniMap (unsigned int iGameClass, int iGameNumber, unsigned int iEmpireKey);
  580. void RenderMiniPlanet (const MiniMapEntry& mmEntry, unsigned int iEmpireKey, unsigned int iLivePlanetKey,
  581. unsigned int iDeadPlanetKey);
  582. int GetSensitiveMapText (int iGameClass, int iGameNumber, int iEmpireKey, int iPlanetKey,
  583. int iProxyPlanetKey, bool bVisibleBuilds, bool bIndependence, const Variant* pvPlanetData, String* pstrAltTag);
  584. int RenderThemeInfo (int iBackgroundKey, int iLivePlanetKey, int iDeadPlanetKey, int iSeparatorKey,
  585. int iButtonKey, int iHorzKey, int iVertKey, int iColorKey);
  586. int DisplayThemeData (int iThemeKey);
  587. void WriteStringByDiplomacy (const char* pszString,
  588. int iDiplomacy);
  589. void SearchForDuplicateIPAddresses (int iGameClass, int iGameNumber);
  590. void SearchForDuplicateSessionIds (int iGameClass, int iGameNumber);
  591. int LoginEmpire();
  592. void RenderShips (unsigned int iGameClass, int iGameNumber, unsigned int iEmpireKey,
  593. int iBR, float fMaintRatio, float fNextMaintRatio, ShipsInMapScreen* pShipsInMap, bool bShipString,
  594. unsigned int* piShips, unsigned int* piFleets);
  595. int HandleShipMenuSubmissions();
  596. bool VerifyEmpireNameHash (int iEmpireKey, unsigned int iHash);
  597. // Build
  598. void RenderMiniBuild (unsigned int iPlanetKey, bool bSingleBar);
  599. void HandleMiniBuild (unsigned int iPlanetKey);
  600. int CreateRandomFleet (unsigned int iPlanetKey, unsigned int* piFleetKey);
  601. void AddBuildNewShipsMessage (int iErrCode, int iNumShipsBuilt, int iBR, int iTechKey,
  602. const char* pszPlanetName, int iX, int iY, const char* pszFleetName, bool bBuildReduced);
  603. void AddCreateNewFleetMessage (int iErrCode, const char* pszFleetName);
  604. // New button system
  605. bool IsLegalButtonId (ButtonId bidButton);
  606. bool WasButtonPressed (ButtonId bidButton);
  607. void WriteButton (ButtonId bidButton);
  608. // Search interface
  609. int HandleSearchSubmission (
  610. SearchDefinition& sd,
  611. const char** pszFormName,
  612. const char** pszColName1,
  613. const char** pszColName2,
  614. unsigned int** ppiSearchEmpireKey,
  615. unsigned int* piNumSearchEmpires,
  616. unsigned int* piLastKey
  617. );
  618. void RenderSearchForms (bool fAdvanced);
  619. void RenderSearchResults (
  620. SearchDefinition& sd,
  621. const char** pszFormName,
  622. const char** pszColName1,
  623. const char** pszColName2,
  624. unsigned int* piSearchEmpireKey,
  625. unsigned int iNumSearchEmpires,
  626. unsigned int iLastKey
  627. );
  628. void RenderEmpireInformation (int iGameClass, int iGameNumber, bool bAdmin);
  629. // Game entry confirmation
  630. void RenderGameConfiguration (int iGameClass, unsigned int iTournamentKey);
  631. int ParseGameConfigurationForms (int iGameClass, unsigned int iTournamentKey,
  632. const Variant* pvGameClassInfo, GameOptions* pgoOptions);
  633. // GameOptions
  634. void InitGameOptions (GameOptions* pgoOptions);
  635. void ClearGameOptions (GameOptions* pgoOptions);
  636. // Icons
  637. void WriteIconSelection (int iIconSelect, int iIcon, const char* pszCategory);
  638. int HandleIconSelection (unsigned int* piIcon, const char* pszUploadDir, unsigned int iKey1, unsigned int iKey2);
  639. // Admin
  640. void WriteActiveGameAdministration (int* piGameClass, int* piGameNumber, unsigned int iNumActiveGames,
  641. unsigned int iNumOpenGames, unsigned int iNumClosedGames, bool bAdmin);
  642. void WriteAdministerGame (int iGameClass, int iGameNumber, bool bAdmin);
  643. // Tournaments
  644. void RenderTournaments (const unsigned int* piTournamentKey, unsigned int iTournaments, bool bSingleOwner);
  645. void RenderTournamentSimple (unsigned int iTournamentKey, bool bSingleOwner);
  646. void RenderTournamentDetailed (unsigned int iTournamentKey);
  647. void RenderEmpire (unsigned int iTournamentKey, int iEmpireKey);
  648. // Context stuff
  649. MilliSeconds GetTimerCount() {
  650. return Time::GetTimerCount (m_tmTimer);
  651. }
  652. void AddMessage (const char* pszMessage) {
  653. if (!m_strMessage.IsBlank()) {
  654. m_strMessage += "<br>";
  655. }
  656. m_strMessage += pszMessage;
  657. }
  658. void AddMessage (int iInt) {
  659. if (!m_strMessage.IsBlank()) {
  660. m_strMessage += "<br>";
  661. }
  662. m_strMessage += iInt;
  663. }
  664. void AddMessage (float fFloat) {
  665. if (!m_strMessage.IsBlank()) {
  666. m_strMessage += "<br>";
  667. }
  668. m_strMessage += fFloat;
  669. }
  670. void AppendMessage (const char* pszMessage) {
  671. m_strMessage += pszMessage;
  672. }
  673. void AppendMessage (int iInt) {
  674. m_strMessage += iInt;
  675. }
  676. void AppendMessage (unsigned int uiInt) {
  677. m_strMessage += uiInt;
  678. }
  679. void AppendMessage (float fFloat) {
  680. m_strMessage += fFloat;
  681. }
  682. int Render_TournamentManager (unsigned int iOwnerKey);
  683. // Rendering functions
  684. int Render_ActiveGameList();
  685. int Render_Login();
  686. int Render_NewEmpire();
  687. int Render_OpenGameList();
  688. int Render_SystemGameList();
  689. int Render_ProfileEditor();
  690. int Render_TopLists();
  691. int Render_ProfileViewer();
  692. int Render_ServerAdministrator();
  693. int Render_EmpireAdministrator();
  694. int Render_GameAdministrator();
  695. int Render_ThemeAdministrator();
  696. int Render_PersonalGameClasses();
  697. int Render_Chatroom();
  698. int Render_SystemServerRules();
  699. int Render_SystemFAQ();
  700. int Render_SystemNews();
  701. int Render_Info();
  702. int Render_Tech();
  703. int Render_Diplomacy();
  704. int Render_Map();
  705. int Render_Planets();
  706. int Render_Options();
  707. int Render_Build();
  708. int Render_Ships();
  709. int Render_GameServerRules();
  710. int Render_GameFAQ();
  711. int Render_GameNews();
  712. int Render_GameProfileViewer();
  713. int Render_Quit();
  714. int Render_LatestNukes();
  715. int Render_SpectatorGames();
  716. int Render_GameContributions();
  717. int Render_GameCredits();
  718. int Render_SystemContributions();
  719. int Render_SystemCredits();
  720. int Render_LatestGames();
  721. int Render_TournamentAdministrator();
  722. int Render_PersonalTournaments();
  723. int Render_Tournaments();
  724. int Render_GameTos();
  725. int Render_SystemTos();
  726. };
  727. // Function Pointers
  728. static inline int THREAD_CALL Fxn_ActiveGameList (void* pThis) {
  729. return ((HtmlRenderer*) pThis)->Render_ActiveGameList();
  730. }
  731. static inline int THREAD_CALL Fxn_Login (void* pThis) {
  732. return ((HtmlRenderer*) pThis)->Render_Login();
  733. }
  734. static inline int THREAD_CALL Fxn_NewEmpire (void* pThis) {
  735. return ((HtmlRenderer*) pThis)->Render_NewEmpire();
  736. }
  737. static inline int THREAD_CALL Fxn_OpenGameList (void* pThis) {
  738. return ((HtmlRenderer*) pThis)->Render_OpenGameList();
  739. }
  740. static inline int THREAD_CALL Fxn_SystemGameList (void* pThis) {
  741. return ((HtmlRenderer*) pThis)->Render_SystemGameList();
  742. }
  743. static inline int THREAD_CALL Fxn_ProfileEditor (void* pThis) {
  744. return ((HtmlRenderer*) pThis)->Render_ProfileEditor();
  745. }
  746. static inline int THREAD_CALL Fxn_TopLists (void* pThis) {
  747. return ((HtmlRenderer*) pThis)->Render_TopLists();
  748. }
  749. static inline int THREAD_CALL Fxn_ProfileViewer (void* pThis) {
  750. return ((HtmlRenderer*) pThis)->Render_ProfileViewer();
  751. }
  752. static inline int THREAD_CALL Fxn_ServerAdministrator (void* pThis) {
  753. return ((HtmlRenderer*) pThis)->Render_ServerAdministrator();
  754. }
  755. static inline int THREAD_CALL Fxn_EmpireAdministrator (void* pThis) {
  756. return ((HtmlRenderer*) pThis)->Render_EmpireAdministrator();
  757. }
  758. static inline int THREAD_CALL Fxn_GameAdministrator (void* pThis) {
  759. return ((HtmlRenderer*) pThis)->Render_GameAdministrator();
  760. }
  761. static inline int THREAD_CALL Fxn_ThemeAdministrator (void* pThis) {
  762. return ((HtmlRenderer*) pThis)->Render_ThemeAdministrator();
  763. }
  764. static inline int THREAD_CALL Fxn_PersonalGameClasses (void* pThis) {
  765. return ((HtmlRenderer*) pThis)->Render_PersonalGameClasses();
  766. }
  767. static inline int THREAD_CALL Fxn_Chatroom (void* pThis) {
  768. return ((HtmlRenderer*) pThis)->Render_Chatroom();
  769. }
  770. static inline int THREAD_CALL Fxn_SystemServerRules (void* pThis) {
  771. return ((HtmlRenderer*) pThis)->Render_SystemServerRules();
  772. }
  773. static inline int THREAD_CALL Fxn_SystemFAQ (void* pThis) {
  774. return ((HtmlRenderer*) pThis)->Render_SystemFAQ();
  775. }
  776. static inline int THREAD_CALL Fxn_SystemNews (void* pThis) {
  777. return ((HtmlRenderer*) pThis)->Render_SystemNews();
  778. }
  779. static inline int THREAD_CALL Fxn_Info (void* pThis) {
  780. return ((HtmlRenderer*) pThis)->Render_Info();
  781. }
  782. static inline int THREAD_CALL Fxn_Tech (void* pThis) {
  783. return ((HtmlRenderer*) pThis)->Render_Tech();
  784. }
  785. static inline int THREAD_CALL Fxn_Diplomacy (void* pThis) {
  786. return ((HtmlRenderer*) pThis)->Render_Diplomacy();
  787. }
  788. static inline int THREAD_CALL Fxn_Map (void* pThis) {
  789. return ((HtmlRenderer*) pThis)->Render_Map();
  790. }
  791. static inline int THREAD_CALL Fxn_Planets (void* pThis) {
  792. return ((HtmlRenderer*) pThis)->Render_Planets();
  793. }
  794. static inline int THREAD_CALL Fxn_Options (void* pThis) {
  795. return ((HtmlRenderer*) pThis)->Render_Options();
  796. }
  797. static inline int THREAD_CALL Fxn_Build (void* pThis) {
  798. return ((HtmlRenderer*) pThis)->Render_Build();
  799. }
  800. static inline int THREAD_CALL Fxn_Ships (void* pThis) {
  801. return ((HtmlRenderer*) pThis)->Render_Ships();
  802. }
  803. static inline int THREAD_CALL Fxn_GameServerRules (void* pThis) {
  804. return ((HtmlRenderer*) pThis)->Render_GameServerRules();
  805. }
  806. static inline int THREAD_CALL Fxn_GameFAQ (void* pThis) {
  807. return ((HtmlRenderer*) pThis)->Render_GameFAQ();
  808. }
  809. static inline int THREAD_CALL Fxn_GameNews (void* pThis) {
  810. return ((HtmlRenderer*) pThis)->Render_GameNews();
  811. }
  812. static inline int THREAD_CALL Fxn_GameProfileViewer (void* pThis) {
  813. return ((HtmlRenderer*) pThis)->Render_GameProfileViewer();
  814. }
  815. static inline int THREAD_CALL Fxn_Quit (void* pThis) {
  816. return ((HtmlRenderer*) pThis)->Render_Quit();
  817. }
  818. static inline int THREAD_CALL Fxn_LatestNukes (void* pThis) {
  819. return ((HtmlRenderer*) pThis)->Render_LatestNukes();
  820. }
  821. static inline int THREAD_CALL Fxn_SpectatorGames (void* pThis) {
  822. return ((HtmlRenderer*) pThis)->Render_SpectatorGames();
  823. }
  824. static inline int THREAD_CALL Fxn_GameContributions (void* pThis) {
  825. return ((HtmlRenderer*) pThis)->Render_GameContributions();
  826. }
  827. static inline int THREAD_CALL Fxn_GameCredits (void* pThis) {
  828. return ((HtmlRenderer*) pThis)->Render_GameCredits();
  829. }
  830. static inline int THREAD_CALL Fxn_SystemContributions (void* pThis) {
  831. return ((HtmlRenderer*) pThis)->Render_SystemContributions();
  832. }
  833. static inline int THREAD_CALL Fxn_SystemCredits (void* pThis) {
  834. return ((HtmlRenderer*) pThis)->Render_SystemCredits();
  835. }
  836. static inline int THREAD_CALL Fxn_LatestGames (void* pThis) {
  837. return ((HtmlRenderer*) pThis)->Render_LatestGames();
  838. }
  839. static inline int THREAD_CALL Fxn_TournamentAdministrator (void* pThis) {
  840. return ((HtmlRenderer*) pThis)->Render_TournamentAdministrator();
  841. }
  842. static inline int THREAD_CALL Fxn_PersonalTournaments (void* pThis) {
  843. return ((HtmlRenderer*) pThis)->Render_PersonalTournaments();
  844. }
  845. static inline int THREAD_CALL Fxn_Tournaments (void* pThis) {
  846. return ((HtmlRenderer*) pThis)->Render_Tournaments();
  847. }
  848. static inline int THREAD_CALL Fxn_GameTos (void* pThis) {
  849. return ((HtmlRenderer*) pThis)->Render_GameTos();
  850. }
  851. static inline int THREAD_CALL Fxn_SystemTos (void* pThis) {
  852. return ((HtmlRenderer*) pThis)->Render_SystemTos();
  853. }
  854. const ThreadFunction g_pfxnRenderPage[] = {
  855. NULL,
  856. Fxn_ActiveGameList,
  857. Fxn_Login,
  858. Fxn_NewEmpire,
  859. Fxn_OpenGameList,
  860. Fxn_SystemGameList,
  861. Fxn_ProfileEditor,
  862. Fxn_TopLists,
  863. Fxn_ProfileViewer,
  864. Fxn_ServerAdministrator,
  865. Fxn_EmpireAdministrator,
  866. Fxn_GameAdministrator,
  867. Fxn_ThemeAdministrator,
  868. Fxn_PersonalGameClasses,
  869. Fxn_Chatroom,
  870. Fxn_SystemServerRules,
  871. Fxn_SystemFAQ,
  872. Fxn_SystemNews,
  873. Fxn_Info,
  874. Fxn_Tech,
  875. Fxn_Diplomacy,
  876. Fxn_Map,
  877. Fxn_Planets,
  878. Fxn_Options,
  879. Fxn_Build,
  880. Fxn_Ships,
  881. Fxn_GameServerRules,
  882. Fxn_GameFAQ,
  883. Fxn_GameNews,
  884. Fxn_GameProfileViewer,
  885. Fxn_GameContributions,
  886. Fxn_GameCredits,
  887. Fxn_GameTos,
  888. Fxn_Quit,
  889. Fxn_LatestNukes,
  890. Fxn_SpectatorGames,
  891. Fxn_SystemContributions,
  892. Fxn_SystemCredits,
  893. Fxn_LatestGames,
  894. Fxn_TournamentAdministrator,
  895. Fxn_PersonalTournaments,
  896. Fxn_Tournaments,
  897. Fxn_SystemTos,
  898. Fxn_Tournaments,
  899. NULL
  900. };
  901. #define DEFAULT_MESSAGE_FONT_SIZE "-1"
  902. #define DEFAULT_MESSAGE_FONT "sans-serif"
  903. #define DEFAULT_PLANET_NAME_FONT "sans-serif"
  904. #define DEFAULT_GAMECLASS_DESCRIPTION_FONT "sans-serif"
  905. #define DEFAULT_QUOTE_FONT "courier"
  906. #define DEFAULT_LINK_COLOR "9090FF"
  907. #define DEFAULT_ALINK_COLOR "9090FF"
  908. #define DEFAULT_VLINK_COLOR "9090FF"
  909. #define DEFAULT_BG_COLOR "000000"
  910. #define DEFAULT_SEPARATOR_STRING "<hr width=\"90%\" height=\"16\">"
  911. #define SYSTEM_MESSAGE_SENDER "The System"
  912. // Dirs
  913. #define BASE_RESOURCE_DIR "resource/"
  914. #define BASE_ALIEN_DIR "aliens/"
  915. #define BASE_UPLOADED_ALIEN_DIR "alienuploads"
  916. #define BASE_UPLOADED_TOURNAMENT_ICON_DIR "tournamentuploads"
  917. #define BASE_UPLOADED_TOURNAMENT_TEAM_ICON_DIR "tournamentteamuploads"
  918. #define TRANSPARENT_DOT "dot.gif"
  919. #define INDEPENDENT_PLANET_NAME "independent.gif"
  920. #define BACKGROUND_IMAGE "background.jpg"
  921. #define ALMONASTER_BANNER_IMAGE "almonaster.gif"
  922. #define SEPARATOR_IMAGE "separator.gif"
  923. #define DEFAULT_IMAGE_EXTENSION ".gif"
  924. #define LIVE_PLANET_NAME "planet.gif"
  925. #define DEAD_PLANET_NAME "planet2.gif"
  926. #define HORZ_LINE_NAME "horz.gif"
  927. #define VERT_LINE_NAME "vert.gif"
  928. #define ALIEN_NAME "alien"
  929. #define ICON_WIDTH 40
  930. #define ICON_HEIGHT 40
  931. #define FAQ_FILE "faq/faq.html"
  932. #define NEWS_FILE "text/news.html"
  933. #define INTRO_FILE "text/intro.html"
  934. #define INTRO_UPPER_FILE "text/intro-upper.html"
  935. #define INTRO_LOWER_FILE "text/intro-lower.html"
  936. #define CONTRIBUTORS_FILE "text/contributors.html"
  937. #define CREDITS_FILE "text/credits.html"
  938. #define CONTRIBUTIONS_FILE "text/contributions.html"
  939. #define TOS_FILE "text/tos.html"
  940. #define MAX_NUM_SPACELESS_CHARS 72
  941. #define LOWEST_STRING "Lowest"
  942. #define HIGHEST_STRING "Highest"
  943. #define UNLIMITED_STRING "Unlimited"
  944. // Cookies
  945. #define LAST_EMPIRE_USED_COOKIE "LastEmpireUsed"
  946. #define AUTOLOGON_EMPIREKEY_COOKIE "AutoLogonEmpireKey"
  947. #define AUTOLOGON_PASSWORD_COOKIE "AutoLogonPassword"
  948. // Error macros
  949. #define Check(FxnCall) iErrCode = ##FxnCall; \
  950. if (iErrCode != OK) { \
  951. AddMessage ("Error "); \
  952. AppendMessage (iErrCode); \
  953. AppendMessage (" occurred in " __FILE__); \
  954. AppendMessage (" on line "); \
  955. AppendMessage (__LINE__); \
  956. AppendMessage ("; please contact the administrator"); \
  957. return Redirect (LOGIN); \
  958. }
  959. #define GameCheck(FxnCall) iErrCode = ##FxnCall; \
  960. if (iErrCode != OK) { \
  961. AddMessage ("Error "); \
  962. AppendMessage (iErrCode); \
  963. AppendMessage (" occurred during a game in " __FILE__); \
  964. AppendMessage (" on line "); \
  965. AppendMessage (__LINE__); \
  966. AppendMessage ("; please contact the administrator"); \
  967. g_pGameEngine->SignalGameReader (m_iGameClass, m_iGameNumber, m_iEmpireKey, m_pgeLock); \
  968. m_pgeLock = NULL; \
  969. return Redirect (ACTIVE_GAME_LIST); \
  970. }
  971. #define EmpireCheck(FxnCall) iErrCode = ##FxnCall; \
  972. if (iErrCode != OK) { \
  973. AddMessage ("That empire no longer exists"); \
  974. return Redirect (LOGIN); \
  975. }
  976. // Common macros
  977. #define INITIALIZE_EMPIRE \
  978. \
  979. bool bRedirectTest = true; \
  980. if (InitializeEmpire (false) != OK) { \
  981. return Redirect (LOGIN); \
  982. }
  983. #define SYSTEM_REDIRECT_ON_SUBMIT \
  984. \
  985. goto Redirection; \
  986. Redirection: \
  987. if (bRedirectTest) { \
  988. PageId pageRedirect; \
  989. if (RedirectOnSubmit (&pageRedirect)) { \
  990. return Redirect (pageRedirect); \
  991. } \
  992. }
  993. #define SYSTEM_OPEN(bFlag) \
  994. \
  995. Write ("<html><head><title>"); \
  996. \
  997. WriteSystemTitleString(); \
  998. Write ("</title></head>"); \
  999. WriteBodyString (-1); \
  1000. \
  1001. Write ("<center>"); \
  1002. \
  1003. WriteSystemHeaders (bFlag); \
  1004. \
  1005. Check (PostSystemPageInformation()); \
  1006. \
  1007. WriteSystemButtons (m_iButtonKey, m_iPrivilege); \
  1008. \
  1009. if (m_bTimeDisplay) { \
  1010. \
  1011. char pszDateString [OS::MaxDateLength]; \
  1012. \
  1013. int ec = Time::GetDateString (pszDateString); \
  1014. if (ec == OK) { \
  1015. \
  1016. OutputText ("Server time is <strong>"); \
  1017. m_pHttpResponse->WriteText (pszDateString); \
  1018. OutputText ("</strong><p>"); \
  1019. } \
  1020. } \
  1021. \
  1022. WriteSystemMessages(); \
  1023. \
  1024. WriteSeparatorString (m_iSeparatorKey); \
  1025. #define SYSTEM_CLOSE \
  1026. \
  1027. CloseSystemPage(); \
  1028. return OK;
  1029. #define INITIALIZE_GAME \
  1030. \
  1031. if (m_iPrivilege == GUEST) { \
  1032. AddMessage ("Your empire does not have the privilege to access this game"); \
  1033. return Redirect (ACTIVE_GAME_LIST); \
  1034. } \
  1035. \
  1036. PageId pageRedirect; \
  1037. if (InitializeGame (&pageRedirect) != OK) { \
  1038. return Redirect (pageRedirect); \
  1039. }
  1040. #define GAME_REDIRECT_ON_SUBMIT \
  1041. \
  1042. goto Redirection; \
  1043. Redirection: \
  1044. if (bRedirectTest) { \
  1045. PageId pageRedirect; \
  1046. if (RedirectOnSubmitGame (&pageRedirect)) { \
  1047. return Redirect (pageRedirect); \
  1048. } \
  1049. }
  1050. #define GAME_OPEN \
  1051. \
  1052. Write ("<html><head><title>"); \
  1053. WriteGameTitleString(); \
  1054. Write ("</title></head>"); \
  1055. \
  1056. if (m_iGameState & PAUSED) { \
  1057. WriteBodyString (-1); \
  1058. } else { \
  1059. WriteBodyString (m_sSecondsUntil); \
  1060. } \
  1061. \
  1062. Write ("<center>"); \
  1063. GameCheck (WriteGameHeaderString());
  1064. #define GAME_CLOSE \
  1065. \
  1066. CloseGamePage(); \
  1067. return OK;
  1068. #define HANDLE_CREATE_GAME_OUTPUT(iErrCode) \
  1069. \
  1070. switch (iErrCode) { \
  1071. case OK: \
  1072. { \
  1073. char pszMessage [128 + MAX_FULL_GAME_CLASS_NAME_LENGTH + MAX_EMPIRE_NAME_LENGTH]; \
  1074. /* Go to info screen! */ \
  1075. m_iGameClass = iGameClassKey; \
  1076. m_iGameNumber = iGameNumber; \
  1077. Check (g_pGameEngine->SetEnterGameIPAddress (iGameClassKey, iGameNumber, m_iEmpireKey, m_pHttpRequest->GetClientIP())); \
  1078. Check (g_pGameEngine->GetGameClassName (iGameClassKey, m_pszGameClassName)); \
  1079. sprintf (pszMessage, "Welcome to %s %i, %s", m_pszGameClassName, iGameNumber, m_vEmpireName.GetCharPtr()); \
  1080. AddMessage (pszMessage); \
  1081. return Redirect (INFO); \
  1082. } \
  1083. case ERROR_DISABLED: \
  1084. { \
  1085. Variant vReason;

Large files files are truncated, but you can click here to view the full file