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 #include "egoboo.h"
23 
24 //--------------------------------------------------------------------------------------------
25 //--------------------------------------------------------------------------------------------
26 struct s_chr;
27 struct s_prt;
28 struct s_cap;
29 struct s_mad;
30 struct s_eve;
31 struct s_pip;
32 
33 struct Mix_Chunk;
34 
35 struct s_mpd_BSP;
36 struct s_prt_bundle;
37 
38 //--------------------------------------------------------------------------------------------
39 //--------------------------------------------------------------------------------------------
40 
41 /// Placeholders used while importing profiles
42 struct s_pro_import
43 {
44     int   slot;
45     int   player;
46     int   slot_lst[MAX_PROFILE];
47     int   max_slot;
48 };
49 typedef struct s_pro_import pro_import_t;
50 
51 //--------------------------------------------------------------------------------------------
52 //--------------------------------------------------------------------------------------------
53 // This is for random naming
54 
55 #define CHOPPERMODEL                    32
56 #define MAXCHOP                         (MAX_PROFILE*CHOPPERMODEL)
57 #define CHOPSIZE                        8
58 #define CHOPDATACHUNK                   (MAXCHOP*CHOPSIZE)
59 #define MAXSECTION                      4              ///< T-wi-n-k...  Most of 4 sections
60 
61 /// The buffer for the random naming data
62 struct s_chop_data
63 {
64     size_t  chop_count;             ///< The global number of name parts
65 
66     Uint32  carat;                  ///< The data pointer
67     char    buffer[CHOPDATACHUNK];  ///< The name parts
68     int     start[MAXCHOP];         ///< The first character of each part
69 };
70 typedef struct s_chop_data chop_data_t;
71 
72 chop_data_t * chop_data_init( chop_data_t * pdata );
73 
74 bool_t        chop_export_vfs( const char *szSaveName, const char * szChop );
75 
76 //--------------------------------------------------------------------------------------------
77 
78 /// Defintion of a single chop section
79 struct s_chop_section
80 {
81     int size;     ///< Number of choices, 0
82     int start;    ///< A reference to a specific offset in the chop_data_t buffer
83 };
84 typedef struct s_chop_section chop_section_t;
85 
86 //--------------------------------------------------------------------------------------------
87 
88 /// Defintion of the chop info needed to create a name
89 struct s_chop_definition
90 {
91     chop_section_t  section[MAXSECTION];
92 };
93 typedef struct s_chop_definition chop_definition_t;
94 
95 chop_definition_t * chop_definition_init( chop_definition_t * pdefinition );
96 
97 //--------------------------------------------------------------------------------------------
98 //--------------------------------------------------------------------------------------------
99 
100 /// a wrapper for all the datafiles in the *.obj dir
101 struct s_object_profile
102 {
103     EGO_PROFILE_STUFF
104 
105     // the sub-profiles
106     REF_T   iai;                              ///< the AI  for this profile
107     CAP_REF icap;                             ///< the cap for this profile
108     MAD_REF imad;                             ///< the mad for this profile
109     EVE_REF ieve;                             ///< the eve for this profile
110 
111     PIP_REF prtpip[MAX_PIP_PER_PROFILE];      ///< Local particles
112 
113     // the profile skins
114     size_t  skins;                            ///< Number of skins
115     TX_REF  tex_ref[MAX_SKIN];                ///< references to the icon textures
116     TX_REF  ico_ref[MAX_SKIN];                ///< references to the skin textures
117 
118     // the profile message info
119     int     message_start;                    ///< The first message
120 
121     /// the random naming info
122     chop_definition_t chop;
123 
124     // sounds
125     struct Mix_Chunk *  wavelist[MAX_WAVE];             ///< sounds in a object
126 };
127 
128 typedef struct s_object_profile object_profile_t;
129 typedef struct s_object_profile pro_t;
130 
131 //--------------------------------------------------------------------------------------------
132 //--------------------------------------------------------------------------------------------
133 // the profile list
134 
135 DECLARE_LIST_EXTERN( pro_t, ProList, MAX_PROFILE );
136 
137 int          pro_get_slot_vfs( const char * tmploadname, int slot_override );
138 const char * pro_create_chop( const PRO_REF profile_ref );
139 bool_t       pro_load_chop_vfs( const PRO_REF profile_ref, const char *szLoadname );
140 
141 void    ProList_init();
142 //void    ProList_free_all();
143 size_t  ProList_get_free( const PRO_REF override_ref );
144 bool_t  ProList_free_one( const PRO_REF object_ref );
145 
146 #define VALID_PRO_RANGE( IOBJ ) ( ((IOBJ) >= 0) && ((IOBJ) < MAX_PROFILE) )
147 #define LOADED_PRO( IOBJ )       ( VALID_PRO_RANGE( IOBJ ) && ProList.lst[IOBJ].loaded )
148 
149 //--------------------------------------------------------------------------------------------
150 //--------------------------------------------------------------------------------------------
151 extern size_t  bookicon_count;
152 extern TX_REF  bookicon_ref[MAX_SKIN];                      ///< The first book icon
153 
154 extern pro_import_t import_data;
155 extern chop_data_t chop_mem;
156 
157 DECLARE_STATIC_ARY_TYPE( MessageOffsetAry, int, MAXTOTALMESSAGE );
158 DECLARE_EXTERN_STATIC_ARY( MessageOffsetAry, MessageOffset );
159 
160 extern Uint32          message_buffer_carat;                                  ///< Where to put letter
161 extern char            message_buffer[MESSAGEBUFFERSIZE];                     ///< The text buffer
162 
163 //--------------------------------------------------------------------------------------------
164 //--------------------------------------------------------------------------------------------
165 
166 void profile_system_begin();
167 void profile_system_end();
168 
169 void   init_all_profiles();
170 int    load_profile_skins_vfs( const char * tmploadname, const PRO_REF object_ref );
171 void   load_all_messages_vfs( const char *loadname, const PRO_REF object_ref );
172 void   release_all_pro_data();
173 void   release_all_profiles();
174 void   release_all_pro();
175 void   release_all_local_pips();
176 bool_t release_one_pro( const PRO_REF object_ref );
177 bool_t release_one_local_pips( const PRO_REF object_ref );
178 
179 int load_one_profile_vfs( const char* tmploadname, int slot_override );
180 
181 void reset_messages();
182 
183 const char *  chop_create( chop_data_t * pdata, chop_definition_t * pdef );
184 bool_t        chop_load_vfs( chop_data_t * pchop_data, const char *szLoadname, chop_definition_t * pchop_definition );
185