Hello ezee.
I must say I am quite impressed with what you have produced. I have only seen the code on the forum (haven't downloaded it yet), but I am happy to see you have use for my code. Here are a few comments which may help you on your quest.
I am trying to port your code in a visualstudio9 solution .
I am glad you have succeeded with your efforts, since it produced results, but I would like to suggest you take a look at CMake. CMake is capable of creating vs9 solution files which you can use in your IDE, and also the system used by vegastrike proper.
http://www.cmake.org/cmake/help/runningcmake.html may help you on your way. I am also eager to know about any problems it gives on windows, since that is a platform I haven't used in a development sense in a while.
On that note, Also thank you for posting your changes. They are most informative and will help me maintain platform independence in future code I write.
#ifdef WIN32
float cargoMass = atof(this->attributes["mass"].c_str());
strtof is a c++11 function which outputs a float, atof returns a double but works on pre-c++11 code. If this is the only c++11 function in use and/or c++11 code is a problem, I suggest we change the code to the atof version for both win32 and non-win32 platforms.
Cargo is something that i would better define in the actual API .
I am not really sure where you got CargoHolder from, since I do not find it in the code i have here present, but let me tell you the history of Cargo.
"Cargo" started its life as vegastrikes Cargo class. Aside from the not-economy junk, it represented an amount of one thing. So it is 1 ganja, or it is 10 ganja, or 3 rhum; but not 1 ganja and 3 rhum. Also, all this not-economy junk about what exactly a ganja is would have been carries with all the amounts of ganja in the galaxy, which sizewise, was a lot. Hence i moved most of that stuff over to cargotype, since, a ganja's a ganja's a ganja. who cares which, which left cargo being an int, and a pointer of sorts to that other class.
The concept 'Cargo', to me, has the idea of "a bunch of stuff". this stuff is not necesarily anywhere specific, but can be any amount of any amount of goods. Gamewise, this would also allow to keep track of mission cargo, by having it in its own virtual container, rather then piled together with the rest of your junk (even though it is really still all lumped together in this virtual reality. Hence I brought in the datastructure to include some of anything. Basically is just a pimped out STL template.
But i just realized that i can now simply rename: Cargo Container;
I would have no problem with that. The code may already be too far gone from the vegastrike Cargo that integrating them will be difficult regardless of my planned efforts.
Economy is at the top of the system , in Vegastrike i would use it like it :
Economy * ConfedEconomy ;//general faction economy
Economy * AeraEconomy ;//general faction economy
Personally I was thinking about one global economy in order to escape the probability of having a cargo run through two economies. Who controls which resource is determined by whoes governor controls which planet/ship/othercargocontainer. The economical comparion example you gave can then still be done by keeping a list of governours per faction, and have them do the counting... Maybe they can even 'lie' if they are desperate enough or otherwise persuaded (not something i think for the near future, but one can dream).
Though it is probably because it is a 'quick example', but I'd advice aside further explicitly defining the factions in code. There are already a few vegastrike mods and having them needing to change that all in-code is a tedious process. Regardless of how the economies are defined though, you can certainly still have individual economies.
I lack a quote for this one, but you mentioned the idea of running the economy clock once a frame or once per second. Though the current economy simulation can easily provide that, even with multidigit numbers in the bigtest one, I myself was more thinking along the line of once per minute, or longer. In vegastrike, you easily spend more time then that in space, so it seems wasted resources to me to simulate at that speed whilst it is not interacted with. Besides, the merchant doesn't get his shipments one bullet at the time either.
The hardcore way is to use the Governor class of the Market as an AI agent
Hot damn. I am very impressed. What i came up with was something that periodically checked how much resources were available and activate the first factory that could provide something when it needed it. Yours is quite a lot more sophisticated.
The idea of the governor class is to have multiple possible systems around. One can divide by faction, planet, randomly, or some other factor. These governers would indeed need to know the concept of credits and be able to send messages to eachother that they need good x or y for some reason (e.g., governator realises not much mining can be done on a starbase, so you need to get stones from elsewhere).
The factories (or rather, the cargoes, bubbling up through the factories) can definitely emit events when unable to do production, though I am not sure whether the governor be the one alerted to it. I have not much experience in c++ so I decided to stay away from exceptions for the time being, as their specifics were not very familiar to me.
I think we should attempt to make Market Cargo inherit from VS Cargo , thus making
market cargo accessible in the VS source code , as a normal VS Cargo .
If i read my doxygen graphs correctly (site should still be up), the Cargo code should only be touched by the buy cargo interface code and the cargo holds. It may not be too hard to replace vegastrikes' stock Cargo with the market cargo altogether.
It is getting late, i will comment more later. Again, I am very impressed with your efforts. I hope these words will help you on your way.