Skip to content

Commit

Permalink
Import version 89.03
Browse files Browse the repository at this point in the history
git-svn-id: svn://tron.homeunix.org/simutrans/simutrans/trunk@80 8aca7d54-2c30-db11-9de9-000461428c89
  • Loading branch information
chmallon committed Aug 20, 2006
1 parent b6c02cb commit e3525b3
Show file tree
Hide file tree
Showing 58 changed files with 626 additions and 2,094 deletions.
18 changes: 9 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,15 @@ SOURCES += gui/stadt_info.cc
SOURCES += gui/thing_info.cc
SOURCES += gui/welt.cc
SOURCES += gui/werkzeug_parameter_waehler.cc
SOURCES += sucher/platzsucher.cc
SOURCES += tpl/debug_helper.cc
SOURCES += tpl/no_such_element_exception.cc
SOURCES += utils/cstring_t.cc
SOURCES += utils/cbuffer_t.cc
SOURCES += utils/log.cc
SOURCES += utils/searchfolder.cc
SOURCES += utils/simstring.c
SOURCES += utils/tocstring.cc
SOURCES += freight_list_sorter.cc
SOURCES += old_blockmanager.cc
SOURCES += simcity.cc
Expand Down Expand Up @@ -266,15 +275,6 @@ SOURCES += simware.cc
SOURCES += simwerkz.cc
SOURCES += simwin.cc
SOURCES += simworld.cc
SOURCES += sucher/platzsucher.cc
SOURCES += tpl/debug_helper.cc
SOURCES += tpl/no_such_element_exception.cc
SOURCES += utils/cstring_t.cc
SOURCES += utils/cbuffer_t.cc
SOURCES += utils/log.cc
SOURCES += utils/searchfolder.cc
SOURCES += utils/simstring.c
SOURCES += utils/tocstring.cc


SOURCES += simgraph$(COLOUR_DEPTH).c
Expand Down
15 changes: 4 additions & 11 deletions bauer/fabrikbauer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -313,9 +313,6 @@ fabrikbauer_t::verteile_tourist(karte_t * welt, spieler_t *, int max_number)
// stuff for the progress bar
const int groesse=welt->gib_groesse_y(); // only used for progrss bar!!!
const int staedte = welt->gib_einstellungen()->gib_anzahl_staedte();
const int display_offset = (5*groesse)/6 + staedte*12;
const int display_part = groesse/6;
const int display_total = groesse+staedte*12;
// current count
int current_number=0;

Expand All @@ -325,6 +322,7 @@ fabrikbauer_t::verteile_tourist(karte_t * welt, spieler_t *, int max_number)
return;
}

// very fast, so we do not bother updating progress bar
print("Distributing %i tourist attractions ...\n",max_number);fflush(NULL);

// try to built 25% city consumer (if there)
Expand All @@ -345,10 +343,6 @@ fabrikbauer_t::verteile_tourist(karte_t * welt, spieler_t *, int max_number)
current_number ++;
}

if(is_display_init()) {
display_progress(display_offset + (display_part *current_number)/max_number, display_total);
display_flush(IMG_LEER,0, 0, 0, "", "", 0, 0);
}
}
// update an open map
reliefkarte_t::gib_karte()->calc_map();
Expand All @@ -365,9 +359,8 @@ fabrikbauer_t::verteile_industrie(karte_t * welt, spieler_t *, int max_number_of
// stuff for the progress bar
const int groesse = welt->gib_groesse_y(); // only for progress bar!!!
const int staedte = welt->gib_einstellungen()->gib_anzahl_staedte();
const int display_offset = ( (in_city?4:3)*groesse )/6 + staedte*12;
const int display_part = groesse/6;
const int display_total = groesse+staedte*12;
const int display_offset = 16 + welt->gib_einstellungen()->gib_anzahl_staedte()*4 + (in_city? welt->gib_einstellungen()->gib_land_industry_chains() : 0);
const int display_total = 16 + welt->gib_einstellungen()->gib_anzahl_staedte()*4 + welt->gib_einstellungen()->gib_land_industry_chains() + welt->gib_einstellungen()->gib_city_industry_chains();
// current count
int factory_number=0;
int current_number=0;
Expand All @@ -394,7 +387,7 @@ fabrikbauer_t::verteile_industrie(karte_t * welt, spieler_t *, int max_number_of
}

if(is_display_init()) {
display_progress(display_offset + (display_part *current_number)/max_number_of_factories, display_total);
display_progress(display_offset + current_number, display_total);
display_flush(IMG_LEER,0, 0, 0, "", "", 0, 0);
}
}
Expand Down
42 changes: 33 additions & 9 deletions bauer/warenbauer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,19 @@
#include "../besch/spezial_obj_tpl.h"
#include "warenbauer.h"


stringhashtable_tpl<const ware_besch_t *> warenbauer_t::besch_names;

slist_tpl<const ware_besch_t *> warenbauer_t::waren;
slist_tpl<ware_besch_t *> warenbauer_t::waren;

const ware_besch_t *warenbauer_t::passagiere = NULL;
const ware_besch_t *warenbauer_t::post = NULL;
const ware_besch_t *warenbauer_t::nichts = NULL;

ware_besch_t *warenbauer_t::load_passagiere = NULL;
ware_besch_t *warenbauer_t::load_post = NULL;
ware_besch_t *warenbauer_t::load_nichts = NULL;

static spezial_obj_tpl<ware_besch_t> spezial_objekte[] = {
{ &warenbauer_t::passagiere, "Passagiere" },
{ &warenbauer_t::post, "Post" },
Expand All @@ -37,47 +42,53 @@ bool warenbauer_t::alles_geladen()
* Put special items in front:
* Volker Meyer
*/
waren.insert(post);
waren.insert(passagiere);
waren.insert(nichts);
waren.insert(load_post);
waren.insert(load_passagiere);
waren.insert(load_nichts);
return true;
}


bool warenbauer_t::register_besch(ware_besch_t *besch)
{
besch->value = besch->base_value;
::register_besch(spezial_objekte, besch);
besch_names.put(besch->gib_name(), const_cast<ware_besch_t *>(besch));

if(besch==passagiere) {
besch->ware_index = 0;
load_passagiere = besch;
} else if(besch==post) {
besch->ware_index = 1;
load_post = besch;
} else if(besch != nichts) {
besch->ware_index = waren.count()+2;
waren.append(besch);
}
else {
load_nichts = besch;
besch->ware_index = 2;
}
return true;
}





const ware_besch_t *warenbauer_t::gib_info(const char* name)
const ware_besch_t *
warenbauer_t::gib_info(const char* name)
{
const ware_besch_t *t = (const ware_besch_t *)besch_names.get(name);

if(t == NULL) {
dbg->error("warenbauer_t::gib_info()", "No info for good '%s' available", name);
}

return t;
}



const ware_besch_t *warenbauer_t::gib_info_catg(const sint8 catg)
const ware_besch_t *
warenbauer_t::gib_info_catg(const sint8 catg)
{
if(catg>0) {
for(unsigned i=0; i<gib_waren_anzahl(); i++ ) {
Expand All @@ -89,3 +100,16 @@ const ware_besch_t *warenbauer_t::gib_info_catg(const sint8 catg)
dbg->warning("warenbauer_t::gib_info()", "No info for good catg %d available, set to passengers", catg);
return waren.at(0);
}



// adjuster for dummies ...
void
warenbauer_t::set_multiplier(sint32 multiplier)
{
//DBG_MESSAGE("warenbauer_t::set_multiplier()","new factor %i",multiplier);
for(unsigned i=0; i<gib_waren_anzahl(); i++ ) {
sint32 long_base_value = waren.at(i)->base_value;
waren.at(i)->value = (uint16)((long_base_value*multiplier)/1000l);
}
}
93 changes: 49 additions & 44 deletions bauer/warenbauer.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,54 +26,59 @@ class ware_besch_t;
*/
class warenbauer_t
{
private:

static stringhashtable_tpl<const ware_besch_t *> besch_names;

static slist_tpl<const ware_besch_t *> waren;

public:

static const ware_besch_t *passagiere;
static const ware_besch_t *post;
static const ware_besch_t *nichts;

static bool alles_geladen();
static bool register_besch(ware_besch_t *besch);

/**
* Sucht information zur ware 'name' und gibt die
* Beschreibung davon zurück. Gibt NULL zurück wenn die
* Ware nicht bekannt ist.
*
* @param name der nicht-übersetzte Warenname
* @author Hj. Malthaner/V. Meyer
*/
static const ware_besch_t *gib_info(const char* name);

static const ware_besch_t *gib_info(unsigned int idx) {
return waren.at(idx);
}

static bool ist_fabrik_ware(const ware_besch_t *ware)
{
return ware != post && ware != passagiere && ware != nichts;
}

static int gib_index(const ware_besch_t *ware)
{
return ware->gib_index();
// return waren.index_of(ware);
}

static unsigned int gib_waren_anzahl()
{
return waren.count();
}
private:
static stringhashtable_tpl<const ware_besch_t *> besch_names;
static slist_tpl<ware_besch_t *> waren;

static ware_besch_t *load_passagiere;
static ware_besch_t *load_post;
static ware_besch_t *load_nichts;

public:
static const ware_besch_t *passagiere;
static const ware_besch_t *post;
static const ware_besch_t *nichts;

static bool alles_geladen();
static bool register_besch(ware_besch_t *besch);
/**
* Sucht information zur ware 'name' und gibt die
* Beschreibung davon zurück. Gibt NULL zurück wenn die
* Ware nicht bekannt ist.
*
* @param name der nicht-übersetzte Warenname
* @author Hj. Malthaner/V. Meyer
*/
static const ware_besch_t *gib_info(const char* name);

static const ware_besch_t *gib_info(unsigned int idx)
{
return waren.at(idx);
}

static bool ist_fabrik_ware(const ware_besch_t *ware)
{
return ware != post && ware != passagiere && ware != nichts;
}

static int gib_index(const ware_besch_t *ware)
{
return ware->gib_index();
}

static unsigned int gib_waren_anzahl()
{
return waren.count();
}

// ware by catg
static const ware_besch_t *gib_info_catg(const sint8 catg);

/*
* allow to multiply all prices, 1000=1.0
* used for the beginner mode
*/
static void set_multiplier(sint32 multiplier);
};

#endif // warenbauer_t_h
2 changes: 1 addition & 1 deletion besch/reader/building_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
class tile_reader_t : public obj_reader_t {
static tile_reader_t the_instance;

tile_reader_t() { register_reader(); }
tile_reader_t() { register_reader(); }
public:
static tile_reader_t*instance() { return &the_instance; }

Expand Down
2 changes: 1 addition & 1 deletion besch/reader/factory_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
class factory_smoke_reader_t : public obj_reader_t {
static factory_smoke_reader_t the_instance;

factory_smoke_reader_t() { register_reader(); }
factory_smoke_reader_t() { register_reader(); }
protected:
virtual void register_obj(obj_besch_t *&data);
public:
Expand Down
6 changes: 3 additions & 3 deletions besch/reader/good_reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -131,23 +131,23 @@ obj_besch_t * good_reader_t::read_node(FILE *fp, obj_node_info_t &node)
if(version == 1) {
// Versioned node, version 1

besch->value = decode_uint16(p);
besch->base_value = decode_uint16(p);
besch->catg = decode_uint16(p);
besch->speed_bonus = decode_uint16(p);
besch->weight_per_unit = 100;

} else if(version == 2) {
// Versioned node, version 2

besch->value = decode_uint16(p);
besch->base_value = decode_uint16(p);
besch->catg = decode_uint16(p);
besch->speed_bonus = decode_uint16(p);
besch->weight_per_unit = decode_uint16(p);

} else {
// old node, version 0

besch->value = v;
besch->base_value = v;
besch->catg = decode_uint16(p);
besch->speed_bonus = 0;
besch->weight_per_unit = 100;
Expand Down
1 change: 1 addition & 0 deletions besch/reader/good_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class good_reader_t : public obj_reader_t {
static good_reader_t the_instance;

good_reader_t() { register_reader(); }
virtual ~good_reader_t() {}
protected:
virtual void register_obj(obj_besch_t *&data);
virtual bool successfully_loaded() const;
Expand Down
8 changes: 5 additions & 3 deletions besch/reader/obj_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,12 @@ class obj_reader_t {

void register_reader();
public:
virtual obj_type get_type() const = 0;
virtual const char *get_type_name() const = 0;
virtual ~obj_reader_t() {}

static bool init(const char *liste);
virtual obj_type get_type() const = 0;
virtual const char *get_type_name() const = 0;

static bool init(const char *liste);
};

#endif // __OBJ_READER_H
3 changes: 2 additions & 1 deletion besch/reader/sound_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@
class sound_reader_t : public obj_reader_t {
static sound_reader_t the_instance;

sound_reader_t() { register_reader(); }
sound_reader_t() { register_reader(); }
virtual ~sound_reader_t() {}
protected:
virtual void register_obj(obj_besch_t *&data);
virtual bool successfully_loaded() const;
Expand Down
1 change: 1 addition & 0 deletions besch/reader/xref_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class xref_reader_t : public obj_reader_t {
static xref_reader_t the_instance;

xref_reader_t() { register_reader(); }
virtual ~xref_reader_t() {}
protected:
virtual void register_obj(obj_besch_t *&data);
public:
Expand Down
Loading

0 comments on commit e3525b3

Please sign in to comment.