News:

Simutrans.com Portal
Our Simutrans site. You can find everything about Simutrans from here.

Recent posts

#1
Patches & Projects / Re: tpl freelist mutex locking...
Last post by prissi - Today at 05:50:49 AM
Well spotted, that should be indeed a lock unstead of unlock.

And the squirrel headers are patched, as we had to download squirrel verbatim. I am anyway trying to update simutrans to squirrel 3.2.

#2
Patches & Projects / tpl freelist mutex locking inc...
Last post by jrs - Today at 05:00:54 AM
I am working on a port of simutrans to openbsd and found their pthreads implementation was not happy with tpl/freelist_tpl.h, aborting due to an unlock with an unknown owner. While poking at the code trying to understand this I found the lock/unlock dance in tpl/freelist_tpl.h strange. Unlock was called twice. changing the first one to a lock allowed the game to run.

Index: simutrans/src/simutrans/tpl/freelist_tpl.h
--- simutrans/src/simutrans/tpl/freelist_tpl.h.orig
+++ simutrans/src/simutrans/tpl/freelist_tpl.h
@@ -170,7 +170,7 @@ class freelist_size_t (public)
#endif

#ifdef MULTI_THREAD
- pthread_mutex_unlock(&freelist_mutex);
+ pthread_mutex_lock(&freelist_mutex);
#endif

// putback to first node

One other small thing, this might just be an openbsd/clang peculiarity. but wanted to mention it just in case.
squirrel/squirrel/sqvm.h can not find a declaration for "va_list" I found it in stdarg.h

Index: simutrans/src/squirrel/squirrel/sqvm.h
--- simutrans/src/squirrel/squirrel/sqvm.h.orig
+++ simutrans/src/squirrel/squirrel/sqvm.h
@@ -2,6 +2,7 @@
 #ifndef _SQVM_H_
 #define _SQVM_H_
 
+#include <stdarg.h>
 #include "sqopcodes.h"
 #include "sqobject.h"
 #define MAX_NATIVE_CALLS 100



#3
Extension Requests / Re: edit credit per MW of powe...
Last post by poppo - Today at 04:22:18 AM
diff --git a/src/simutrans/dataobj/settings.cc b/src/simutrans/dataobj/settings.cc
index bcc0a3294..67e110fe2 100644
--- a/src/simutrans/dataobj/settings.cc
+++ b/src/simutrans/dataobj/settings.cc
@@ -746,6 +746,13 @@ void settings_t::rdwr(loadsave_t *file)
  file->rdwr_long(way_count_avoid_crossings);
  file->rdwr_long(way_count_maximum);
  }
+
+ if (file->is_version_atleast(124,4)) {
+ file->rdwr_long(credit_per_MWs);
+ }
+ else {
+ credit_per_MWs = 2;
+ }
  }
 
  // sometimes broken savegames could have no legal direction for take off ...
@@ -1307,6 +1314,8 @@ void settings_t::parse_simuconf( tabfile_t& simuconf, sint16& disp_width, sint16
 
  crossconnect_factories         = contents.get_int("crossconnect_factories", crossconnect_factories ) != 0;
 
+ credit_per_MWs = contents.get_int_clamped( "credit_per_MWs", credit_per_MWs, 1, 512);
+
  env_t::just_in_time = contents.get_int_clamped("just_in_time", env_t::just_in_time, 0, 2);
  just_in_time = env_t::just_in_time;
 
diff --git a/src/simutrans/dataobj/settings.h b/src/simutrans/dataobj/settings.h
index a15b485f4..d3a12fa57 100644
--- a/src/simutrans/dataobj/settings.h
+++ b/src/simutrans/dataobj/settings.h
@@ -63,6 +63,8 @@ private:
  sint32 factory_count       =  12;
  sint32 electric_promille   = 330;
 
+ uint32 credit_per_MWs;
+
  sint32 city_count         =   16;
  sint32 mean_citizen_count = 1600;
 
@@ -418,6 +420,8 @@ public:
 
  sint32 get_electric_promille() const {return electric_promille;}
 
+ sint32 get_credit_per_MWs() const {return credit_per_MWs;}
+
  void set_tourist_attractions( sint32 n ) { tourist_attractions = n; }
  sint32 get_tourist_attractions() const {return tourist_attractions;}
 
diff --git a/src/simutrans/gui/settings_stats.cc b/src/simutrans/gui/settings_stats.cc
index 40b1425d0..bb113b843 100644
--- a/src/simutrans/gui/settings_stats.cc
+++ b/src/simutrans/gui/settings_stats.cc
@@ -306,6 +306,7 @@ void settings_economy_stats_t::init(settings_t const* const sets)
  INIT_NUM( "electric_promille", sets->get_electric_promille(), 0, 1000, gui_numberinput_t::AUTOLINEAR, false );
  INIT_BOOL( "allow_underground_transformers", sets->get_allow_underground_transformers() );
  INIT_NUM( "way_height_clearance", sets->get_way_height_clearance(), 1, 2, gui_numberinput_t::AUTOLINEAR, true );
+ INIT_NUM( "credit_per_MWs", sets->get_credit_per_MWs(), 1, 512, gui_numberinput_t::AUTOLINEAR, false);
  SEPERATOR
 
  INIT_NUM( "passenger_factor",  sets->get_passenger_factor(), 0, 16, gui_numberinput_t::AUTOLINEAR, false );
@@ -398,6 +399,7 @@ void settings_economy_stats_t::read(settings_t* const sets)
  READ_NUM_VALUE( sets->electric_promille );
  READ_BOOL_VALUE( sets->allow_underground_transformers );
  READ_NUM_VALUE( sets->way_height_clearance );
+ READ_NUM_VALUE( sets->credit_per_MWs );
 
  READ_NUM_VALUE( sets->passenger_factor );
  READ_NUM_VALUE( sets->minimum_city_distance );
diff --git a/src/simutrans/obj/leitung2.cc b/src/simutrans/obj/leitung2.cc
index c84e9b36c..b2d528667 100644
--- a/src/simutrans/obj/leitung2.cc
+++ b/src/simutrans/obj/leitung2.cc
@@ -668,7 +668,7 @@ senke_t::~senke_t()
 void senke_t::pay_revenue()
 {
  // megajoules (megawatt seconds) per cent
- const uint64 mjpc = (1 << POWER_TO_MW) / CREDIT_PER_MWS; // should be tied to game setting
+ const uint64 mjpc = (1 << POWER_TO_MW) / world()->get_settings().get_credit_per_MWs(); // should be tied to game setting
 
  // calculate payment in cent
  const sint64 payment = (sint64)(energy_acc / mjpc);
diff --git a/src/simutrans/obj/leitung2.h b/src/simutrans/obj/leitung2.h
index e1a17e75c..a4c4e1a5d 100644
--- a/src/simutrans/obj/leitung2.h
+++ b/src/simutrans/obj/leitung2.h
@@ -16,8 +16,6 @@
 // bitshift for converting internal power values to MW for display
 extern const uint32 POWER_TO_MW;
 
-#define CREDIT_PER_MWS 2
-
 class powernet_t;
 class player_t;
 class fabrik_t;
I made a patch.
But I want to discuss about how much the upper limit of credit per MW.
In addition, in calculating energy_acc, we should consider about "MW per credit" cannot be as an integer (a remainder occurs in division).
#4
Scripting Scenarios and AI / Re: Tutorial - mail extension
Last post by Andarix - Yesterday at 09:29:43 PM
The conversion is mostly complete, including errors.

If there are free tile, a post office building is required.

If there are no free tile, a post office stop is required.

The waiting area for postal vehicles is being moved to a post office stop.

The selection of the post office building and post office stop is automatic when using automatic progression.

Since I changed the halt fields, saved tutorials no longer work.

chapter_05/04_1-3.txt
#5
Bug Reports / squirrel script - building_des...
Last post by Andarix - Yesterday at 03:45:00 PM
Simutrans r11871

Despite specifying Waytype 0, objects with other waytypes are also returned.

list = building_desc_x.get_available_stations(building_desc_x.station_extension, 0, good_desc_x(good))
good is "Post"

pak64
Screenshot 2026-01-19 163650.png

pak64.german
Screenshot 2026-01-19 163112.png
#6
Scripting Scenarios and AI / Re: Tutorial - mail extension
Last post by Andarix - Yesterday at 09:17:08 AM
first beta pak64

- text not changed
- auto step not work - chapter 5 step D

Simutrans r11871

not compatible to older save games (halt coord changed)

[EDIT]
delete file
#7
Bug Reports / Re: squirrel script - bug sele...
Last post by prissi - January 18, 2026, 11:40:35 AM
This is the intended format:
name => object
number => waytype
Only in the later building stages, the object is know, not at the time when the tool is called, since the last waytape is cached with the tool.
#8
Patches & Projects / Re: tool_wayremover_t can be u...
Last post by prissi - January 18, 2026, 11:37:28 AM
Before, there had been actually ways with waytype tram_wt. But I am ok with removing this old code, as now track get converted anyway on pak set loading time.

Using the same driver for removal and adding wayobj sounds sensible to me. But the scenario checker must not be removed.

I added this in r11872
#9
Extension Requests / Re: edit credit per MW of powe...
Last post by prissi - January 18, 2026, 11:09:48 AM
This is a good idea. I would take a patch for it.
#10
Extension Requests / edit credit per MW of powerlin...
Last post by poppo - January 17, 2026, 05:23:06 PM
today, the credit per electric(MW) is fixed as 2 in leitung2.h.
I want to edit it for my paksets.

I suggest that credit per MW can be set and editted in settings.