News:

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

List of available vehicles (without building depot)

Started by BBGunn, May 21, 2014, 02:06:01 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

BBGunn

Forgive me if this has been requested before; I couldn't find any relative recent threads.

The extension I want the most right now is a list of all the available vehicles in the game (era dependent). 

For example, imagine that I have a line of road convoys, and I want to upgrade it to trains.  But I want to make sure that my company can afford any of the available trains.  Currently, to look at all available trains, I have to build one piece of railroad, then build a depot, then click on the depot to bring up a list of available vehicles.  But wouldn't it be better to have a list of all available vehicles somewhere that I can look at, without having to build a depot?  That way, I could save that money for later.  If I decide not to buy trains because they are too expensive, the money I spent just building a depot is wasted.
Another beautiful day!

私が日本語の間違いをしたら、すみません。
Desculpe-me quaisquer erros portugueses.  Sou só aprendiz.

Yona-TYT


Having a list of the vehicles available at the time of the game can be very useful.
however, long ago I suggested this and no one bothered to create a patch.


do not know if things will be different this time.


http://forum.simutrans.com/index.php?topic=10184.msg96720#msg96720

BBGunn

Quote from: Yona-TYT on May 21, 2014, 03:06:20 AM
Having a list of the vehicles available at the time of the game can be very useful.
however, long ago I suggested this and no one bothered to create a patch.


do not know if things will be different this time.


http://forum.simutrans.com/index.php?topic=10184.msg96720#msg96720
Ah, I missed that thread.  Thank you, Yona-TYT.  Yeah, from that thread, it looks like this sort of thing is not as easy to implement as it sounds. 
Another beautiful day!

私が日本語の間違いをしたら、すみません。
Desculpe-me quaisquer erros portugueses.  Sou só aprendiz.

Yona-TYT

Quote from: BBGunn on May 21, 2014, 05:18:26 AM
Ah, I missed that thread.  Thank you, Yona-TYT.  Yeah, from that thread, it looks like this sort of thing is not as easy to implement as it sounds. 



I'm afraid so.


But it's worth trying again, maybe someone can think of creating a good patch this time it.  ;)


prissi

It is extremely easy to implement, it will take me about one evening. But it is a great way to start understanding simutrans. So I had my hope up that someone would be bothered enough to do this.

Ves

If you would give me some advises, I would like to give it a try.  :)
I have never really programmed before, only some programs on my calculator. But I have read articles about C++ and feel like I kind of understand how it works. I even had downloaded VS2010 on my old computer, read and even understood some pieces of the sourcecode, then compiled a working Simutrans. Small things for you guys, but big as a mountain for me! :)

So how would you suggest I get started?

Ters

Quote from: Ves on May 28, 2014, 09:27:10 PM
feel like I kind of understand how it works.

I think that's about as far most C++ programmers get. But the only way to find out if you can swim is to get into the water. Simutrans is somewhat "deep water", at least in certain parts. I don't think the GUI is the deepest part (in terms of technical details of C++ or computers in general), but I haven't really "been there" myself.

Yona-TYT


Aquin

Well there is the Dat-Viewer and Editor by Zeno http://sourceforge.net/projects/st-mass-dat/ it can list all vehicles if you have the source .dat files.

Since it cannot save the list to any text or spreadsheet format, I added a little to it, now it saves the table as a tab delimeted text file to d:\summary.txt. http://simutrans-germany.com/files/upload/MassDatEditor.zip
It should be fine with both Standart and Experimental .dat-files.

Ters

Quote from: Aquin on May 29, 2014, 11:34:37 AM
Well there is the Dat-Viewer and Editor by Zeno http://sourceforge.net/projects/st-mass-dat/ it can list all vehicles if you have the source .dat files.

Since it cannot save the list to any text or spreadsheet format, I added a little to it, now it saves the table as a tab delimeted text file to d:\summary.txt. http://simutrans-germany.com/files/upload/MassDatEditor.zip
It should be fine with both Standart and Experimental .dat-files.

Most players don't have the dat files, so they would need something that can read the pak files. However, the request is for an in-game solution, not a separate program.

Ves

#10
First step, I suppose, is to get a working simutranscompilations.
However, I get some fatal errors when Im compiling the trunk Simutrans on my new computer windows 7, 64 bits. I did not have these problems before on Windows Vista 32 bit.

I have followed the checklist in this thread http://forum.simutrans.com/index.php?topic=652.0 which worked on my old computer.

When I choose the w64 folder (after adding the libraries that should be added), I get these errors:
1>simgraph16.obj : error LNK2001: unresolved external symbol __imp__pthread_mutex_init
1>simgraph16.obj : error LNK2001: unresolved external symbol __imp__pthread_mutex_destroy
1>simgraph16.obj : error LNK2001: unresolved external symbol __imp__pthread_mutex_unlock
1>simgraph16.obj : error LNK2001: unresolved external symbol __imp__pthread_mutex_lock
1>simview.obj : error LNK2001: unresolved external symbol __imp__pthread_attr_destroy
1>simview.obj : error LNK2001: unresolved external symbol __imp__pthread_barrier_init
1>simview.obj : error LNK2001: unresolved external symbol __imp__pthread_barrier_wait
1>simview.obj : error LNK2001: unresolved external symbol __imp__pthread_cond_broadcast
1>simview.obj : error LNK2001: unresolved external symbol __imp__pthread_create
1>simview.obj : error LNK2001: unresolved external symbol __imp__pthread_attr_setdetachstate
1>simview.obj : error LNK2001: unresolved external symbol __imp__pthread_attr_init
1>simview.obj : error LNK2001: unresolved external symbol __imp__pthread_cond_wait
1>image_reader.obj : error LNK2001: unresolved external symbol _adler32@12
1>loadsave.obj : error LNK2001: unresolved external symbol _gzeof@4
1>loadsave.obj : error LNK2001: unresolved external symbol _gzread@12
1>loadsave.obj : error LNK2001: unresolved external symbol _gzerror@8
1>loadsave.obj : error LNK2001: unresolved external symbol _gzwrite@12
1>loadsave.obj : error LNK2001: unresolved external symbol _gzclose@4
1>loadsave.obj : error LNK2001: unresolved external symbol __imp__pthread_join
1>loadsave.obj : error LNK2001: unresolved external symbol __imp__pthread_barrier_destroy
1>loadsave.obj : error LNK2001: unresolved external symbol _gzgets@12
1>loadsave.obj : error LNK2001: unresolved external symbol _gzopen@8
1>simworld.obj : error LNK2001: unresolved external symbol __imp__sem_post
1>simworld.obj : error LNK2001: unresolved external symbol __imp__sem_init
1>simworld.obj : error LNK2001: unresolved external symbol __imp__sem_destroy
1>simworld.obj : error LNK2001: unresolved external symbol __imp__sem_wait
1>F:\Spel\Utveckla Simutrans\Simutrans källkod\simutrans\simutrans\trunk\Release\Simutrans.exe : fatal error LNK1120: 26 unresolved externals


Using the w32-folder i get these errors:
1>simgraph16.obj : error LNK2001: unresolved external symbol __imp__pthread_mutex_init
1>simgraph16.obj : error LNK2001: unresolved external symbol __imp__pthread_mutex_destroy
1>simgraph16.obj : error LNK2001: unresolved external symbol __imp__pthread_mutex_unlock
1>simgraph16.obj : error LNK2001: unresolved external symbol __imp__pthread_mutex_lock
1>simview.obj : error LNK2001: unresolved external symbol __imp__pthread_attr_destroy
1>simview.obj : error LNK2001: unresolved external symbol __imp__pthread_barrier_init
1>simview.obj : error LNK2001: unresolved external symbol __imp__pthread_barrier_wait
1>simview.obj : error LNK2001: unresolved external symbol __imp__pthread_cond_broadcast
1>simview.obj : error LNK2001: unresolved external symbol __imp__pthread_create
1>simview.obj : error LNK2001: unresolved external symbol __imp__pthread_attr_setdetachstate
1>simview.obj : error LNK2001: unresolved external symbol __imp__pthread_attr_init
1>simview.obj : error LNK2001: unresolved external symbol __imp__pthread_cond_wait
1>loadsave.obj : error LNK2001: unresolved external symbol __imp__pthread_join
1>loadsave.obj : error LNK2001: unresolved external symbol __imp__pthread_barrier_destroy
1>simworld.obj : error LNK2001: unresolved external symbol __imp__sem_post
1>simworld.obj : error LNK2001: unresolved external symbol __imp__sem_init
1>simworld.obj : error LNK2001: unresolved external symbol __imp__sem_destroy
1>simworld.obj : error LNK2001: unresolved external symbol __imp__sem_wait


There is a file called pthread.h in the "shared include" folder (according to the "how to compile.."-thread)
I have tried to install everything over again, but have not worked yet. What am I doing wrong?

---------------------------

Now I managed to get it down to these errors:


compiled using libraries for w64:
1>image_reader.obj : error LNK2001: unresolved external symbol _adler32@12
1>loadsave.obj : error LNK2001: unresolved external symbol _gzeof@4
1>loadsave.obj : error LNK2001: unresolved external symbol _gzread@12
1>loadsave.obj : error LNK2001: unresolved external symbol _gzerror@8
1>loadsave.obj : error LNK2001: unresolved external symbol _gzwrite@12
1>loadsave.obj : error LNK2001: unresolved external symbol _gzclose@4
1>loadsave.obj : error LNK2001: unresolved external symbol _gzgets@12
1>loadsave.obj : error LNK2001: unresolved external symbol _gzopen@8
1>F:\Spel\Utveckla Simutrans\Simutrans källkod\simutrans\simutrans\trunk\Release\Simutrans.exe : fatal error LNK1120: 8 unresolved externals


Managed to only get one error while compiling using libraries for w32:
1>LINK : fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt
The reason I try with both libraries is that I frankly dont know which one to use  :o

How should I resolve these errors?

------------------------------

Im really really sorry about trippleposting, but: Yay! I got it working! 8)
I uninstalled Net framework 4.5, and download and installed Net framework 4.0.


So, with a working compilation, how would you coders out there suggest me to look for?

Ves

Well, after looking through the code, I found that maybe copying the files citylist_frame_t.cc and citylist_frame_t.h, renaming them to vehiclelist_frame_t.cc and /.h would do as a start. I did and managed then to create a new magic list entry and I have now a new window titulated "vehicle list" fully working in simutrans with its own icon! :D
Now I have to replace what's inside the window with something with vehicles.

What would be most desired? A "depot like" window or something else? I see fore me that you can use tabs to select the types of vehicles, where do I find the use of the icons used in the line management window? then something to differentiate between powered/unpowered and maybe even what kind of power..

An_dz

halt_info.cc have the icons you want, just check it.

If you use the same idea of the depot window it will be faster. Using the image_list components to draw them, the filtering functions and the the tabs structure, all you have to do is reload when you change vehicle type tab. Something like tabs inside tabs.

Ves

Ok, thank you! I'm having problem stripping the old city-content out of the window I get many errors every time I try to remove something (sortings etc). What is the basic classes that is needed in order to make a clean window usable?

An_dz

The bare minimum is define /display/simgraph.h/ for the drawing stuff in the cc file.
/gui/gui_frame.h/ is required in the header file for the sizing stuff (D_MARGIN_LEFT, LINESPACE, etc.)

prissi

The proper way to make this is to generate a new list which just uses. I.e. derive from gui_scrolled_list.h
/**
* Container for list entries - consisting of text and color
*/
class scrollitem_t {
public:
virtual ~scrollitem_t() {}
virtual scr_coord_val get_h() const = 0; // largest object in this list
virtual scr_coord_val draw( scr_coord pos, scr_coord_val width, bool is_selected, bool has_focus ) = 0;
virtual char const* get_text() const = 0;
virtual bool is_valid() { return true; } //  can be used to indicate invalid entries
virtual bool is_editable() { return false; }
virtual bool sort( vector_tpl<scrollitem_t *> &, int, void * ) const { return false; } // not sorted, leave vector as before
};

An object for each vehicle. That way you could use a scrolled list and do not worry at all about scrollbars etc. Then you just add this list to a window.

Ves

Up until now I have tried to get rid of the current content of the window (former citylist), but have failed badly.
What I have currently is this:

vehiclelist_frame_t
vehiclelist_stats_t

These classes are currently identicall as their citylists-correspondings, however I try to 'empty' them.

As how to make a structure, would you suggest that I keep and use the 4 files (vehiclelist_stats.cc /.h and vehiclelist_frame.cc /.h) with their classes?

I will experiement with the gui_scrolled_list.h when I come home tonight!

DrSuperGood

I would also be very grateful for a convoy type list. Especially for knowing what vehicles are coming in the future I often find myself going off and creating a dummy game just to see when vehicles come into production.

A useful feature for the window would be a speed approximation or load simulation for engines. Currently the only way to tell if an engine will meet your shipping requirements is to build a convoy with it in a depot (and probably sell it if it fails) or rely on past experience (you made one before and know what to expect). Experimental sort of has this listing a high and low speed tonnage weighting in the depots but being able to get the exact pull tonnage for a certain speed or determine the speed for a certain pull tonnage would be very useful and seems the sort of feature you would want in a vehicle list window.

Ters


DrSuperGood

QuoteSomething like this tool?
Yes something like that looks like the sort of thing that needs to be built into the game rather than run as an external Java application. Especially since the mathematics governing train speeds and weights is not something most people can do in their heads.

Ters

The problem is that the UI for feeding the calculations of all these things is rather complicated. I'm not sure the GUI framework in Simutrans is up to it. An added bonus is that I can run this application on one monitor, and Simutrans on the other. (For me as a developer, I can even add new features or tweak existing ones without having to close and restart Simutrans. I also would never have made this without the ease at which I can develop and debug in Java compared to C++.) The drawback is that I have to keep the code in sync with Simutrans.

DrSuperGood

QuoteThe problem is that the UI for feeding the calculations of all these things is rather complicated. I'm not sure the GUI framework in Simutrans is up to it.
I think that stems from the render engine used which is fully software based and so has to render everything from the UI to the simulation graphics in a pretty efficient and tightly optimized way so having each element act independently is quite difficult. However even if the UI was not so complicated I imagine something possible that works on a engine by engine basis that uses the value selection fields like the goods list does for speed (and other things in experimental but that seems broken?).

Maybe if Simutrans is operating in windowed mode each pop-up could me made a separate physical window (similar to how the 16 bit simtower did it)? Since modern OS like Windows (and Linux with the write windows manager) hardware accelerate windows this would be pretty useful as not only could you arrange windows accros multiple displays but it would also defer the windows management complexity from the game and its render engine.

Ters

Quote from: DrSuperGood on June 06, 2014, 10:07:14 PM
I think that stems from the render engine used which is fully software based

Not really. It has nothing to do with rendering, but with how the GUI is tied to the underlying data and how events work. In a way, it has more to do with Simutrans' GUI being written in C++, rather than some managed language.

Quote from: DrSuperGood on June 06, 2014, 10:07:14 PM
Maybe if Simutrans is operating in windowed mode each pop-up could me made a separate physical window (similar to how the 16 bit simtower did it)? Since modern OS like Windows (and Linux with the write windows manager) hardware accelerate windows this would be pretty useful as not only could you arrange windows accros multiple displays but it would also defer the windows management complexity from the game and its render engine.

Personally, I don't like such a GIMP-like setup. (GIMP has lately become configurable in that regard.) I feel my desktop becomes an unorganized mess. I can't just move all of Simutrans to my secondary monitor in one go (Shift+Win+Arrow) when I can let it run alone for a short while while I do something else. But window management has nothing to do with why I won't even contemplate porting my Java application into Simutrans.

Ves

I am still stuck. I find myself realizing that I have very little knowledge of this. I have tried to get a clean window to work with, and came as far as only getting one error, but resolving that just creates two new, resolving them creates even more and so on. Tips to create a clean window are most welcome!

Then I wonder, I am supposed to take the vehicle information from somewhere. Should I use vehikel_besch_t or should I look after the information somewhere else?
I suppose that I should keep the _stats -files to gather and organize lists in there?

Ters

Quote from: Ves on June 07, 2014, 12:09:57 AM
Should I use vehikel_besch_t or should I look after the information somewhere else?

vehikel_besch_t is the structure containing information about vehicle types (as opposed to individual actual vehicles), so yes, that should be the thing to use.

Ves

Slowly I get forward, understanding more and more of what is what. I have found other parts that uses the gui_scrolled_list_t and copied it into my parts and it seems that that part is working. However, when I compile I get the error c2512 no appropriate default constructor available for gui_scrolled_list_t::const_text_scrollitem_t and for my own new class: vehiclelist_stats_t


I try to read about it on the net, but I come to short. What should I look for in order to resolve this?

prissi

At some point you are doing a copy or generating an array of stuff. For this first an emtpy element needs to be created, i.e. when you write
scrollitem_t t;

But there are only constructors with text_scrollitem_t( const char *, COLORVAL ), then you get this message.

Ves

#27
Hello dusty Computer!  ;D
I lost my internet connection for several months and also I was away, so no chance of dooing anything usefull. :redx:
But now its back! (the internet) 8)

I already pulled my hair off once, just to let it grow out during the summer and now pulled it half off again!
I completely ended up in a mess with classes and referenses and every error fixed, created 3 more errors! Therefore, I have now torn it all down to a fresh start, this time only working with a class called vehiclelist_frame_t and then skipped the vehiclelist_stats_t.

What I *think* I am suposed to do:
* create and define this vehiclelist_frame_t class and make it work as a window - done and tested with succesfull build and a new window in Simutrans!
* Call all the vehicles, so that I can use them, I suppose this is the method to use(?):

private
static vector_tpl<const vehikel_besch_t *> vehicles;

public
static vector_tpl<vehikel_besch_t const*> const& get_all_besch() { return vehicles; }

At least there are no red lines underneath! And I found some "Baum"-code that kind of did the same.....

* learn how to use the scrolled list.......
When looking in the code, I find many different ways of dooing lists. Eg the curiosity_edit_t looks one way, the baum_edit_t looks similar, yet different, the goods_frame_t have again another kind of using the code not speaking about the citylists. Maybe Im just plain dumb, but when I try to implement one way, I always get behind an obstructle I cant pass. The template you showed in this thread prissi, I have yet to figure out how to use it...

What I have done in the .cc-file so far, I made something that 'fills the list'. So far my logic brain tells me, this is where all the entries to the list is created and beeing 'filled' to the list (im not wrong here?). This peace of code looked similar in most places, and I managed to adapt it to my needs:


void vehiclelist_frame_t::fill_list(bool translate)
{
vehicles.clear();
FOR(vector_tpl<vehikel_besch_t const*>, const i, vehiclelist_frame_t::get_all_besch()) {
if (i) {
vehicles.insert_ordered(i, sort_mode);
}
}
// now build scrolled list
scl.clear_elements();
scl.set_selection(-1);
FOR(vector_tpl<vehikel_besch_t const*>, const i, vehicles) {
char const* const name = translate ? translator::translate(i->get_name()) : i->get_name();
scl.append_element(new gui_scrolled_list_t::const_text_scrollitem_t("vehicle list", COL_BLACK));
if (i == besch) {
scl.set_selection(scl.get_count() - 1);
}
}
}

Under these lines there are also no red underlines!

That peace of code demanded a "sort_mode", so I had to make a compare-section, it currently looks like this:

bool vehiclelist_frame_t::compare(gui_scrolled_list_t::scrollitem_t *aa, gui_scrolled_list_t::scrollitem_t *bb)
{
// if there is a mixed list, then this will lead to crashes!
vehikel_besch_t *a = (vehikel_besch_t *)aa;
vehikel_besch_t *b = (vehikel_besch_t *)bb;
switch (sort_mode) {
case 0: // default
break;
case 1:
return (a->get_topspeed(), b->get_topspeed()) < 0;
case 2:
return (a->get_ware() - b->get_ware()) < 0;
case 3:
return (a->get_zuladung() - b->get_zuladung()) < 0;
case 4:
return (a->get_intro_year_month() - b->get_intro_year_month()) < 0;
case 5:
return (a->get_preis() - b->get_preis()) < 0;
default: break;
// default sorting ...
}
return strcmp(((const_text_scrollitem_t *)aa)->get_text(), ((const_text_scrollitem_t *)bb)->get_text());
};

And it has no red underlines. The get_ -stuff I just putted in there to get something. That should ofcorse be more precise later.

When I try to compile al this, I get these four errors, saying basicaly the same thing:


Error 1 error C2512: 'gui_scrolled_list_t::const_text_scrollitem_t' : no appropriate default constructor available F:\Spel\Utveckla Simutrans\Simutrans källkod\simutrans.14.05.29\simutrans\trunk\gui\vehiclelist_frame_t.cc 19 1 Simutrans
Error 2 error C2512: 'gui_scrolled_list_t' : no appropriate default constructor available F:\Spel\Utveckla Simutrans\Simutrans källkod\simutrans.14.05.29\simutrans\trunk\gui\vehiclelist_frame_t.cc 19 1 Simutrans
3 IntelliSense: no instance of constructor "gui_scrolled_list_t::gui_scrolled_list_t" matches the argument list f:\Spel\Utveckla Simutrans\Simutrans källkod\simutrans.14.05.29\simutrans\trunk\gui\vehiclelist_frame_t.cc 18 5 Simutrans
4 IntelliSense: no default constructor exists for class "gui_scrolled_list_t::const_text_scrollitem_t" f:\Spel\Utveckla Simutrans\Simutrans källkod\simutrans.14.05.29\simutrans\trunk\gui\vehiclelist_frame_t.cc 19 1 Simutrans



The top of the .cc-file (under the #includes) is where the problem is, I suppose.
It looks like this:

vehiclelist_frame_t::vehiclelist_frame_t() :
gui_frame_t(translator::translate("Vehicle list"))
{
}

Here, the third line (with the "{") has a red underline, saying: No defult constructer exist for 'gui_scrolled_list_t::const_text_scrollitem_t'
I look in all kinds of files, to get an impression of what a constructor really is, and moreover what "constructor" I need, but I completely fail here.....

I couldnt make any sence of the "scrollitem_t t;" that you wrote about, prissi. When I put it in the header file, it complains that it is not allowed, that it is a pure virtual function. How would you suggest me to use it?

Am I at all supposed to create a constructor, and since I dont know how, how do I do that?

If anyone wants to comment and/or are willing to push a newbie a little bit in the right direction, just do it! :)

prissi

Sorry, I missed this. If you still work on this: You need to have a vehicle_scrollitem_t which is derived from gui_scrolled_list_t::scrollitem_t. Then this scrollitem need a constructor which takes the besch as parameter.

Using this logic, the list will handle almost everything else by itself.

Yona-TYT


Ves

ok, Im on another computer, so I cant check in the code right now. Am I supposed to create vehicle_scrollitem_t and derive from the gui_scrolled_list::scrollitem_t or is it already there?
I searched trhough the internet about "derive a class" and found some links that I will check.
I will experiement with this as soon I get back to my computer! :-)

Ves

Finally Im getting somewhere!
I created a new class called vehicle_scrollitem_t and after some work, I made it compile again! There is nothing to show at the moment other than the new blank window.
I struggle at the moment to make a correct constructor, I cant really find other usefull constructors based on scrolled list.
When i (in class vehiclelist_frame_t) write:"vehicle_scrollitem_t t;", there is a red underline under the little "t" stating:

ERROR: object of abstract class type "vehicle_scrollitem_t" is not allowed:
Pure virtual function "gui_scrolled_list::scrollitem::get_h" has no overrider
Pure virtual function "gui_scrolled_list::scrollitem::draw" has no overrider
Pure virtual function "gui_scrolled_list::scrollitem::get_text" has no overrider

I found in some code this line:

char const* get_text() const OVERRIDE;

, which I inserted and got rid of one of the errors. I tried to do the same with the other two, but it wouldn allow me to do that.

What am I doing wrong?

prissi

In your class you need to define these functions, i.e. must return the height of the hieghest item, need a fuction to draw and must return a text (like translator::translate(besch->get_name());)

Ves

Ah, ofcorse! (Trying to sound as that was obvious ;-) )

I just keep on digging!

Václav

I support this extension. But where to place button (or so) to show it?

Chybami se člověk učí - ale někteří lidé jsou nepoučitelní