Commit 10b73182 authored by Ansgar's avatar Ansgar

Imported Upstream version 102.2+svn2786

parent 3a3c1b0d
......@@ -2,8 +2,8 @@ CONFIG ?= config.default
-include $(CONFIG)
BACKENDS = allegro gdi sdl mixer_sdl x11
COLOUR_DEPTHS = 8 16
BACKENDS = allegro gdi sdl mixer_sdl x11 posix
COLOUR_DEPTHS = 0 8 16
OSTYPES = beos cygwin freebsd linux mingw mac
ifeq ($(findstring $(BACKEND), $(BACKENDS)),)
......@@ -50,6 +50,7 @@ ifeq ($(OSTYPE),cygwin)
endif
ifeq ($(OSTYPE),mingw)
CC ?= gcc
SOURCES += simsys_w32_png.cc
OS_OPT ?= -mno-cygwin -DPNG_STATIC -DZLIB_STATIC -march=pentium
STD_LIBS ?= -lz
......@@ -96,9 +97,8 @@ ifdef DEBUG
endif
ifneq ($(PROFILE),)
CFLAGS += -pg
CXXFLAGS += -pg
LDFLAGS += -pg
CFLAGS += -pg -DPROFILE -fno-inline
CXXFLAGS += -pg -DPROFILE -fno-inline
endif
CFLAGS += -Wall -W -Wcast-qual -Wpointer-arith -Wcast-align -Wstrict-prototypes $(OS_INC) $(OS_OPT) $(FLAGS)
......@@ -263,6 +263,8 @@ SOURCES += gui/player_frame_t.cc
SOURCES += gui/savegame_frame.cc
SOURCES += gui/scenario_frame.cc
SOURCES += gui/schedule_list.cc
SOURCES += gui/settings_frame.cc
SOURCES += gui/settings_stats.cc
SOURCES += gui/sound_frame.cc
SOURCES += gui/sprachen.cc
SOURCES += gui/stadt_info.cc
......@@ -405,6 +407,12 @@ ifeq ($(BACKEND),x11)
LIBS += -L/usr/X11R6/lib/ -lX11 -lXext
endif
ifeq ($(BACKEND),posix)
SOURCES += simsys_posix.cc
SOURCES += music/no_midi.cc
SOURCES += sound/no_sound.cc
endif
ifneq ($(findstring $(OSTYPE), cygwin mingw),)
SOURCES += simres.rc
......

Microsoft Visual Studio Solution File, Format Version 9.00
# Visual C++ Express 2005
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Simutrans", "Simutrans.vcproj", "{0621B295-BEB7-4767-82F1-F27995610323}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{0621B295-BEB7-4767-82F1-F27995610323}.Debug|Win32.ActiveCfg = Debug|Win32
{0621B295-BEB7-4767-82F1-F27995610323}.Debug|Win32.Build.0 = Debug|Win32
{0621B295-BEB7-4767-82F1-F27995610323}.Release|Win32.ActiveCfg = Release|Win32
{0621B295-BEB7-4767-82F1-F27995610323}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
This diff is collapsed.
This diff is collapsed.
......@@ -11,16 +11,13 @@
#include "../simtypes.h"
#include "../dataobj/koord.h"
#include "../dataobj/koord3d.h"
#include "../boden/wege/weg.h"
// Hajo: these are needed to build the menu entries
#include "../gui/werkzeug_waehler.h"
#include "../besch/skin_besch.h"
class bruecke_besch_t;
class grund_t;
class karte_t; // Hajo: 22-Nov-01: Added forward declaration
class spieler_t; // Hajo: 22-Nov-01: Added forward declaration
class grund_t;
class weg_besch_t;
class werkzeug_waehler_t;
/**
* Baut Brcken. Brcken sollten nicht direct instanziiert werden
......@@ -33,12 +30,16 @@ class grund_t;
class brueckenbauer_t {
private:
brueckenbauer_t() {} // private -> no instance please
public:
/*
* Grund bestimmen, auf dem die Brcke enden soll.
*
* @author V. Meyer
*/
static koord3d finde_ende(karte_t *welt, koord3d pos, koord zv, const bruecke_besch_t *besch, const char *&msg );
static koord3d finde_ende(karte_t *welt, koord3d pos, koord zv, const bruecke_besch_t *besch, const char *&msg, bool ai_bridge=false );
/*
* Brckenendpunkte bei Rampen werden auf flachem Grund gebaut und mssen daher genauer
......@@ -48,11 +49,6 @@ private:
*/
static bool ist_ende_ok(spieler_t *sp, const grund_t *gr);
brueckenbauer_t() {} // private -> no instance please
public:
// built a ramp to change level
static void baue_auffahrt(karte_t *welt, spieler_t *sp, koord3d pos, koord zv, const bruecke_besch_t *besch, const weg_besch_t *weg_besch);
......@@ -92,7 +88,7 @@ public:
* Fill menu with icons of given waytype
* @author priss
*/
static void fill_menu(werkzeug_waehler_t *wzw, const waytype_t wtyp, const karte_t *welt);
static void fill_menu(werkzeug_waehler_t *wzw, const waytype_t wtyp, sint16 sound_ok, const karte_t *welt);
};
#endif
......@@ -192,20 +192,23 @@ DBG_MESSAGE("fabrikbauer_t::get_random_consumer()","No suitable consumer found")
const fabrik_besch_t *fabrikbauer_t::get_fabesch(const char *fabtype)
{
return table.get(fabtype);
return table.get(fabtype);
}
void fabrikbauer_t::register_besch(fabrik_besch_t *besch)
{
uint16 p=besch->get_produktivitaet();
if(p&0x8000) {
koord k=besch->get_haus()->get_groesse();
// to be compatible with old factories, since new code only steps once per factory, not per tile
besch->set_produktivitaet( (p&0x7FFF)*k.x*k.y );
uint16 p=besch->get_produktivitaet();
if(p&0x8000) {
koord k=besch->get_haus()->get_groesse();
// to be compatible with old factories, since new code only steps once per factory, not per tile
besch->set_produktivitaet( (p&0x7FFF)*k.x*k.y );
DBG_DEBUG("fabrikbauer_t::register_besch()","Correction for old factory: Increase poduction from %i by %i",p&0x7FFF,k.x*k.y);
}
}
if( table.remove(besch->get_name()) ) {
dbg->warning( "fabrikbauer_t::register_besch()", "Object %s was overlaid by addon!", besch->get_name() );
}
table.put(besch->get_name(), besch);
}
......@@ -277,8 +280,7 @@ const fabrik_besch_t *fabrikbauer_t::finde_hersteller(const ware_besch_t *ware,
koord3d
fabrikbauer_t::finde_zufallsbauplatz(karte_t * welt, const koord3d pos, const int radius, koord groesse, bool wasser, const haus_besch_t *besch)
koord3d fabrikbauer_t::finde_zufallsbauplatz(karte_t *welt, const koord3d pos, const int radius, koord groesse, bool wasser, const haus_besch_t *besch, bool ignore_climates)
{
static vector_tpl<koord3d> list(10000);
koord k;
......@@ -289,6 +291,8 @@ fabrikbauer_t::finde_zufallsbauplatz(karte_t * welt, const koord3d pos, const in
groesse += koord(6,6);
}
climate_bits climates = !ignore_climates ? besch->get_allowed_climate_bits() : ALL_CLIMATES;
// check no factory but otherwise good place
for(k.y=pos.y-radius; k.y<=pos.y+radius; k.y++) {
if(k.y<0) continue;
......@@ -301,7 +305,7 @@ fabrikbauer_t::finde_zufallsbauplatz(karte_t * welt, const koord3d pos, const in
if(is_fabrik && is_factory_at(k.x,k.y)) {
continue;
}
if(fabrik_t::ist_bauplatz(welt, k, groesse,wasser,besch->get_allowed_climate_bits())) {
if(fabrik_t::ist_bauplatz(welt, k, groesse,wasser,climates)) {
list.append(welt->lookup(k)->get_kartenboden()->get_pos());
// nicht gleich daneben nochmal suchen
k.x += 4;
......@@ -341,7 +345,7 @@ void fabrikbauer_t::verteile_tourist(karte_t* welt, int max_number)
}
// very fast, so we do not bother updating progress bar
print("Distributing %i tourist attractions ...\n",max_number);fflush(NULL);
printf("Distributing %i tourist attractions ...\n",max_number);fflush(NULL);
int retrys = max_number*4;
while(current_number<max_number && retrys-->0) {
......@@ -354,7 +358,7 @@ void fabrikbauer_t::verteile_tourist(karte_t* welt, int max_number)
}
int rotation=simrand(attraction->get_all_layouts()-1);
pos = finde_zufallsbauplatz(welt, pos, 20, attraction->get_groesse(rotation),false,attraction); // so far -> land only
pos = finde_zufallsbauplatz(welt, pos, 20, attraction->get_groesse(rotation),false,attraction,false); // so far -> land only
if(welt->lookup(pos)) {
// Platz gefunden ...
hausbauer_t::baue(welt, welt->get_spieler(1), pos, rotation, attraction);
......@@ -364,7 +368,7 @@ void fabrikbauer_t::verteile_tourist(karte_t* welt, int max_number)
}
// update an open map
reliefkarte_t::get_karte()->calc_map();
reliefkarte_t::get_karte()->calc_map_groesse();
}
......@@ -400,7 +404,10 @@ fabrik_t* fabrikbauer_t::baue_fabrik(karte_t* welt, koord3d* parent, const fabri
if(welt->ist_in_kartengrenzen(k)) {
// add all water to station
grund_t *gr = welt->lookup(k)->get_kartenboden();
if(gr->ist_wasser() && gr->hat_weg(water_wt) == 0) {
// build only on gb, otherwise can't remove it
// also savegame restore only halt on gb
// this needs for bad fish swarm
if(gr->ist_wasser() && gr->hat_weg(water_wt) == 0 && gr->find<gebaeude_t>()) {
halt->add_grund( gr );
}
}
......@@ -562,8 +569,8 @@ DBG_MESSAGE("fabrikbauer_t::baue_hierarchie","Construction of %s at (%i,%i).",in
if(parent==NULL) {
DBG_MESSAGE("fabrikbauer_t::baue_hierarchie()","update karte");
// update an open map
reliefkarte_t::get_karte()->calc_map();
// update the map if needed
reliefkarte_t::get_karte()->calc_map_groesse();
INT_CHECK( "fabrikbauer 730" );
......@@ -668,7 +675,8 @@ DBG_MESSAGE("fabrikbauer_t::baue_hierarchie","lieferanten %i, lcount %i (need %i
slist_tpl<fabs_to_crossconnect_t>::iterator i = std::find(factories_to_correct.begin(), factories_to_correct.end(), fabs_to_crossconnect_t(zfab, 0));
if (i == factories_to_correct.end()) {
factories_to_correct.append(fabs_to_crossconnect_t(zfab, 1));
} else {
}
else {
i->demand += 1;
}
}
......@@ -736,7 +744,8 @@ DBG_MESSAGE("fabrikbauer_t::baue_hierarchie","lieferanten %i, lcount %i (need %i
int rotate = simrand(hersteller->get_haus()->get_all_layouts()-1);
koord3d parent_pos = our_fab->get_pos();
koord3d k = finde_zufallsbauplatz(welt, our_fab->get_pos()+(retry_koord[retry%25]*DISTANCE*2), DISTANCE, hersteller->get_haus()->get_groesse(rotate),hersteller->get_platzierung()==fabrik_besch_t::Wasser,hersteller->get_haus());
// ignore climates, when already 40 retrys occurred ...
koord3d k = finde_zufallsbauplatz(welt, our_fab->get_pos()+(retry_koord[retry%25]*DISTANCE*2), DISTANCE, hersteller->get_haus()->get_groesse(rotate),hersteller->get_platzierung()==fabrik_besch_t::Wasser,hersteller->get_haus(),j>40);
INT_CHECK("fabrikbauer 697");
......@@ -788,7 +797,8 @@ DBG_MESSAGE("fabrikbauer_t::baue_hierarchie","failed to built lieferant %s aroun
(*i).fab->add_supplier( (*fab)->get_pos().get_2d() );
if (i->demand < 0) {
i = factories_to_correct.erase(i);
} else {
}
else {
++i;
}
}
......@@ -846,12 +856,30 @@ next_ware_check:
// first: do we have to continue unfinished buissness?
if(last_built_consumer && last_built_consumer_ware < last_built_consumer->get_besch()->get_lieferanten()) {
int org_rotation = -1;
// rotate until we can save it, if one of the factory is non-rotateable ...
if(welt->cannot_save() && !can_factory_tree_rotate(last_built_consumer->get_besch()) ) {
org_rotation = welt->get_einstellungen()->get_rotation();
for( int i=0; i<3 && welt->cannot_save(); i++ ) {
welt->rotate90();
}
assert( !welt->cannot_save() );
}
uint32 last_suppliers = last_built_consumer->get_suppliers().get_count();
do {
nr += baue_link_hierarchie( last_built_consumer, last_built_consumer->get_besch(), last_built_consumer_ware, welt->get_spieler(1) );
last_built_consumer_ware ++;
} while( last_built_consumer_ware < last_built_consumer->get_besch()->get_lieferanten() && last_built_consumer->get_suppliers().get_count()==last_suppliers );
// must rotate back?
if(org_rotation>=0) {
for( int i=0; i<4 && welt->get_einstellungen()->get_rotation()!=org_rotation; i++ ) {
welt->rotate90();
}
welt->update_map();
}
// only return, if successfull
if( last_built_consumer->get_suppliers().get_count() > last_suppliers ) {
DBG_MESSAGE( "fabrikbauer_t::increase_industry_density()", "added ware %i to factory %s", last_built_consumer_ware, last_built_consumer->get_name() );
......@@ -890,8 +918,9 @@ next_ware_check:
// now decide producer of electricity or normal ...
sint32 promille = (electric_productivity*4000l)/total_produktivity;
int no_electric = promille > welt->get_einstellungen()->get_electric_promille();
DBG_MESSAGE( "fabrikbauer_t::increase_industry_density()", "production of electricity/total production is %i/%i (%i/oo)", electric_productivity, total_produktivity, promille );
DBG_MESSAGE( "fabrikbauer_t::increase_industry_density()", "production of electricity/total production is %i/%i (%i o/oo)", electric_productivity, total_produktivity, promille );
bool not_yet_too_desperate_to_ignore_climates = false;
while( no_electric<2 ) {
for(int retrys=20; retrys>0; retrys-- ) {
const fabrik_besch_t *fab=get_random_consumer( no_electric==0, ALL_CLIMATES, welt->get_timeline_year_month() );
......@@ -907,7 +936,7 @@ next_ware_check:
int rotation=simrand(fab->get_haus()->get_all_layouts()-1);
if(!in_city) {
pos = finde_zufallsbauplatz(welt, pos, 20, fab->get_haus()->get_groesse(rotation),fab->get_platzierung()==fabrik_besch_t::Wasser,fab->get_haus());
pos = finde_zufallsbauplatz(welt, pos, 20, fab->get_haus()->get_groesse(rotation),fab->get_platzierung()==fabrik_besch_t::Wasser,fab->get_haus(),not_yet_too_desperate_to_ignore_climates);
}
if(welt->lookup(pos)) {
// Platz gefunden ...
......@@ -918,7 +947,7 @@ next_ware_check:
last_built_consumer = our_fab;
last_built_consumer_ware = 1;
}
reliefkarte_t::get_karte()->calc_map();
reliefkarte_t::get_karte()->calc_map_groesse();
// tell the player
if(tell_me) {
stadt_t *s = welt->suche_naechste_stadt( pos.get_2d() );
......@@ -930,6 +959,11 @@ next_ware_check:
return nr;
}
}
else if( retrys==1 && not_yet_too_desperate_to_ignore_climates ) {
// from now one, we will ignore climates to avoid broken chains
not_yet_too_desperate_to_ignore_climates = true;
retrys = 20;
}
}
}
// if electricity not sucess => try next
......
......@@ -9,7 +9,6 @@
#define fabrikbauer_t_h
#include "../tpl/stringhashtable_tpl.h"
#include "../tpl/array_tpl.h"
#include "../dataobj/koord3d.h"
class haus_besch_t;
......@@ -122,7 +121,7 @@ public:
private:
// bauhilfen
static koord3d finde_zufallsbauplatz(karte_t *welt, koord3d pos, int radius, koord groesse,bool on_water, const haus_besch_t *besch);
static koord3d finde_zufallsbauplatz(karte_t *welt, koord3d pos, int radius, koord groesse,bool on_water, const haus_besch_t *besch, bool ignore_climates);
// check, if we have to rotate the factories before building this tree
static bool can_factory_tree_rotate( const fabrik_besch_t *besch );
......
......@@ -13,6 +13,7 @@
#include "../besch/spezial_obj_tpl.h"
#include "../boden/boden.h"
#include "../boden/wasser.h"
#include "../boden/fundament.h"
#include "../dataobj/translator.h"
......@@ -98,6 +99,64 @@ static bool compare_station_besch(const haus_besch_t* a, const haus_besch_t* b)
bool hausbauer_t::alles_geladen()
{
stringhashtable_iterator_tpl<const haus_besch_t *>iter(besch_names);
while( iter.next() ) {
const haus_besch_t* besch = iter.get_current_value();
switch(besch->get_typ()) {
case gebaeude_t::wohnung:
wohnhaeuser.append(besch);
break;
case gebaeude_t::industrie:
industriehaeuser.append(besch);
break;
case gebaeude_t::gewerbe:
gewerbehaeuser.append(besch);
break;
case gebaeude_t::unbekannt:
switch (besch->get_utyp()) {
case haus_besch_t::denkmal:
denkmaeler.append(besch);
break;
case haus_besch_t::attraction_land:
sehenswuerdigkeiten_land.append(besch);
break;
case haus_besch_t::firmensitz:
headquarter.append(besch);
break;
case haus_besch_t::rathaus:
rathaeuser.append(besch);
break;
case haus_besch_t::attraction_city:
sehenswuerdigkeiten_city.append(besch);
break;
case haus_besch_t::fabrik:
break;
case haus_besch_t::hafen:
case haus_besch_t::hafen_geb:
case haus_besch_t::depot:
case haus_besch_t::generic_stop:
case haus_besch_t::generic_extension:
station_building.append(besch);
break;
case haus_besch_t::weitere:
if(strcmp(besch->get_name(),"MonorailGround")==0) {
// foundation for elevated ways
elevated_foundation_besch = besch;
break;
}
default:
// obsolete object, usually such pak set will not load properly anyway (old objects should be catched before!)
dbg->error("hausbauer_t::alles_geladen()","unknown subtype %i of \"%s\" ignored",besch->get_utyp(),besch->get_name());
}
}
}
// now sort them according level
std::sort(wohnhaeuser.begin(), wohnhaeuser.end(), compare_haus_besch);
std::sort(gewerbehaeuser.begin(), gewerbehaeuser.end(), compare_haus_besch);
std::sort(industriehaeuser.begin(), industriehaeuser.end(), compare_haus_besch);
......@@ -112,41 +171,11 @@ bool hausbauer_t::register_besch(const haus_besch_t *besch)
{
::register_besch(spezial_objekte, besch);
switch(besch->get_typ()) {
case gebaeude_t::wohnung: wohnhaeuser.append(besch); break;
case gebaeude_t::industrie: industriehaeuser.append(besch); break;
case gebaeude_t::gewerbe: gewerbehaeuser.append(besch); break;
case gebaeude_t::unbekannt:
switch (besch->get_utyp()) {
case haus_besch_t::denkmal: denkmaeler.append(besch); break;
case haus_besch_t::attraction_land: sehenswuerdigkeiten_land.append(besch); break;
case haus_besch_t::firmensitz: headquarter.append(besch); break;
case haus_besch_t::rathaus: rathaeuser.append(besch); break;
case haus_besch_t::attraction_city: sehenswuerdigkeiten_city.append(besch); break;
case haus_besch_t::fabrik: break;
case haus_besch_t::hafen:
case haus_besch_t::hafen_geb:
case haus_besch_t::depot:
case haus_besch_t::generic_stop:
case haus_besch_t::generic_extension:
station_building.append(besch);
DBG_DEBUG("hausbauer_t::register_besch()","Infrastructure %s",besch->get_name());
break;
case haus_besch_t::weitere:
if(strcmp(besch->get_name(),"MonorailGround")==0) {
// foundation for elevated ways
elevated_foundation_besch = besch;
break;
}
default:
DBG_DEBUG("hausbauer_t::register_besch()","unknown subtype %i of %s: ignored",besch->get_utyp(),besch->get_name());
return false;
}
// avoid duplicates with same name
if(besch_names.remove(besch->get_name())) {
dbg->warning( "hausbauer_t::register_besch()", "Object %s was overlaid by addon!", besch->get_name() );
}
besch_names.put(besch->get_name(), besch);
/* supply the tiles with a pointer back to the matchin description
* this is needed, since each building is build of seperate tiles,
......@@ -157,10 +186,6 @@ DBG_DEBUG("hausbauer_t::register_besch()","unknown subtype %i of %s: ignored",be
const_cast<haus_tile_besch_t *>(besch->get_tile(i))->set_besch(besch);
}
if(besch_names.get(besch->get_name())) {
dbg->fatal("hausbauer_t::register_Besch()", "building %s duplicated", besch->get_name());
}
besch_names.put(besch->get_name(), besch);
return true;
}
......@@ -171,7 +196,7 @@ static stringhashtable_tpl<wkz_station_t *> station_tool;
static stringhashtable_tpl<wkz_depot_t *> depot_tool;
// all these menus will need a waytype ...
void hausbauer_t::fill_menu(werkzeug_waehler_t* wzw, haus_besch_t::utyp utyp, waytype_t wt, const karte_t* welt)
void hausbauer_t::fill_menu(werkzeug_waehler_t* wzw, haus_besch_t::utyp utyp, waytype_t wt, sint16 sound_ok, const karte_t* welt)
{
const uint16 time = welt->get_timeline_year_month();
DBG_DEBUG("hausbauer_t::fill_menu()","maximum %i",station_building.get_count());
......@@ -189,6 +214,7 @@ DBG_DEBUG("hausbauer_t::fill_menu()","maximum %i",station_building.get_count());
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;