1 #pragma once
2 
3 //********************************************************************************************
4 //*
5 //*    This file is part of Egoboo.
6 //*
7 //*    Egoboo is free software: you can redistribute it and/or modify it
8 //*    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 //*    Egoboo is distributed in the hope that it will be useful, but
13 //*    WITHOUT ANY WARRANTY; without even the implied warranty of
14 //*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 //*    General Public License for more details.
16 //*
17 //*    You should have received a copy of the GNU General Public License
18 //*    along with Egoboo.  If not, see <http://www.gnu.org/licenses/>.
19 //*
20 //********************************************************************************************
21 
22 /// @file passage.h
23 /// @Passages and doors and whatnot.  Things that impede your progress!
24 
25 #include "egoboo_typedef.h"
26 
27 #include "passage_file.h"
28 
29 //--------------------------------------------------------------------------------------------
30 //--------------------------------------------------------------------------------------------
31 
32 struct s_script_state;
33 
34 //--------------------------------------------------------------------------------------------
35 //--------------------------------------------------------------------------------------------
36 #define MAX_PASS             256                     ///< Maximum number of passages ( mul 32 )
37 #define MAX_SHOP             MAX_PASS
38 #define CLOSETOLERANCE       3                       ///< For closing doors
39 
40 #define SHOP_NOOWNER 0xFFFF        ///< Shop has no owner
41 #define SHOP_STOLEN  0xFFFF        ///< Someone stole a item
42 
43 /// The pre-defined orders for communicating with shopkeepers
44 enum e_shop_orders
45 {
46     SHOP_BUY       = 0,
47     SHOP_SELL,
48     SHOP_NOAFFORD,
49     SHOP_THEFT
50 };
51 
52 //--------------------------------------------------------------------------------------------
53 //--------------------------------------------------------------------------------------------
54 // Passages
55 
56 DECLARE_STACK_EXTERN( passage_t, PassageStack, MAX_PASS );
57 
58 #define VALID_PASSAGE_RANGE( IPASS ) ( ((IPASS) >= 0) && ((IPASS) <   MAX_PASS) )
59 #define VALID_PASSAGE( IPASS )       ( VALID_PASSAGE_RANGE( IPASS ) && ((IPASS) <  PassageStack.count) )
60 #define INVALID_PASSAGE( IPASS )     ( !VALID_PASSAGE( IPASS ) )
61 
62 /// The data defining a shop
63 struct s_shop
64 {
65     PASS_REF passage;  ///< The passage number
66     CHR_REF  owner;    ///< Who gets the gold?
67 };
68 typedef struct s_shop shop_t;
69 
70 DECLARE_STACK_EXTERN( shop_t, ShopStack, MAX_SHOP );
71 
72 #define VALID_SHOP_RANGE( ISHOP ) ( ((ISHOP) >= 0) && ((ISHOP) <   MAX_SHOP) )
73 #define VALID_SHOP( ISHOP )       ( VALID_SHOP_RANGE( ISHOP ) && ((ISHOP) <  ShopStack.count) )
74 #define INVALID_SHOP( ISHOP )     ( !VALID_SHOP( ISHOP ) )
75 
76 //--------------------------------------------------------------------------------------------
77 //--------------------------------------------------------------------------------------------
78 // prototypes
79 
80 void   check_passage_music();
81 void   clear_all_passages();
82 void   activate_passages_file_vfs();
83 
84 void   add_passage( passage_t * pdata );
85 
86 bool_t   open_passage( const PASS_REF ipassage );
87 bool_t   close_passage( const PASS_REF ipassage );
88 void     flash_passage( const PASS_REF ipassage, Uint8 color );
89 CHR_REF who_is_blocking_passage( const PASS_REF passage, const CHR_REF isrc, IDSZ idsz, BIT_FIELD targeting_bits, IDSZ require_item );
90 void   add_shop_passage( const CHR_REF owner, const PASS_REF ipassage );
91 
92 bool_t point_is_in_passage( const PASS_REF ipassage, float xpos, float ypos );
93 bool_t object_is_in_passage( const PASS_REF ipassage, float xpos, float ypos, float radius );
94 
95 CHR_REF  shop_get_owner( int ix, int iy );
96