Times are UTC Toggle Colours
01:38:58 *** tycoondemon2 has joined #openttd.dev 01:43:44 *** tycoondemon has quit IRC 06:53:26 *** Supercheese has quit IRC 14:30:40 *** Knogle has quit IRC 14:32:11 *** Knogle has joined #openttd.dev 17:00:26 *** Zuu has joined #openttd.dev 17:00:26 *** ChanServ sets mode: +v Zuu 18:04:41 *** Alberth has joined #openttd.dev 18:04:41 *** ChanServ sets mode: +v Alberth 18:42:47 <fonsinchen> "waiting via" can also be done without cdist. It will just always return INVALID_STATION 18:42:58 <fonsinchen> Same with all the planned stuff actually 18:55:07 <Zuu> I've updated the patch. It adds ScriptStation::GetCargoWaitingFrom, ScriptStation::GetCargoWaitingVia and ScriptCargo::GetDistributionType. The later makes it easier to write the doxygen @pre as well as making it easier for AI/GS authors as they don't need to map a cargo to which setting to look at. 18:55:29 <Zuu> http://devs.openttd.org/~zuu/010-ai-cargodist.patch 18:56:37 <Zuu> It contains a lot of auto-generated code at the beginning, but you can scroll down to script_station.cpp for implementation of the core functionality of this patch. 18:57:25 *** Supercheese has joined #openttd.dev 18:57:25 *** ChanServ sets mode: +v Supercheese 18:57:37 <Alberth> INVALID_DISTRIBUTION_TYPE = -1, negative enum literals is usually a bad idea 18:58:02 <Zuu> Script API returns negative results usually on pre condition fail. 18:58:36 <Alberth> enums may or may not be signed, and has an undefined length (iirc) 19:01:21 <Zuu> See for example COMPANY_INVALID in script_company.hpp 19:01:47 <Alberth> can be, but you have no guarantee that the value is actually negative, I think 19:02:40 <Alberth> although all our current implementations may do that 19:02:50 <Zuu> The actual enum value is not described in the docs. Instead script authors are asked to use the enum constants. 19:03:30 <Zuu> But I do agree with you that it looks a bit unsafe, but somehow it works. And well, I didn't invent the way it works, just follows the convention here. 19:04:20 <Zuu> But I could change INVALID_DISTRIBUTION_TYPE to 0xFF or so. 19:04:37 <Zuu> Hopefully fonsinchen will never invent more than 254 distribution types. :-) 19:04:38 <Alberth> fair enough, perhaps something to fix for another day 19:05:02 <Alberth> if you fix it, you should fix all negative values, imho 19:05:19 <Alberth> and this close to the release date seems a bad time to do so 19:05:29 <Zuu> Changing the enum values will be quite hard to do. Scripts may store there values in the save game even if they never hard code the actual value inside their source code. 19:07:09 <Zuu> Or even 0xFFFF as invalid distribution type should probably also work. Though that assumes the enum is larger than 8 bits. 19:08:50 <Alberth> in C++, an enum is big enough to fit the largest value 19:09:14 <Alberth> don't know what squirrel assumes here 19:10:18 <Zuu> As I understand it, Squirrel use some bit length for all integers. 19:10:31 <Alberth> C++ does not say it will not be larger though :) using uint32 for all enums is a valid option 19:11:24 <Zuu> API methods that does not use an enum type, usually return int32. So I guess that is what Squirrel uses too. 19:11:37 <Alberth> I'd have to check the definitions, but it seems likely that C++ does something similar 19:11:46 *** frosch123 has joined #openttd.dev 19:11:46 *** ChanServ sets mode: +v frosch123 19:11:52 <Alberth> yeah, just regular "int" 19:13:37 <Alberth> just let it be as-is, we already have the -1 problem, adding one more case isn't that much more complicated 19:16:00 <frosch123> + if (!IsValidStation(from_station_id); <- how does that compile? 19:16:15 <Zuu> frosch123: It doesn't. Patch updated. 19:16:35 <frosch123> ottd puts & and * right-associative 19:17:55 <Zuu> I should know that, but .. bad habit 19:18:13 <frosch123> i also have to switch between ottd and work every time :p 19:19:06 <frosch123> + * See how much cargo with a specific source station there is waiting on a station. <- s/on/at/ ? 19:19:18 <Zuu> I should note that I have tested GetCargoWaitingVia but not GetCargoWaitingFrom. 19:20:36 <Zuu> GetCargoWaiting also use "... waiting on a station" which doesn't feel right to me, but since the new methods are variants of that one I did follow its wording. 19:21:00 <frosch123> ok, no idea then :p 19:27:57 <fonsinchen> Zuu: There is a better way to get GetCargoWaitingVia 19:28:08 <fonsinchen> In fact what you're doing there is probably wrong 19:28:30 <fonsinchen> Well, it's not wrong, but do use equal_range please 19:28:41 <fonsinchen> And don't forget INVALID_STATION 19:29:17 <fonsinchen> You can just expose the trick with INVALID_STATION to the script, though 19:30:13 <fonsinchen> In that case you shouldn't filter it. All cargo that doesn't have a specific destination has the destination of INVALID_STATION. A script might be interested in that. 19:30:39 <fonsinchen> Also, you don't really have to filter DT_MANUAL 19:31:02 <fonsinchen> In case of DT_MANUAL all cargo will have INVALID_STATION as next hop 19:31:16 <fonsinchen> Oh, above s/destination/next hop/g 19:33:03 <fonsinchen> Actually, even the "from" value can legally be INVALID_STATION if the origin of the cargo has been deleted. 19:33:11 <Zuu> INVALID_STATION is handled for From by allowing from_station_id to be INVALID_STATION. For Via I probably didn't knew if it was possible. 19:33:41 <fonsinchen> if (!IsValidStation(from_station_id)) return -1; 19:33:49 <fonsinchen> ^You should drop that then 19:34:21 <Zuu> Hmm. Oh sorry. Yes it is Via that accepts INVALID_STATION as argument, but not From. 19:34:22 <fonsinchen> or add a special case for INVALID_STATION as opposed to some invalid ID which is not INVALID_STATION 19:34:45 <Zuu> But I see your argument for allowing INVALID_STATION also for From. 19:36:47 <frosch123> for From invalid-station is valid, if the source station was removed or so 19:37:57 <Zuu> Yep, I'll change that. As well as dropping DT_MANUAL pre condition and instead add a note about what will happen in that case. 19:55:14 <Zuu> Updated patch. Now uses equal_range. Allows INVALID_STATION for both APIs. DT_MANUAL @pre has been dropped. 22:02:25 *** frosch123 has quit IRC 22:18:54 *** DorpsGek changes topic to "OpenTTD Dev Channel || Latest SVN: r26396 || Logs: http://webster.openttdcoop.org/?channel=openttd.dev || Voice (talk-right) upon request via #openttd; make sure you are registered to NickServ before asking" 22:57:57 *** Alberth has left #openttd.dev 23:07:33 *** Zuu has quit IRC