Pol  Revision:cb584c9
tiles.cpp
Go to the documentation of this file.
1 
9 #include "tiles.h"
10 
11 #include <stddef.h>
12 
13 #include "../clib/cfgelem.h"
14 #include "../clib/logfacility.h"
15 #include "../clib/passert.h"
16 #include "../plib/mapfunc.h"
17 #include "../plib/pkg.h"
18 #include "../plib/systemstate.h"
19 
20 namespace Pol
21 {
22 namespace Core
23 {
24 void load_tile_entry( const Plib::Package* /*pkg*/, Clib::ConfigElem& elem )
25 {
26  unsigned short graphic = static_cast<unsigned short>( strtoul( elem.rest(), nullptr, 0 ) );
27  passert_always( graphic < ( Plib::systemstate.config.max_tile_id + 1 ) );
28  Tile& entry = Plib::systemstate.tile[graphic];
29  entry.desc = elem.remove_string( "Desc" );
30  entry.uoflags = elem.remove_ulong( "UoFlags" );
31  entry.layer = static_cast<u8>( elem.remove_ushort( "Layer", 0 ) );
32  entry.height = static_cast<u8>( elem.remove_ushort( "Height" ) );
33  entry.weight = static_cast<u8>( elem.remove_ushort( "Weight" ) );
34  entry.flags = Plib::readflags( elem );
35 
37 }
38 
40 {
42  new Tile[static_cast<size_t>( Plib::systemstate.config.max_tile_id + 1 )];
43 
44  load_all_cfgs( "tiles.cfg", "TILE", load_tile_entry );
45 
46  if ( !Plib::systemstate.tiles_loaded )
47  ERROR_PRINT << "Warning: No tiles loaded. Please check tiles.cfg\n";
48 }
49 }
50 }
unsigned int uoflags
Definition: tiles.h:23
unsigned char u8
Definition: rawtypes.h:25
void load_tiles_cfg()
Definition: tiles.cpp:39
std::string remove_string(const char *propname)
Definition: cfgfile.cpp:381
SystemState systemstate
Definition: systemstate.cpp:12
Core::PolConfig config
Definition: systemstate.h:43
void load_tile_entry(const Plib::Package *, Clib::ConfigElem &elem)
Definition: tiles.cpp:24
unsigned int remove_ulong(const char *propname)
Definition: cfgfile.cpp:461
unsigned int max_tile_id
Definition: polcfg.h:61
std::string desc
Definition: tiles.h:22
const char * rest() const
Definition: cfgfile.cpp:71
unsigned int flags
Definition: tiles.h:24
void load_all_cfgs(const char *cfgname, const char *taglist, void(*loadentry)(const Package *, Clib::ConfigElem &))
Definition: pkg.cpp:473
unsigned short remove_ushort(const char *propname)
Definition: cfgfile.cpp:318
#define ERROR_PRINT
Definition: logfacility.h:230
#define passert_always(exp)
Definition: passert.h:80
Definition: berror.cpp:12
unsigned int readflags(Clib::ConfigElem &elem)
Definition: mapfunc.cpp:229