Commit 8cf9707a authored by Ansgar's avatar Ansgar

Imported Upstream version 102.2.1~ds1

parent 10b73182
......@@ -25,7 +25,7 @@ endif
ifeq ($(OSTYPE),beos)
STD_LIBS ?= -lz
STD_LIBS ?= -lz -lnet
endif
ifeq ($(OSTYPE),freebsd)
......@@ -57,7 +57,7 @@ ifeq ($(OSTYPE),mingw)
ifeq ($(BACKEND),gdi)
STD_LIBS += -lunicows
endif
STD_LIBS += -lmingw32 -lgdi32 -lwinmm
STD_LIBS += -lmingw32 -lgdi32 -lwinmm -lwsock32
endif
ALLEGRO_CONFIG ?= allegro-config
......@@ -99,6 +99,7 @@ endif
ifneq ($(PROFILE),)
CFLAGS += -pg -DPROFILE -fno-inline
CXXFLAGS += -pg -DPROFILE -fno-inline
LDFLAGS += -pg
endif
CFLAGS += -Wall -W -Wcast-qual -Wpointer-arith -Wcast-align -Wstrict-prototypes $(OS_INC) $(OS_OPT) $(FLAGS)
......@@ -168,6 +169,7 @@ SOURCES += dataobj/koord.cc
SOURCES += dataobj/koord3d.cc
SOURCES += dataobj/loadsave.cc
SOURCES += dataobj/marker.cc
SOURCES += dataobj/network.cc
SOURCES += dataobj/powernet.cc
SOURCES += dataobj/ribi.cc
SOURCES += dataobj/route.cc
......
......@@ -65,7 +65,7 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="kernel32.lib user32.lib gdi32.lib winmm.lib zlibstat.lib advapi32.lib $(NOINHERIT)"
AdditionalDependencies="kernel32.lib user32.lib gdi32.lib winmm.lib zlibstat.lib advapi32.lib wsock32.lib $(NOINHERIT)"
LinkIncremental="2"
AdditionalLibraryDirectories="&quot;G:\Program Files\PlatformSDK\Lib&quot;;G:\Projects\zlib\lib"
IgnoreAllDefaultLibraries="false"
......@@ -144,7 +144,7 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="kernel32.lib user32.lib gdi32.lib winmm.lib zlibstat.lib advapi32.lib $(NOINHERIT)"
AdditionalDependencies="kernel32.lib user32.lib gdi32.lib winmm.lib zlibstat.lib advapi32.lib wsock32.lib $(NOINHERIT)"
LinkIncremental="1"
AdditionalLibraryDirectories="&quot;G:\Program Files\PlatformSDK\Lib&quot;;G:\Projects\zlib\lib"
IgnoreDefaultLibraryNames="libcmt.lib"
......@@ -660,6 +660,10 @@
RelativePath=".\boden\wege\narrowgauge.cc"
>
</File>
<File
RelativePath=".\dataobj\network.cc"
>
</File>
<File
RelativePath=".\besch\reader\obj_reader.cc"
>
......
......@@ -30,6 +30,7 @@
#include "../gui/messagebox.h"
#include "../gui/werkzeug_waehler.h"
#include "../gui/karte.h"
#include "../besch/bruecke_besch.h"
#include "../besch/skin_besch.h"
......@@ -52,12 +53,21 @@ static stringhashtable_tpl<const bruecke_besch_t *> bruecken_by_name;
* Registers a new bridge type
* @author V. Meyer, Hj. Malthaner
*/
void brueckenbauer_t::register_besch(const bruecke_besch_t *besch)
void brueckenbauer_t::register_besch(bruecke_besch_t *besch)
{
// avoid duplicates with same name
if( bruecken_by_name.remove(besch->get_name()) ) {
dbg->warning( "brueckenbauer_t::register_besch()", "Object %s was overlaid by addon!", besch->get_name() );
}
// add the tool
wkz_brueckenbau_t *wkz = new wkz_brueckenbau_t();
wkz->set_icon( besch->get_cursor()->get_bild_nr(1) );
wkz->cursor = besch->get_cursor()->get_bild_nr(0);
wkz->default_param = besch->get_name();
wkz->id = werkzeug_t::general_tool.get_count()|GENERAL_TOOL;
werkzeug_t::general_tool.append( wkz );
besch->set_builder( wkz );
bruecken_by_name.put(besch->get_name(), besch);
}
......@@ -104,8 +114,7 @@ bool brueckenbauer_t::laden_erfolgreich()
* Find a matchin bridge
* @author Hj. Malthaner
*/
const bruecke_besch_t *
brueckenbauer_t::find_bridge(const waytype_t wtyp, const uint32 min_speed,const uint16 time)
const bruecke_besch_t *brueckenbauer_t::find_bridge(const waytype_t wtyp, const uint32 min_speed,const uint16 time)
{
const bruecke_besch_t *find_besch=NULL;
......@@ -159,18 +168,7 @@ void brueckenbauer_t::fill_menu(werkzeug_waehler_t *wzw, const waytype_t wtyp, s
// now sorted ...
for (vector_tpl<const bruecke_besch_t*>::const_iterator i = matching.begin(), end = matching.end(); i != end; ++i) {
const bruecke_besch_t* besch = *i;
wkz_brueckenbau_t *wkz = bruecken_tool.get(besch->get_name());
if(wkz==NULL) {
// not yet in hashtable
wkz = new wkz_brueckenbau_t();
wkz->set_icon( besch->get_cursor()->get_bild_nr(1) );
wkz->cursor = besch->get_cursor()->get_bild_nr(0);
wkz->default_param = besch->get_name();
wkz->ok_sound = sound_ok;
bruecken_tool.put(besch->get_name(),wkz);
}
wzw->add_werkzeug( (werkzeug_t*)wkz );
wzw->add_werkzeug( (*i)->get_builder() );
}
}
......@@ -614,8 +612,10 @@ const char *brueckenbauer_t::remove(karte_t *welt, spieler_t *sp, koord3d pos, w
// search neighbors
for(int r = 0; r < 4; r++) {
if( (zv == koord::invalid || zv == koord::nsow[r]) && from->get_neighbour(to, delete_wegtyp, koord::nsow[r]) && !marker.ist_markiert(to) && to->ist_bruecke() ) {
tmp_list.insert(to->get_pos());
marker.markiere(to);
if( wegtyp != powerline_wt || to->find<bruecke_t>()->get_besch()->get_waytype() == powerline_wt ) {
tmp_list.insert(to->get_pos());
marker.markiere(to);
}
}
}
} while (!tmp_list.empty());
......@@ -650,6 +650,8 @@ const char *brueckenbauer_t::remove(karte_t *welt, spieler_t *sp, koord3d pos, w
p->entferne(p->get_besitzer());
delete p;
}
// refresh map
reliefkarte_t::get_karte()->calc_map_pixel(pos.get_2d());
}
// finally delete the bridge ends
while (!end_list.empty()) {
......@@ -657,7 +659,6 @@ const char *brueckenbauer_t::remove(karte_t *welt, spieler_t *sp, koord3d pos, w
grund_t *gr = welt->lookup(pos);
if(wegtyp==powerline_wt) {
gr->get_leitung()->calc_bild();
ding_t *br;
while ((br = gr->find<bruecke_t>()) != 0) {
br->entferne(sp);
......@@ -699,7 +700,11 @@ const char *brueckenbauer_t::remove(karte_t *welt, spieler_t *sp, koord3d pos, w
// then add the new ground, copy everything and replace the old one
grund_t *gr_new = new boden_t(welt, pos, gr->get_grund_hang());
gr_new->take_obj_from( gr );
welt->access(pos.get_2d())->kartenboden_setzen(gr_new );
welt->access(pos.get_2d())->kartenboden_setzen( gr_new );
if( wegtyp == powerline_wt ) {
gr_new->get_leitung()->calc_neighbourhood(); // Recalc the image. calc_bild() doesn't do the right job...
}
}
welt->set_dirty();
......
......@@ -59,7 +59,7 @@ public:
* Registers a new bridge type
* @author V. Meyer, Hj. Malthaner
*/
static void register_besch(const bruecke_besch_t *besch);
static void register_besch(bruecke_besch_t *besch);
static bool laden_erfolgreich();
......
......@@ -167,13 +167,40 @@ bool hausbauer_t::alles_geladen()
}
bool hausbauer_t::register_besch(const haus_besch_t *besch)
bool hausbauer_t::register_besch(haus_besch_t *besch)
{
::register_besch(spezial_objekte, besch);
// avoid duplicates with same name
if(besch_names.remove(besch->get_name())) {
const haus_besch_t *old_besch = besch_names.get(besch->get_name());
if(old_besch) {
dbg->warning( "hausbauer_t::register_besch()", "Object %s was overlaid by addon!", besch->get_name() );
besch_names.remove(besch->get_name());
delete old_besch->get_builder();
delete old_besch;
}
// probably need a tools, if it has a cursor
const skin_besch_t *sb = besch->get_cursor();
if( sb && sb->get_bild_nr(1)!=IMG_LEER) {
werkzeug_t *wkz;
if( besch->get_utyp()==haus_besch_t::depot ) {
wkz = new wkz_depot_t();
}
else if( besch->get_utyp()==haus_besch_t::firmensitz ) {
wkz = new wkz_headquarter_t();
}
else {
wkz = new wkz_station_t();
}
wkz->set_icon( besch->get_cursor()->get_bild_nr(1) );
wkz->cursor = besch->get_cursor()->get_bild_nr(0),
wkz->default_param = besch->get_name();
wkz->id = werkzeug_t::general_tool.get_count()|GENERAL_TOOL;
werkzeug_t::general_tool.append( wkz );
besch->set_builder( wkz );
}
else {
besch->set_builder( NULL );
}
besch_names.put(besch->get_name(), besch);
......@@ -203,35 +230,9 @@ DBG_DEBUG("hausbauer_t::fill_menu()","maximum %i",station_building.get_count());
for( vector_tpl<const haus_besch_t *>::const_iterator iter = station_building.begin(), end = station_building.end(); iter != end; ++iter ) {
const haus_besch_t* besch = (*iter);
// DBG_DEBUG("hausbauer_t::fill_menu()", "try to add %s (%p)", besch->get_name(), besch);
if( besch->get_utyp()==utyp && besch->get_cursor()->get_bild_nr(1) != IMG_LEER && besch->get_extra()==(uint16)wt ) {
if( besch->get_utyp()==utyp && besch->get_builder() && (utyp==haus_besch_t::firmensitz || besch->get_extra()==(uint16)wt) ) {
if(time==0 || (besch->get_intro_year_month()<=time && besch->get_retire_year_month()>time)) {
if(utyp==haus_besch_t::depot) {
wkz_depot_t *wkz = depot_tool.get(besch->get_name());
if(wkz==NULL) {
// not yet in hashtable
wkz = new wkz_depot_t();
wkz->set_icon( besch->get_cursor()->get_bild_nr(1) );
wkz->cursor = besch->get_cursor()->get_bild_nr(0);
wkz->default_param = besch->get_name();
wkz->ok_sound = sound_ok;
depot_tool.put(besch->get_name(),wkz);
}
wzw->add_werkzeug( (werkzeug_t*)wkz );
}
else {
wkz_station_t *wkz = station_tool.get(besch->get_name());
if(wkz==NULL) {
// not yet in hashtable
wkz = new wkz_station_t();
wkz->set_icon( besch->get_cursor()->get_bild_nr(1) );
wkz->cursor = besch->get_cursor()->get_bild_nr(0),
wkz->default_param = besch->get_name();
wkz->ok_sound = sound_ok;
station_tool.put(besch->get_name(),wkz);
}
wzw->add_werkzeug( (werkzeug_t*)wkz );
}
wzw->add_werkzeug( besch->get_builder() );
}
}
}
......
......@@ -62,7 +62,7 @@ public:
static const haus_tile_besch_t* find_tile(const char* name, int idx);
static bool register_besch(const haus_besch_t *besch);
static bool register_besch(haus_besch_t *besch);
static bool alles_geladen();
/* Fill menu with icons of buildings of a given type
......
......@@ -55,14 +55,21 @@ void tunnelbauer_t::register_besch(tunnel_besch_t *besch)
if( tunnel_by_name.remove(besch->get_name()) ) {
dbg->warning( "tunnelbauer_t::register_besch()", "Object %s was overlaid by addon!", besch->get_name() );
}
// add the tool
wkz_tunnelbau_t *wkz = new wkz_tunnelbau_t();
wkz->set_icon( besch->get_cursor()->get_bild_nr(1) );
wkz->cursor = besch->get_cursor()->get_bild_nr(0);
wkz->default_param = besch->get_name();
wkz->id = werkzeug_t::general_tool.get_count()|GENERAL_TOOL;
werkzeug_t::general_tool.append( wkz );
besch->set_builder( wkz );
tunnel_by_name.put(besch->get_name(), besch);
}
// now we have to convert old tunnel to new ones ...
bool
tunnelbauer_t::laden_erfolgreich()
bool tunnelbauer_t::laden_erfolgreich()
{
stringhashtable_iterator_tpl<tunnel_besch_t *>iter(tunnel_by_name);
while( iter.next() ) {
......@@ -93,8 +100,7 @@ tunnelbauer_t::laden_erfolgreich()
const tunnel_besch_t *
tunnelbauer_t::get_besch(const char *name)
const tunnel_besch_t *tunnelbauer_t::get_besch(const char *name)
{
return tunnel_by_name.get(name);
}
......@@ -105,8 +111,7 @@ tunnelbauer_t::get_besch(const char *name)
* Find a matchin tunnel
* @author Hj. Malthaner
*/
const tunnel_besch_t *
tunnelbauer_t::find_tunnel(const waytype_t wtyp, const uint32 min_speed,const uint16 time)
const tunnel_besch_t *tunnelbauer_t::find_tunnel(const waytype_t wtyp, const uint32 min_speed,const uint16 time)
{
const tunnel_besch_t *find_besch=NULL;
......@@ -148,8 +153,6 @@ static bool compare_tunnels(const tunnel_besch_t* a, const tunnel_besch_t* b)
*/
void tunnelbauer_t::fill_menu(werkzeug_waehler_t* wzw, const waytype_t wtyp, sint16 sound_ok, const karte_t* welt)
{
static stringhashtable_tpl<wkz_tunnelbau_t *> tunnel_tool;
const uint16 time=welt->get_timeline_year_month();
vector_tpl<const tunnel_besch_t*> matching(tunnel_by_name.get_count());
......@@ -167,18 +170,7 @@ void tunnelbauer_t::fill_menu(werkzeug_waehler_t* wzw, const waytype_t wtyp, sin
// now sorted ...
for (vector_tpl<const tunnel_besch_t*>::const_iterator i = matching.begin(), end = matching.end(); i != end; ++i) {
const tunnel_besch_t* besch = *i;
wkz_tunnelbau_t *wkz = tunnel_tool.get(besch->get_name());
if(wkz==NULL) {
// not yet in hashtable
wkz = new wkz_tunnelbau_t();
wkz->set_icon( besch->get_cursor()->get_bild_nr(1) );
wkz->cursor = besch->get_cursor()->get_bild_nr(0);
wkz->default_param = besch->get_name();
wkz->ok_sound = sound_ok;
tunnel_tool.put(besch->get_name(),wkz);
}
wzw->add_werkzeug( (werkzeug_t*)wkz );
wzw->add_werkzeug( (*i)->get_builder() );
}
}
......@@ -482,8 +474,9 @@ tunnelbauer_t::remove(karte_t *welt, spieler_t *sp, koord3d start, waytype_t weg
gr->obj_loesche_alle(sp);
welt->access(pos.get_2d())->boden_entfernen(gr);
welt->access(pos.get_2d())->get_kartenboden()->set_flag(grund_t::dirty);
reliefkarte_t::get_karte()->calc_map_pixel( pos.get_2d() );
delete gr;
reliefkarte_t::get_karte()->calc_map_pixel( pos.get_2d() );
}
// Und die Tunnelenden am Schlu
......
......@@ -36,8 +36,7 @@ static spezial_obj_tpl<ware_besch_t> spezial_objekte[] = {
bool
warenbauer_t::alles_geladen()
bool warenbauer_t::alles_geladen()
{
if(!::alles_geladen(spezial_objekte)) {
return false;
......
......@@ -103,22 +103,39 @@ bool wegbauer_t::alle_wege_geladen()
maglev_t::default_maglev = wegbauer_t::weg_search(maglev_wt,1,0,weg_t::type_flat);
narrowgauge_t::default_narrowgauge = wegbauer_t::weg_search(narrowgauge_wt,1,0,weg_t::type_flat);
kanal_t::default_kanal = wegbauer_t::weg_search(water_wt,1,0,weg_t::type_flat);
if( kanal_t::default_kanal==0 ) {
// find also hidden rivers ...
kanal_t::default_kanal = wegbauer_t::weg_search(water_wt,0,0,weg_t::type_all);
}
runway_t::default_runway = wegbauer_t::weg_search(air_wt,1,0,weg_t::type_flat);
wegbauer_t::leitung_besch = wegbauer_t::weg_search(powerline_wt,1,0,weg_t::type_flat);
return true;
}
bool wegbauer_t::register_besch(const weg_besch_t *besch)
bool wegbauer_t::register_besch(weg_besch_t *besch)
{
#ifdef DEBUG
DBG_DEBUG("wegbauer_t::register_besch()", besch->get_name());
if( besch->has_switch_bild() ) {
DBG_DEBUG("wegbauer_t::register_besch()", "with switches" );
}
#endif
if( alle_wegtypen.remove(besch->get_name()) ) {
const weg_besch_t *old_besch = alle_wegtypen.get(besch->get_name());
if( old_besch ) {
alle_wegtypen.remove(besch->get_name());
dbg->warning( "wegbauer_t::register_besch()", "Object %s was overlaid by addon!", besch->get_name() );
delete old_besch->get_builder();
delete old_besch;
}
if( besch->get_cursor()->get_bild_nr(1)!=IMG_LEER ) {
// add the tool
wkz_wegebau_t *wkz = new wkz_wegebau_t();
wkz->set_icon( besch->get_cursor()->get_bild_nr(1) );
wkz->cursor = besch->get_cursor()->get_bild_nr(0);
wkz->default_param = besch->get_name();
wkz->id = werkzeug_t::general_tool.get_count()|GENERAL_TOOL;
werkzeug_t::general_tool.append( wkz );
besch->set_builder( wkz );
}
else {
besch->set_builder( NULL );
}
alle_wegtypen.put(besch->get_name(), besch);
return true;
......@@ -238,7 +255,6 @@ static bool compare_ways(const weg_besch_t* a, const weg_besch_t* b)
*/
void wegbauer_t::fill_menu(werkzeug_waehler_t *wzw, const waytype_t wtyp, const weg_t::system_type styp, sint16 ok_sound, karte_t *welt)
{
static stringhashtable_tpl<wkz_wegebau_t *> way_tool;
const uint16 time = welt->get_timeline_year_month();
// list of matching types (sorted by speed)
......@@ -249,7 +265,7 @@ void wegbauer_t::fill_menu(werkzeug_waehler_t *wzw, const waytype_t wtyp, const
const weg_besch_t* besch = iter.get_current_value();
if (besch->get_styp() == styp &&
besch->get_wtyp() == wtyp &&
besch->get_cursor()->get_bild_nr(1) != IMG_LEER && (
besch->get_builder() && (
time == 0 ||
(besch->get_intro_year_month() <= time && time < besch->get_retire_year_month())
)) {
......@@ -260,18 +276,7 @@ void wegbauer_t::fill_menu(werkzeug_waehler_t *wzw, const waytype_t wtyp, const
// now add sorted ways ...
for (vector_tpl<const weg_besch_t*>::const_iterator i = matching.begin(), end = matching.end(); i != end; ++i) {
const weg_besch_t* besch = *i;
wkz_wegebau_t *wkz = way_tool.get(besch->get_name());
if(wkz==NULL) {
// not yet in hashtable
wkz = new wkz_wegebau_t();
wkz->set_icon( besch->get_cursor()->get_bild_nr(1) );
wkz->cursor = besch->get_cursor()->get_bild_nr(0);
wkz->default_param = besch->get_name();
wkz->ok_sound = ok_sound;
way_tool.put(besch->get_name(),wkz);
}
wzw->add_werkzeug( (werkzeug_t*)wkz );
wzw->add_werkzeug( (*i)->get_builder() );
}
}
......@@ -281,8 +286,7 @@ void wegbauer_t::fill_menu(werkzeug_waehler_t *wzw, const waytype_t wtyp, const
/* allow for railroad crossing
* @author prissi
*/
bool
wegbauer_t::check_crossing(const koord zv, const grund_t *bd, waytype_t wtyp0, const spieler_t *sp) const
bool wegbauer_t::check_crossing(const koord zv, const grund_t *bd, waytype_t wtyp0, const spieler_t *sp) const
{
const waytype_t wtyp = wtyp0==tram_wt ? track_wt : wtyp0;
// nothing to cross here
......@@ -1919,10 +1923,11 @@ void wegbauer_t::baue_strasse()
// we take ownership => we take care to maintain the roads completely ...
spieler_t *s = weg->get_besitzer();
spieler_t::add_maintenance(s, -weg->get_besch()->get_wartung());
// cost is the more expensive one, so downgrading is between removing and new buidling
cost -= max( weg->get_besch()->get_preis(), besch->get_preis() );
weg->set_besch(besch);
spieler_t::add_maintenance( sp, weg->get_besch()->get_wartung());
weg->set_besitzer(sp);
cost -= besch->get_preis();
}
}
else {
......@@ -1983,10 +1988,11 @@ void wegbauer_t::baue_schiene()
// we take ownership => we take care to maintain the roads completely ...
spieler_t *s = weg->get_besitzer();
spieler_t::add_maintenance( s, -weg->get_besch()->get_wartung());
// cost is the more expensive one, so downgrading is between removing and new buidling
cost -= max( weg->get_besch()->get_preis(), besch->get_preis() );
weg->set_besch(besch);
spieler_t::add_maintenance( sp, weg->get_besch()->get_wartung());
weg->set_besitzer(sp);
cost -= besch->get_preis();
}
}
else {
......@@ -2014,8 +2020,7 @@ void wegbauer_t::baue_schiene()
void
wegbauer_t::baue_leitung()
void wegbauer_t::baue_leitung()
{
if( get_count() < 1 ) {
return;
......@@ -2044,7 +2049,7 @@ wegbauer_t::baue_leitung()
else {
spieler_t::add_maintenance( lt->get_besitzer(), -wegbauer_t::leitung_besch->get_wartung() );
}
lt->laden_abschliessen();
lt->leitung_t::laden_abschliessen();
if((i&3)==0) {
INT_CHECK( "wegbauer 1584" );
......@@ -2066,8 +2071,7 @@ class fluss_fahrer_t : fahrer_t
// make a river
void
wegbauer_t::baue_fluss()
void wegbauer_t::baue_fluss()
{
/* since the contraits of the wayfinder ensures that a river flows always downwards
* we can assume that the first tiles are the ocean.
......@@ -2157,8 +2161,7 @@ wegbauer_t::baue_fluss()
void
wegbauer_t::baue()
void wegbauer_t::baue()
{
if(get_count()<2 || get_count() > maximum) {
DBG_MESSAGE("wegbauer_t::baue()","called, but no valid route.");
......@@ -2217,6 +2220,8 @@ DBG_MESSAGE("wegbauer_t::baue", "took %i ms",dr_time()-ms);
#endif
}
/*
* This function calculates the distance of pos to the cuboid
* spanned up by mini and maxi.
......
......@@ -34,7 +34,7 @@ class wegbauer_t
public:
static const weg_besch_t *leitung_besch;
static bool register_besch(const weg_besch_t *besch);
static bool register_besch(weg_besch_t *besch);
static bool alle_wege_geladen();
// generates timeline message
......
......@@ -23,6 +23,8 @@
#include "../dataobj/ribi.h"
class werkzeug_t;
class bruecke_besch_t : public obj_besch_std_name_t {
friend class bridge_writer_t;
......@@ -53,6 +55,9 @@ private:
/* number of seasons (0 = none, 1 = no snow/snow
*/
sint8 number_seasons;
werkzeug_t *builder;
public:
/*
* Nummerierung all der verschiedenen Schienstcke
......@@ -143,6 +148,14 @@ public:
* @author prissi
*/
int get_retire_year_month() const { return obsolete_date; }
// default tool for building
werkzeug_t *get_builder() const {
return builder;
}
void set_builder( werkzeug_t *w ) {
builder = w;
}
};
#endif
......@@ -15,6 +15,7 @@
class haus_besch_t;
class skin_besch_t;
class werkzeug_t;
/*
* Autor:
......@@ -161,9 +162,10 @@ class haus_besch_t : public obj_besch_std_name_t { // Daten f
private:
enum flag_t {
FLAG_NULL = 0,
FLAG_KEINE_INFO = 1, // was flag FLAG_ZEIGE_INFO
FLAG_KEINE_GRUBE = 2 , // Baugrube oder nicht?
FLAG_NEED_GROUND = 4 // draw ground below
FLAG_KEINE_INFO = 1, // was flag FLAG_ZEIGE_INFO
FLAG_KEINE_GRUBE = 2, // Baugrube oder nicht?
FLAG_NEED_GROUND = 4, // draw ground below
FLAG_HAS_CURSOR = 8 // there is cursor/icon for this
};
gebaeude_t::typ gtyp; // Hajo: this is the type of the building
......@@ -174,7 +176,7 @@ class haus_besch_t : public obj_besch_std_name_t { // Daten f
koord groesse;
flag_t flags;
uint16 level; // or passengers;
uint8 layouts; // 1 2 oder 4
uint8 layouts; // 1 2, 4, 8 or 16
uint8 enables; // if it is a stop, what is enabled ...
uint8 chance; // Hajo: chance to build, special buildings, only other is weight factor
......@@ -188,6 +190,8 @@ class haus_besch_t : public obj_besch_std_name_t { // Daten f
return gtyp == gebaeude_t::unbekannt && utype == u;
}
werkzeug_t *builder;
public:
koord get_groesse(int layout = 0) const {
......@@ -272,7 +276,9 @@ public:
* Skin: cursor (index 0) and icon (index 1)
* @author Hj. Malthaner
*/
const skin_besch_t * get_cursor() const { return (const skin_besch_t *)(get_child(2+groesse.x*groesse.y*layouts)); }
const skin_besch_t * get_cursor() const {
return flags&FLAG_HAS_CURSOR ? (const skin_besch_t *)(get_child(2+groesse.x*groesse.y*layouts)) : NULL;
}
/**
* @return introduction month
......@@ -287,14 +293,12 @@ public:
uint32 get_retire_year_month() const { return obsolete_date; }
// true if future
bool is_future (const uint16 month_now) const
{
bool is_future (const uint16 month_now) const {
return month_now && (intro_date > month_now);
}
// true if obsolete
bool is_retired (const uint16 month_now) const
{
bool is_retired (const uint16 month_now) const {
return month_now && (obsolete_date <= month_now);
}
......@@ -318,6 +322,14 @@ public:
* @author prissi
*/
uint16 get_animation_time() const { return animation_time; }
// default tool for building
werkzeug_t *get_builder() const {
return builder;
}
void set_builder( werkzeug_t *w ) {
builder = w;
}
};
#endif
......@@ -284,6 +284,10 @@ obj_besch_t * building_reader_t::read_node(FILE *fp, obj_node_info_t &node)
besch->obsolete_date = DEFAULT_RETIRE_DATE*12;
besch->animation_time = 300;
}
// there are additional nodes for cursor/icon
if( node.children > 2+besch->groesse.x*besch->groesse.y*besch->layouts ) {
besch->flags = (haus_besch_t::flag_t)((int)besch->flags | (int)haus_besch_t::FLAG_HAS_CURSOR);
}
// correct old station buildings ...
if (besch->level <= 0 && (besch->utype >= haus_besch_t::bahnhof || besch->utype == haus_besch_t::fabrik)) {
......
......@@ -17,6 +17,7 @@
class skin_besch_t;
class werkzeug_t;
/*
* Autor:
......@@ -55,6 +56,8 @@ private:
uint16 intro_date;
uint16 obsolete_date;
werkzeug_t *builder;
public:
enum types {ONE_WAY=1, FREE_ROUTE=2, PRIVATE_ROAD=4, SIGN_SIGNAL=8, SIGN_PRE_SIGNAL=16, ONLY_BACKIMAGE=32, SIGN_LONGBLOCK_SIGNAL=64, END_OF_CHOOSE_AREA=128 };
......@@ -112,6 +115,14 @@ public:
* @author prissi
*/
uint16 get_retire_year_month() const { return obsolete_date; }
// default tool for building
werkzeug_t *get_builder() const {
return builder;
}
void set_builder( werkzeug_t *w ) {
builder = w;
}
};
#endif
......@@ -47,6 +47,9 @@ private:
/* has underground way image ? ( 0 = no, 1 = yes
*/
uint8 has_way;
werkzeug_t *builder;
public: