ScummVM API documentation
gtldat.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef BAGEL_METAGAME_GTL_GTLDAT_H
23 #define BAGEL_METAGAME_GTL_GTLDAT_H
24 
25 #include "common/stream.h"
26 #include "common/system.h"
27 #include "bagel/boflib/sound.h"
28 #include "bagel/hodjnpodj/metagame/bgen/bgen.h"
29 #include "bagel/hodjnpodj/metagame/bgen/bgenut.h"
30 #include "bagel/hodjnpodj/metagame/bgen/bsutl.h"
31 #include "bagel/hodjnpodj/metagame/gtl/gtlview.h"
32 #include "bagel/hodjnpodj/globals.h"
33 #include "bagel/hodjnpodj/metagame/gtl/resource.h"
34 #include "bagel/hodjnpodj/metagame/bgen/bgb.h"
35 #include "bagel/hodjnpodj/metagame/bgen/bbt.h"
36 #include "bagel/hodjnpodj/metagame/bgen/bfc.h"
37 #include "bagel/hodjnpodj/metagame/bgen/mgstat.h"
38 
39 namespace Bagel {
40 namespace HodjNPodj {
41 namespace Metagame {
42 namespace Gtl {
43 
44 #define MAX_NODES 550 // max # nodes supported
45 #define MAX_LINKS_PER_NODE 6 // max # links for 1 node
46 #define MAX_FILENAME_LENGTH 60 // max .p filename length
47 #define MAX_TEXT_LENGTH 200 // max length of text
48 #define MAX_HANDLE_LENGTH 200 // max length of handle name
49 #define MAX_STRINGLIST 512 // max total length of all strings in line
50 #define MAX_LEXELTS 100 // max # of CLexElement objects
51 #define MAX_LABEL_LENGTH 12 // max length of node/bitmap
52 // label/action
53 #define MAX_BITMAPS 130
54 
55 #define NODERADIUS 5 /* display radius of node */
56 #define NODESENSITIVITY 20 /* default node sensitivity */
57 #define MAX_GAME_TABLE 12 /* meta game execution table */
58 #define MAX_CLUES 100
59 
60 #define NEWSCROLL 1
61 
62 // defining distance between nodes
63 inline long SQ(int y) {
64  return ((long)((long)y * (long)y)) ;
65 }
66 inline long SQ(long y) {
67  return (y * y) ;
68 }
69 inline long LSQ(CPoint p1, CPoint p2) {
70  return (SQ(p1.x - p2.x) + SQ(p1.y - p2.y)) ;
71 }
72 
73 // lexical element types
74 #define LXT_INTEGER 102
75 #define LXT_STRING 103
76 #define LXT_IDENT 104
77 #define LXT_COMMA 106
78 #define LXT_EQU 107
79 #define LXT_LPR 108
80 #define LXT_RPR 109
81 #define LXT_PLUS 110
82 #define LXT_MINUS 111
83 #define LXT_SEMIC 112
84 #define LXT_COLON 113
85 #define LXT_EOX 120
86 
87 
88 // keyword codes
89 #define KT_BMP 201
90 #define KT_NODE 202
91 #define KT_LINK 203
92 #define KT_ABOVE 204
93 #define KT_BELOW 205
94 #define KT_LEFT 206
95 #define KT_RIGHT 207
96 #define KT_PALETTE 208
97 #define KT_SPRITE 209
98 #define KT_PASSTHRU 210
99 #define KT_PREVIOUS 211
100 #define KT_LINKPREV 212
101 #define KT_POSITION 213
102 #define KT_DIRECTORY 214
103 #define KT_OVERLAY 215
104 #define KT_MASKED 216
105 #define KT_METAGAME 217
106 #define KT_WEIGHT 218
107 #define KT_ACTION 219
108 #define KT_BORDER 220
109 #define KT_SECTOR 221
110 #define KT_SENSITIVITY 222
111 #define KT_FOREGROUND 223
112 #define KT_BACKGROUND 224
113 #define KT_ANIMATED 225
114 #define KT_SIZE 226
115 #define KT_MIDDLE 227
116 #define KT_FREQUENCY 228
117 #define KT_EOF 230
118 
119 // object types
120 #define OBJ_NONE 0
121 #define OBJ_BITMAP 301
122 #define OBJ_NODE 302
123 #define OBJ_LINK 303
124 
125 // buttons
126 #define BUTTON_MINIMAP 1
127 #define BUTTON_INVENTORY 2
128 #define BUTTON_SCROLL 3
129 
130 // node types
131 #define NT_GAME_MIN 100 /* use BFCG_xxxx game code */
132 #define NT_GAME_MAX 200
133 #define NT_MENU 201 /* meta-game menu */
134 #define NT_OVERLAY 202 /* tied to overlay */
135 
136 // codes for DumpGameStatus
137 #define DUMPSTAT_PROBLEM 0x8000
138 #define DUMPSTAT_CURRENT 0x4000
139 #define DUMPSTAT_BOTH 0x2000
140 #define DUMPSTAT_EVERYTHING 0xFFFF
141 
142 class CGtlView;
143 
144 class CMemDC {
145 public:
146  CMemDC();
147  ~CMemDC();
148 
149  CDC *m_pDC = nullptr;
150  CPalette *m_pPalOld = nullptr;
151  HBITMAP m_hBmpOld = nullptr;
152 };
153 
154 // CLexElement -- lexical element class
155 class CLexElement {
156  friend class CGtlData ;
157  int m_iType ; // lexical type -- LXT_xxxx
158  int m_iVal ; // integer or char or keyword code
159  int m_iStringListPos ; // string position
160  int m_iLineNumber, m_iColumn ; // for error messages
161 };
162 
163 // CKeyTab -- keyword table element
164 class CKeyTab {
165 public:
166  int m_iKeyValue ; // keyword value
167  const char *m_xpszKeyString ; // string
168 };
169 
170 // CMap -- bit map
171 class CMap {
172  friend class CGtlData ;
173 
174  char m_szLabel[MAX_LABEL_LENGTH] = {}; // bitmap label
175  char m_szFilename[MAX_FILENAME_LENGTH] = {}; // file name of BMP file
176  bool m_bPositionDetermined: 1 ;
177  bool m_bSprite : 1 ;
178  bool m_bPalette : 1 ; // game palette from this bitmap
179  bool m_bOverlay : 1 ; // overlay onto background map
180  bool m_bMasked : 1 ; // bitmap is masked
181  bool m_bMetaGame : 1 ; // show bitmap only in metagame
182  bool m_bRelocatable : 1 ; // relocatable
183  bool m_bPositionSpecified : 1 ; // position specified on input
184  bool m_bSpecialPaint: 1 ; // don't automatically paint
185  CBgbObject FAR *m_lpcBgbObject = nullptr; // Boffo game object for bitmap file
186 
187  int m_iRelationType = 0; // KT_ABOVE, KT_BELOW, KT_LEFT, KT_RIGHT,
188  // KT_NODE
189  int m_iRelation = 0; // index of relation bitmap or node
190 
191  CMap() {
192  m_bPositionDetermined = false;
193  m_bSprite = false;
194  m_bPalette = false;
195  m_bOverlay = false;
196  m_bMasked = false;
197  m_bMetaGame = false;
198  m_bRelocatable = false;
199  m_bPositionSpecified = false;
200  m_bSpecialPaint = false;
201  }
202 };
203 
207 class CNode {
208 public:
209  char m_szLabel[MAX_LABEL_LENGTH] = { 0 }; // node label
210  int m_iLinks[MAX_LINKS_PER_NODE] = { 0 }; // up to 10 links per node
211  int m_iLocationCode = 0; // MG_LOC_xxxx to specify location
212  int m_iSector = 0; // MG_SECTOR_xxxx to specify sector
213  int m_iBitmap = 0; // index of related bitmap
214  int m_iX = 0, m_iY = 0; // position
215  int m_iNumLinks = 0; // number of links
216  bool m_bDeleted : 1; // deleted node
217  bool m_bSelected : 1; // this is selected node
218  bool m_bRelative : 1; // relative to bitmap
219  bool m_bRelocatable : 1; // relocatable node
220  bool m_bWgtSpec : 1; // weight specified
221  bool m_bSenSpec : 1; // sensitivity specified
222  bool m_bMenu : 1; // true if menu
223  byte m_iWeight = 0; // node weight
224  byte m_iSensitivity = 0; // distance to accept clickb
225 
226  CNode();
227 
228  bool IfRelocatable() {
229  return (m_bRelocatable != 0) ;
230  }
231 };
232 
233 // CStratLocInfo -- strategy location information
235  friend class CGtlData ;
236  friend class CStrategyInfo ;
237 
238  int m_iLocCode = 0; // MG_LOC_xxxx -- location code
239  CNode FAR *m_lpNode = nullptr; // node pointer for location
240  int m_iValueCode = 0; // MG_VISIT_xxxx or MG_WIN_xxxx
241  // or 0 if not eligible
242  int m_iDistance = 0; // distance to location
243  int m_iWeight = 0; // weight of location
244  int m_iAdjustedWeight = 0; // weight adjusted by distance
245 
246  void clear() {
247  m_iLocCode = 0;
248  m_lpNode = nullptr;
249  m_iValueCode = 0;
250  m_iDistance = 0;
251  m_iWeight = 0;
252  m_iAdjustedWeight = 0;
253  }
254 };
255 
256 
257 // CStrategyInfo -- strategy information for determining best move
259  friend class CGtlData ;
260 
261  CStratLocInfo *xpTargetLocInfo = nullptr; // target location (best move)
262 
263  int m_iRequiredObjectsCount = 0; // total number of objects I need
264  int m_iRequiredObjectsTable[MAX_GAME_TABLE] = {}; // objects I need
265 
266  int m_iMaximumDistance = 0; // max distance to eligible location
267  int m_iMaxAdjustedWeight = 0; // maximum adjusted weight
268  int m_iTopLocCount = 0; // number of top locations
269  int m_iTopLocTable[MG_LOC_MAX] = {}; // table of top locations
270 
271  CStratLocInfo m_cStratLocInfo[MG_LOC_MAX + 1] ;
272 };
273 
274 // CXodj -- structure for Hodj Podj
275 class CXodj {
276  friend class CGtlData ;
277 
278 public:
279 
280  CXodj *m_xpXodjNext = nullptr; // next in chain
281  char m_szName[MAX_LABEL_LENGTH] = {}; // name of character
282  bool m_bHodj = false; // char is Hodj (not Podj)
283  int m_iFurlongs = 0; // number of furlongs available
284  int m_iCharNode = 0; // node where character is positioned
285 
286  int m_nTurns = 0; // number of turns remaining (not furlongs)
287 
288  bool m_bComputer = false; // played by computer
289  CMap FAR *m_lpMap = nullptr; // bitmap object
290  CBgbObject FAR *m_lpcCharSprite = nullptr; // character sprite bgb object
291  CBgbObject FAR *m_lpcIcon = nullptr; // icon for character
292 
293  CSound *m_pThemeSound = nullptr; // this character's MIDI theme song info
294  const char *m_pszThemeFile = nullptr;
295  unsigned int m_nThemeStart = 0;
296  unsigned int m_nThemeEnd = 0;
297 
298  const char *m_pszStarsFile = nullptr; // cel strip for stars animation
299 
300  // fields for computing computer play (also used for human player
301  // for debugging or giving hints)
302  class CStrategyInfo *m_xpStrategyInfo = nullptr; // strategy information
303 
304  // list of clue numbers for clues given by winning mini-game
305  int m_iWinInfoWon = 0; // how many clues I've received
306  int m_iWinInfoNeed = 0; // total number of clues I need
307  int m_iWinInfoTable[MAX_GAME_TABLE] = {};
308 
309  // list of clue numbers for clues given by farmer, etc.
310  int m_iSecondaryInfoWon = 0; // how many clues I've received
311  int m_iSecondaryInfoNeed = 0; // total number of clues I need
312  int m_iSecondaryInfoTable[MAX_GAME_TABLE] = {};
313 
314  // list of objects required to get Mish/Mosh
315  int m_iRequiredObjectsCount = {}; // total number of objects I need
316  int m_iRequiredObjectsTable[MAX_GAME_TABLE] = {}; // objects I need
317  int m_iRequiredMoney = 0; // money needed for Mish/Mosh
318 
319  // list of secondary information location we still have to visit
320  int m_iSecondaryLoc[MAX_GAME_TABLE] = {};
321 
322  int m_iGameHistory[20] = {}; // last 20 mini-games played
323  int m_iTargetLocation = 0; // target location for computer play
324  bool m_bGatherInformation = false; // if false, data from last
325  // GatherInformation is still valid
326 
327  CInventory *m_pInventory = nullptr; // items in personal inventory
328  CInventory *m_pGenStore = nullptr; // items in general store
329  CInventory *m_pBlackMarket = nullptr; // items in pawn shop
330  CInventory *m_pTradingPost = nullptr; // items in pawn shop
331 
332  ~CXodj();
333 };
334 
335 // CGtlData -- data class for graphics utility
336 class CGtlData {
337 public:
338  class CGtlDoc *m_xpcGtlDoc = nullptr; // document pointer
339 
340 private:
341  bool bFirstTime = true;
342  CGenUtil m_cGenUtil; // general utility object
343  CBgbMgr m_cBgbMgr; // Boffo Game Object manager
344  CBbtMgr m_cBbtMgr; // Boffo Games button manager
345  CBbutton m_cMiniButton; // minimap button
346  CBbutton m_cInvButton; // inventory button
347  CBbutton m_cScrollButton; // scroll button
348 
349  CMap FAR *m_lpMaps = nullptr; // bitmap array
350  CNode FAR *m_lpNodes = nullptr; // node array
351 
352  bool m_bGtlDll = false; // equals GTLDLL define
353  char m_szBmpDirectory[MAX_FILENAME_LENGTH] = {}; // bitmap file director
354  char m_szGtlFile[MAX_FILENAME_LENGTH] = {}; // gtl file name
355  char m_szListFile[MAX_FILENAME_LENGTH] = {}; // List file name
356  Common::SeekableReadStream *m_xpGtlFile = nullptr; // ptr to file structure for .GTL file
357  Common::WriteStream *m_xpListFile = nullptr; // ptr to file structure for .LST file
358  bool m_bListing = false; // listing file flag
359  int m_iIndent = 0; // current indent (decompile only)
360  int m_iLineNumber = 0; // line number in input file
361  int m_iMaps = 0, m_iNodes = 0; // # of bitmaps, nodes
362  bool m_bEof = false; // end of file on input (or END stmt)
363  CNode FAR *m_lpLastNode = nullptr; // pointer to last node
364  int m_iNumGenLabels = 0; // number of generated lables
365  CLexElement *m_xpLexLabel = nullptr; // current label lexeme
366  CLexElement m_cLexElts[MAX_LEXELTS] = {}; // lexical element blocks
367  char m_szStringList[MAX_STRINGLIST] = {}; // compiler input string
368  bool m_bSelectedLink = false; // flag: a link is selected
369  int m_iSelLinkPt1 = 0, m_iSelLinkPt2 = 0; // indexes of selected link pts
370  uint32 m_stAcceptClickActive = 0; // prevent recursion
371  uint32 m_stLDownTime = 0; // time of left button down
372  CNode FAR *m_lpFoundNode = nullptr; // node clicked on
373  CNode FAR *m_lpLastSelectedNode = nullptr; // selected on click down
374 
375  bool m_bJustPlayedMiniGame = false; // true for Mini-Games in ProcessGameResult
376 
377  // fields for Draw routine
378 public:
379  bool m_bInhibitDraw = false; // inhibit any actual drawing
380  bool m_bDrawing = false; // in Draw routine (prevent recursion)
381  CGtlView *m_xpGtlView = nullptr; // current view
382  bool m_bPaint = false; // WM_PAINT flag
383  bool m_bRelocatable = false; // device context is currently
384  // relocatable
385  CRect *m_xpClipRect = nullptr; // relocatable clipping rectangle
386  CRect *m_xpDevClipRect = nullptr; // device (non-relocatable)
387  // clipping rectangle
388  CMap FAR *m_lpFurlongMaps[25] = {}; // 0-24 furlong bitmaps
389 
390 // ---
391 public:
392  int m_iSizeX = 0, m_iSizeY = 0; // size of entire client area
393  // (entire bitmap)
394  int m_iMargin = 0; // size of top margin of view window
395  bool m_bChangeSize = false; // size of window changed (because
396  // gtl modified the bitmap template)
397  int m_iViewSizeX = 0, m_iViewSizeY = 0; // size of view
398 
399  bool m_bPaintBackground = false; // paint background
400  bool m_bShowNodes = false; // show nodes and links
401  bool m_bShowSensitivity = false; // show node sensitivities
402  bool m_bStartMetaGame = false; // start in meta game mode
403  bool _metaGame = false; // meta game mode
404  bool m_bInitMetaGame = false; // init sprites at beginning of metagame
405 
406  CXodj *m_xpXodjChain = nullptr; // chain of characters
407  CXodj *m_xpCurXodj = nullptr; // character currently on the move
408  bool m_bSamePlace = false; // both characters are in same place
409  bool m_bGameOver = false; // game is over
410 
411  CBitmap *m_pOffScreenBmp = nullptr;
412  CPalette *m_pPalOld = nullptr;
413  HBITMAP m_hOldBitmap = nullptr;
414 
415  int m_iMishMoshLoc = 0; // MG_LOC_xxxx -- Mish/Mosh location
416 
417  COLORREF m_cNodePenColor = 0, m_cNodeBrushColor = 0, m_cLinkPenColor = 0;
418  COLORREF m_cNodeSensitivityColor = 0;
419  COLORREF m_cNodePassThruColor = 0, m_cNodeHeavyColor = 0;
420  COLORREF m_cSelNodePenColor = 0, m_cSelNodeBrushColor = 0;
421  COLORREF m_cSelLinkPenColor = 0;
422  COLORREF m_cBackColor = 0;
423 
424  // constructor zeroes out all fields and allocates far arrays
425 public:
426  void ClearData() {
427  *this = CGtlData();
428  }
429 
430  // gtldcp.cpp -- decompiler for meta game
431 
432  //- Decompile -- output data to .GTL file
433  int Decompile(const char *xpszPathName) ;
434  //- AsciiOutput -- ascii output
435  int AsciiOutput(int iIndent, XPSTR lpszOut) ;
436  //- ListingOutput -- listing output
437  int ListingOutput(int iIndent, XPSTR lpszOut) ;
438 
439 
440  // gtlcpl.cpp -- compiler for graphics utility
441 
447  int Compile(const char *xpszPathName);
448 
449  //- ParseLine -- parse input line
450  bool ParseLine() ;
451  //- ParseInteger -- parse integer, store into node structure
452  CLexElement *ParseInteger(CLexElement * xpLxel,
453  int iPrevType, int FAR& iValue) ;
454  //- ParseString -- parse string, store into node structure
455  // Note: Accepts identifier as well as string
456  CLexElement *ParseString(CLexElement * xpLxel,
457  int iPrevType, char *lpszValue, XPINT xpiValue) ;
458  //- GetLabel -- get bitmap or node label
459  bool GetLabel(CLexElement * xpLxel,
460  bool bNode, int FAR& iIndex) ;
461  //- GetLabel -- get bitmap or node label
462  bool GetLabel(char *lpszLabel,
463  bool bNode, int FAR& iIndex) ;
464 
465 private:
466  //- AddLink -- link together a pair of nodes
467  bool AddLink(CNode FAR * lpNode1, CNode FAR * lpNode2) ;
468  //- AddLink -- add link to one node
469  bool AddLink(CNode FAR * lpNode, int iLink) ;
470 
471 
472  // gtllex -- lexical analysis for graphics utility
473 
474  //- FindKeyword -- find keyword, given tree node type
475  const char *FindKeyword(int iType) ;
476  //- ReadLine -- read input line
477  bool ReadLine() ;
478  //- ErrorMsg -- publish error message
479  bool ErrorMsg(CLexElement * xpLxel, const char *szMessage) ;
480 
481  // gtlui.cpp -- data interface to Windows
482 
483 public:
484  //- CGtlData -- constructor -- zero out all fields, allocate
485  // arrays, and set colors
486  CGtlData() ;
487  ~CGtlData() ;
488 
489  void CreateOffScreenBmp();
490  void DeleteOffScreenBmp();
491  void PaintOffScreenBmp();
492  CMemDC *GetMemDC();
493  void ReleaseMemDC(CMemDC *);
494 
495 
496  bool SetColors() ;
497  //- ClearInhibitDraw -- clear m_bInhibitDraw flag
498  bool ClearInhibitDraw() ;
499  //- Draw -- draw data
500  bool Draw(CGtlView * xpGtlView, CRect * xpClipRect,
501  CDC* xpDc PDFT(nullptr)) ;
502  //- SwitchDc -- switch between relocatable/nonrelocatable
503  // device context
504  bool SwitchDc(CDC * xpDc, bool bRelocatable) ;
505  //- DrawBitmaps -- draw bitmaps for Draw routine
506  bool DrawBitmaps(CDC *, bool);
507 
508  //- DrawABitmap -- draw a bitmap object for Draw routine
509  bool DrawABitmap(CDC *, CBgbObject *, bool bPaint PDFT(false));
510 
511  //- NodeToPoint -- return relocatable coordinates of node
512  // adjusted by optional size object
513  CRPoint NodeToPoint(CNode * lpNode,
514  CSize FAR * lpcSize PDFT(nullptr)) ;
515  //- SpecifyUpdate -- specify update rectangle
516  bool SpecifyUpdate(CGtlView * xpGtlView) ;
517  //- UpdateDialogs -- update modeless dialog boxes
518  bool UpdateDialogs(bool bRetrieve PDFT(false)) ;
519 
520 private:
521  //- UpdateMenuDialog -- update control dialog box
522  bool UpdateMenuDialog(bool bRetrieve) ;
523 
524  //- UpdateInfoDialog -- update information dialog box
525  bool UpdateInfoDialog(bool bRetrieve) ;
526 
527  //- UpdateControlDialog -- update control dialog box
528  bool UpdateControlDialog(bool bRetrieve) ;
529 
530  //- UpdateNodeDialog -- update node dialog box
531  bool UpdateNodeDialog(bool bRetrieve) ;
532 
533  //- UpdateFocusRect -- update focus rectangle for hiliting
534  bool UpdateFocusRect() ;
535 
536  //- AdjustToView -- set up bitmaps for view
537  bool AdjustToView(CGtlView *);
538 
539  //- InitOverlay -- initialize overlay
540  bool InitOverlay(CMap FAR * lpMap) ;
541  //- NormalizeData -- normalize data after loading
542  bool NormalizeData(CGtlView * xpGtlView) ;
543 
544  // gtlmanp.cpp -- manipulate the data
545 public:
546 
547  //- AcceptClick -- process a mouse click by user
548  bool AcceptClick(CGtlView * xpGtlView, CPoint cClickPoint, int iClickType) ;
549  //- AcceptDeleteKey -- process depressing delete key
550  bool AcceptDeleteKey(CGtlView * xpGtlView) ;
551 
552 private:
553  //- PointToNode -- find node closest to point
554  CNode FAR *PointToNode(CRPoint crPoint) ;
555  //- SelectNode -- algorithm when node is clicked
556  bool SelectNode(CNode FAR * lpNode) ;
557  //- ModifySelectNode -- modify node select/deselect
558  bool ModifySelectNode(CNode FAR * lpNode PDFT(nullptr), bool bSelect PDFT(true)) ;
559  //- GetSelectedNode -- return selected node, or nullptr if none
560  CNode FAR *GetSelectedNode() ;
561  //- SelectLink -- select or deselect a link
562  bool SelectLink(CNode FAR * lpNode1 PDFT(nullptr), CNode FAR * lpNode2 PDFT(nullptr)) ;
563  //- IfLinked -- test whether two nodes are linked
564  bool IfLinked(CNode FAR * lpNode1, CNode FAR * lpNode2) ;
565  //- DeleteNode -- delete node and all connecting links
566  bool DeleteNode(CNode * lpNode) ;
567  //- DeleteLink -- delete link between two nodes
568  bool DeleteLink(CNode FAR * lpNode1 PDFT(nullptr), CNode FAR * lpNode2 PDFT(nullptr)) ;
569  //- DeleteLinkIndex -- delete index from array of link
570  // indices for a given node, if found
571  bool DeleteLinkIndex(CNode FAR * lpNode, int iLink) ;
572  //- CallUpdate -- call to update all views for this map
573  bool CallUpdate(CNode FAR * lpNode1 PDFT(nullptr),
574  CNode FAR * lpNode2 PDFT(nullptr), bool bLinks PDFT(false),
575  bool bWmPaint PDFT(false)) ;
576  //- CallUpdate -- call to update all views for this map
577  // -- version which updates a bitmap object
578  bool CallUpdate(CBgbObject * lpcBgbObject) ;
579  //- CreateNode -- create a new node
580  bool CreateNode(CNode FAR * &lpNode, CRPoint crPosition) ;
581  //- MoveNode -- move node
582  bool MoveNode(CNode FAR * lpNode, CRPoint crPosition) ;
583 
584  int DoSpecialTravel(int, bool);
585  void LoadCharDirection(CBgbObject *, CPoint, CPoint);
586 
587  //- CreateLink -- create link between two nodes
588  bool CreateLink(CNode FAR * lpNode1, CNode FAR * lpNode2) ;
589  //- SetNodePosition -- set position relative to bitmap
590  bool SetNodePosition(CNode FAR * lpNode, CRPoint crPosition) ;
591 
592 
593  // gtlmgm.cpp -- meta game
594 public:
595 
596  //- SetMetaGame -- set meta game on or off
597  bool SetMetaGame(bool bOn) ;
598  //- InitMetaGame -- init or release sprites for Meta Game
599  bool InitMetaGame(CGtlView * xpGtlView PDFT(nullptr),
600  bool bInit PDFT(true)) ;
601  //- ProcessMove -- handle move processing
602  bool ProcessMove(CNode FAR * lpTargetNode PDFT(nullptr)) ;
603 
604 private:
605  //- MoveCharToNode -- move current character to specified node
606  bool MoveCharToNode(CNode FAR * lpTargetNode) ;
607  //- EstimatePathDistance -- estimate distance between nodes
608  int EstimatePathDistance(CNode FAR * lpNode1,
609  CNode FAR * lpNode2) ;
610  //- FindShortestPath -- between two nodes
611  int *FindShortestPath(CNode FAR * lpNode1,
612  CNode FAR * lpNode2) ;
613 
614 public:
615  //- PositionCharacters -- set positions for Hodj and Podj
616  bool PositionCharacters() ;
617 
618 private:
619  //- PositionACharacter -- find positions for Hodj and Podj
620  bool PositionACharacter(CXodj * xpXodj, int iShift) ;
621  //- LocationToNode -- find node for game location
622  CNode FAR *LocationToNode(int iLocationCode) ;
623 
624 public:
625  int FindNodeId(const char *pszLabel);
626 
627 
628  // gtlmve.cpp -- meta game move processing
629 
630 private:
631  //- InitProblem -- initialize character problem
632  bool InitProblem() ;
633  //- EndMoveProcessing -- handle things at end of a move
634  bool EndMoveProcessing() ;
635 
636 public:
637  //- SwitchPlayers -- switch between Hodj and Podj
638  bool SwitchPlayers() ;
639  //- InitInterface -- init data for interface manager
640  bool InitInterface(int iCode, bool & bExitDll) ;
641  //- ReturnFromInterface -- reset everything
642  // after interface return
643  bool ReturnFromInterface() ;
644 
645 private:
646  //- TakeIneligibleAction -- take action if character is at
647  // a location but is not eligible to perform function
648  bool TakeIneligibleAction(CXodj * xpXodj,
649  int iFunctionCode, int iLocationCode) ;
650  //- DumpGameStatus -- (debugging) dump status of game
651  bool DumpGameStatus(int iOptionFlags
652  PDFT(DUMPSTAT_EVERYTHING)) ;
653  //- ProcessGameResult -- process result of game,
654  // optionally generating a random win
655  bool ProcessGameResult(CXodj * xpXodj,
656  int iGameCode, LPGAMESTRUCT lpGameStruct PDFT(nullptr)) ;
657 
658 public:
659  //- GainRandomItem -- player receives a random item from store
660  bool GainRandomItem(CXodj * xpXodj) ;
661 
662  //- GainMoney -- player has won some money
663  bool GainMoney(CXodj * xpXodj, long lCrowns) ;
664 
665  //- GainMishMosh -- player gets MishMosh
666  bool GainMishMosh(CXodj * xpXodj, long lCrowns) ;
667 
668  //- DivulgeInformation -- divulge information to player
669  bool DivulgeInformation(CXodj * xpXodj, bool bSecondary) ;
670 
671 private:
672  //- DetermineEligibility -- determine whether
673  // player has objects/money needed for current location
674  bool DetermineEligibility(CXodj *xpXodj, int, int &, bool bExecute PDFT(false));
675 
676  //- DetermineGameEligibility -- determine if eligible to play
677  // a game, and update game history if so (and bExecute)
678  // ***** modify this function to determine how often a user can
679  // play the same game over and over
680  bool DetermineGameEligibility(CXodj *xpXodj, int iGameCode, bool bExecute PDFT(false));
681 
682  //- GetGameObjectCount -- get the count of the specified
683  // object in the player's inventory
684  long GetGameObjectCount(CXodj * xpXodj, int iObjectCode) ;
685 
686  //- DetermineInfoEligibility -- determine if eligible to
687  // get information at this location
688  bool DetermineInfoEligibility(CXodj * xpXodj,
689  int iLocationCode, bool bExecute PDFT(false)) ;
690 
691  //- DetermineMishMoshEligibility -- determine if eligible to
692  // grab Mish and Mosh from current location
693  bool DetermineMishMoshEligibility(CXodj *, int);
694 
695  void DoTransport(CXodj *, int);
696 
697 
698  // gtlcmp.cpp -- meta game computer play
699 private:
700  //- SelectBestMove -- select best move for computer play
701  // (can also be used for human player for debugging or giving hints)
702  bool SelectBestMove(CXodj * xpXodj) ;
703  //- GatherInformation -- gather info to decide computer's move
704  bool GatherInformation(CXodj * xpXodj) ;
705  //- DetermineWeights -- determine weight for each
706  // location (independent of distance)
707  bool DetermineWeights(CXodj * xpXodj) ;
708  //- DetermineDistances -- determine distance to each
709  // eligible location
710  bool DetermineDistances(CXodj * xpXodj) ;
711  //- AdjustWeightByDistance -- adjust each by the distance
712  // of the node
713  bool AdjustWeightByDistance(CXodj * xpXodj) ;
714  //- FindTopLocations -- find locations with top weights
715  bool FindTopLocations(CXodj * xpXodj) ;
716  //- DumpBestMoveData -- dump data used in best move computation
717  bool DumpBestMoveData(CXodj * xpXodj) ;
718 
719  void CheckForTransport(CXodj *, int);
720  void SetFurlongs(CXodj *);
721 };
722 
723 } // namespace Gtl
724 } // namespace Metagame
725 } // namespace HodjNPodj
726 } // namespace Bagel
727 
728 #endif
Definition: stream.h:77
Definition: stream.h:745
Definition: afxwin.h:667
Definition: atltypes.h:40
Definition: afxwin.h:721
Definition: minwindef.h:87
Definition: afxwin.h:27
Definition: atltypes.h:131
Definition: atltypes.h:79
Definition: afxwin.h:635