Permalink
Browse files

Wrong change

git-svn-id: svn://tron.homeunix.org/simutrans/simutrans/trunk@5613 8aca7d54-2c30-db11-9de9-000461428c89
  • Loading branch information...
Markus Pristovsek
Markus Pristovsek committed Apr 5, 2012
1 parent fea73e2 commit 431670243f3a23f97748d33faaa77540996509a0
Showing with 346 additions and 150 deletions.
  1. +10 −14 dings/gebaeude.cc
  2. +3 −3 dings/wolke.cc
  3. +4 −4 simfab.cc
  4. +1 −1 simhalt.cc
  5. +6 −5 simtools.cc
  6. +24 −0 simtools.h
  7. +162 −16 simworld.cc
  8. +20 −2 simworld.h
  9. +4 −2 tpl/vector_tpl.h
  10. +74 −2 vehicle/simpeople.cc
  11. +7 −3 vehicle/simpeople.h
  12. +13 −8 vehicle/simvehikel.cc
  13. +17 −88 vehicle/simverkehr.cc
  14. +1 −2 vehicle/simverkehr.h
View
@@ -76,7 +76,7 @@ gebaeude_t::gebaeude_t(karte_t *welt, loadsave_t *file) : ding_t(welt)
set_yoff(0);
}
if(tile && tile->get_phasen()>1) {
- welt->sync_add( this );
+ welt->sync_eyecandy_add( this );
sync = true;
}
}
@@ -115,7 +115,7 @@ gebaeude_t::~gebaeude_t()
if(sync) {
sync = false;
- welt->sync_remove(this);
+ welt->sync_eyecandy_remove(this);
}
// tiles might be invalid, if no description is found during loading
@@ -260,16 +260,16 @@ void gebaeude_t::set_tile(const haus_tile_besch_t *new_tile)
if(sync) {
if(new_tile->get_phasen()<=1 && !zeige_baugrube) {
// need to stop animation
- welt->sync_remove(this);
+ welt->sync_eyecandy_remove(this);
sync = false;
count = 0;
}
}
else if(new_tile->get_phasen()>1 || zeige_baugrube) {
// needs now animation
- count = simrand(new_tile->get_phasen());
+ count = sim_async_rand(new_tile->get_phasen());
anim_time = 0;
- welt->sync_add(this);
+ welt->sync_eyecandy_add(this);
sync = true;
}
tile = new_tile;
@@ -278,8 +278,6 @@ void gebaeude_t::set_tile(const haus_tile_besch_t *new_tile)
}
-
-
/**
* Methode für Echtzeitfunktionen eines Objekts.
* @return false wenn Objekt aus der Liste der synchronen
@@ -295,7 +293,7 @@ bool gebaeude_t::sync_step(long delta_t)
mark_image_dirty(get_bild(),0);
zeige_baugrube = false;
if(tile->get_phasen()<=1) {
- welt->sync_remove( this );
+ welt->sync_eyecandy_remove( this );
sync = false;
}
}
@@ -341,7 +339,6 @@ bool gebaeude_t::sync_step(long delta_t)
}
-
void gebaeude_t::calc_bild()
{
grund_t *gr = welt->lookup(get_pos());
@@ -589,7 +586,6 @@ DBG_MESSAGE("gebaeude_t::zeige_info()", "at %d,%d - name is '%s'", get_pos().x,
}
-
void gebaeude_t::info(cbuffer_t & buf) const
{
ding_t::info(buf);
@@ -857,7 +853,6 @@ void gebaeude_t::rdwr(loadsave_t *file)
}
-
/**
* Wird nach dem Laden der Welt aufgerufen - üblicherweise benutzt
* um das Aussehen des Dings an Boden und Umgebung anzupassen
@@ -885,15 +880,15 @@ void gebaeude_t::laden_abschliessen()
}
-
void gebaeude_t::entferne(spieler_t *sp)
{
// DBG_MESSAGE("gebaeude_t::entferne()","gb %i");
// remove costs
sint64 cost = welt->get_settings().cst_multiply_remove_haus;
// tearing down halts is always single costs only
- if (tile->get_besch()->get_utyp() < haus_besch_t::bahnhof)
+ if (tile->get_besch()->get_utyp() < haus_besch_t::bahnhof) {
cost *= tile->get_besch()->get_level() + 1;
+ }
spieler_t::accounting(sp, cost, get_pos().get_2d(), COST_CONSTRUCTION);
// may need to update next buildings, in the case of start, middle, end buildings
@@ -951,6 +946,7 @@ void gebaeude_t::entferne(spieler_t *sp)
mark_images_dirty();
}
+
void gebaeude_t::mark_images_dirty() const
{
// remove all traces from the screen
@@ -964,6 +960,6 @@ void gebaeude_t::mark_images_dirty() const
img = tile->get_hintergrund(count, 0, snow) ;
}
for( int i=0; img!=IMG_LEER; img=get_bild(++i) ) {
- mark_image_dirty( img, -(i<<6) );
+ mark_image_dirty( img, -(i*get_tile_raster_width()) );
}
}
View
@@ -34,8 +34,6 @@ bool wolke_t::register_besch(const skin_besch_t* besch)
-
-
wolke_t::wolke_t(karte_t *welt, koord3d pos, sint8 x_off, sint8 y_off, const skin_besch_t* besch ) :
ding_no_info_t(welt, pos)
{
@@ -52,7 +50,9 @@ wolke_t::wolke_t(karte_t *welt, koord3d pos, sint8 x_off, sint8 y_off, const ski
wolke_t::~wolke_t()
{
mark_image_dirty( get_bild(), 0 );
- welt->sync_remove(this);
+ if( !welt->sync_way_eyecandy_remove( this ) ) {
+ welt->sync_eyecandy_remove( this );
+ }
}
View
@@ -1191,13 +1191,13 @@ void fabrik_t::smoke() const
const koord size = besch->get_haus()->get_groesse(0)-koord(1,1);
const uint8 rot = rotate%besch->get_haus()->get_all_layouts();
koord ro = rada->get_pos_off(size,rot);
- grund_t *gr=welt->lookup_kartenboden(pos.get_2d()+ro);
+ grund_t *gr = welt->lookup_kartenboden(pos.get_2d()+ro);
// to get same random order on different compilers
- const sint8 offsetx = ((rada->get_xy_off(rot).x+simrand(7)-3)*OBJECT_OFFSET_STEPS)/16;
- const sint8 offsety = ((rada->get_xy_off(rot).y+simrand(7)-3)*OBJECT_OFFSET_STEPS)/16;
+ const sint8 offsetx = ((rada->get_xy_off(rot).x+sim_async_rand(7)-3)*OBJECT_OFFSET_STEPS)/16;
+ const sint8 offsety = ((rada->get_xy_off(rot).y+sim_async_rand(7)-3)*OBJECT_OFFSET_STEPS)/16;
wolke_t *smoke = new wolke_t(welt, gr->get_pos(), offsetx, offsety, rada->get_bilder() );
gr->obj_add(smoke);
- welt->sync_add( smoke );
+ welt->sync_eyecandy_add( smoke );
}
}
View
@@ -1959,7 +1959,7 @@ dbg->warning("haltestelle_t::liefere_an()","%d %s delivered to %s have no longer
}
else if( ware.get_besch() == warenbauer_t::passagiere ) {
// arriving passenger may create pedestrians
- if( umgebung_t::has_pedestrians_at_stops ) {
+ if( welt->get_settings().get_show_pax() ) {
int menge = ware.menge;
FOR( slist_tpl<tile_t>, const& i, tiles ) {
if (menge <= 0) {
View
@@ -1,6 +1,7 @@
#include <assert.h>
#include <math.h>
#include "simtools.h"
+#include "simsys.h"
/* This is the mersenne random generator: More random and faster! */
@@ -119,18 +120,18 @@ uint16 get_random_mode()
}
-static uint32 rand_seed = 12345678;
+static uint32 async_rand_seed = 12345678+dr_time();
// simpler simrand for anything not game critical (like UI)
uint32 sim_async_rand( uint32 max )
{
if( max==0 ) {
return 0;
}
- rand_seed *= 3141592621u;
- rand_seed ++;
+ async_rand_seed *= 3141592621u;
+ async_rand_seed ++;
- return (rand_seed >> 8) % max;
+ return (async_rand_seed >> 8) % max;
}
@@ -143,7 +144,7 @@ uint32 setsimrand(uint32 seed,uint32 ns)
if(seed!=0xFFFFFFFF) {
init_genrand( seed );
- rand_seed = seed;
+ async_rand_seed = seed+dr_time();
random_origin = 0;
}
if(noise_seed!=0xFFFFFFFF) {
View
@@ -57,6 +57,30 @@ template<typename T, typename U> T const& pick_any_weighted_subset(U const& cont
return container.at_weight(simrand(container.get_sum_weight()));
}
+/* Randomly select an entry from the given array. */
+template<typename T, size_t N> T const& pick_any_async(T const (&array)[N])
+{
+ return array[sim_async_rand(N)];
+}
+
+/* Randomly select an entry from the given container. */
+template<typename T, template<typename> class U> T const& pick_any_async(U<T> const& container)
+{
+ return container[sim_async_rand(container.get_count())];
+}
+
+/* Randomly select an entry from the given weighted container. */
+template<typename T, template<typename> class U> T const& pick_any_weighted_async(U<T> const& container)
+{
+ return container.at_weight(sim_async_rand(container.get_sum_weight()));
+}
+
+/* Randomly select an entry from the given subset of a weighted container. */
+template<typename T, typename U> T const& pick_any_weighted_subset_async(U const& container)
+{
+ return container.at_weight(sim_async_rand(container.get_sum_weight()));
+}
+
// compute integer log10
uint32 log10(uint32 v);
Oops, something went wrong.

0 comments on commit 4316702

Please sign in to comment.