IRC logs for #opendune on OFTC at 2011-06-25
⏴ go to previous day
00:30:46 *** fjb is now known as Guest6137
06:56:53 *** Alberth has joined #openDune
06:56:53 *** ChanServ sets mode: +o Alberth
07:43:30 <DorpsGek> SVN: alberth (r1934) -Add: Remove unused variable_7B68.
07:45:51 <DorpsGek> SVN: alberth (r1935) -Add: removed variable_7B8C, variable_7E0C.
08:21:29 <Alberth> hmm, colours in the palette are 6 bit?
08:53:43 <DorpsGek> SVN: alberth (r1936) -Add: Moved variable_7F9C, variable_7FA0, and variable_7FA1 out of global data.
09:50:34 <Alberth> almost nobody is awake here atm :)
10:05:43 * fjb is away hunting some breakfast.
10:57:28 <DorpsGek> SVN: alberth (r1937) -Add: Moved moving mentat parts coordinates out of global data (variable_8006-variable_8011).
11:30:20 * Alberth found even more mentat variables :)
12:20:00 <TrueBrain> Xaroth|W1rk: I am not talking toy ou in different names, you should know that by now :D
12:21:07 *** Xaroth|W1rk is now known as Xaroth|Work
12:32:20 <Alberth> hmm, you are right, probably until r1801
12:32:29 <glx> ha it was used by 01F7 :)
12:35:54 <glx> are you working on 7FA6 and following ?
12:36:23 <Alberth> 8010-8020 (mentat vars)
12:37:05 <glx> ok I'll do factory then (7FA6)
13:04:24 <glx> or 62964 as widgets and graymap was in it :)
13:07:07 <Alberth> TB was also considering loading everything iirc
13:07:48 <glx> I think I'll go for a static 64000
13:08:30 <glx> checking something (like how it's drawn)
13:14:50 <DorpsGek> SVN: glx (r1938) -Fix: moved factory window static variables out of g_global
13:18:52 <glx> well we mix fix and add ;)
13:19:14 <glx> and it seems the buffer is probably not needed
13:19:50 <DorpsGek> SVN: alberth (r1939) -Add: Named global mentat animation variables, and moved them out of global.
13:21:02 <glx> ok buffer is needed else malloc asserts
13:36:09 <TrueBrain> there is not really a word for what we are doing :p
13:36:15 <TrueBrain> but that is too many letters
13:51:38 <glx> as we don't chek free space anyway
13:55:44 <TrueBrain> I want to replace the numbers with ENUMs at some point btw
13:55:58 <TrueBrain> and uint16 .. didn't we have an ActionType or something?
13:56:29 <TrueBrain> as it is a C-file, feel free to include what-ever header is needed
13:56:48 <glx> unit.h is needed (and already included)
13:57:10 <Alberth> nice, a ready-for-use enum :)
13:57:37 <Alberth> yeah, I already checked that it compiled :)
13:59:56 <DorpsGek> SVN: glx (r1940) -Fix: we always assume there is enough free space on the disk, so no need to check that
14:08:42 <DorpsGek> SVN: alberth (r1941) -Add: Move actionsAI from global data to a table.
14:09:13 <Alberth> I kept the uint16, as there are pointer types attached to that size.
14:09:42 <Alberth> (and many other such arrays)
14:10:44 <TrueBrain> sorry, I don't understand?
14:11:07 <TrueBrain> g_table_actionsAI is only used in assigning, so his type is irrelevant for other parts of the code?
14:12:19 <TrueBrain> I don't see why having it an uint16 is better than an ActionType?
14:12:30 <TrueBrain> (I don't understand what you mean with "pointer types attached to that size")
14:13:13 <DorpsGek> SVN: glx (r1942) -Add: removed variable_2A9B
14:17:14 <TrueBrain> owh, I guess you worry about the actionPlayer, which is in ObjectInfo. ObjectInfo is now a full normal struct, so it should be changed into an ActionType too :)
14:24:57 <Alberth> I worry about uint16 *action vars that point into the table
14:26:03 <TrueBrain> well, change them all to ActionType :D:D :)
14:26:16 <TrueBrain> unless of course it is stored in Unit, but I thought it wasn't/
14:26:33 <Alberth> obviously that is the next step, but it *is a next step* imho
14:26:57 <TrueBrain> I don't care; even if it is 1000 steps from now :p
14:27:02 <TrueBrain> I just tried to understand what you were saying
14:28:00 <TrueBrain> I see many actionType variables are not converted yet (both type as enum)
14:28:17 <Alberth> they are all waiting for you :)
14:28:27 <TrueBrain> other fish to fry first
14:29:46 <DorpsGek> SVN: glx (r1943) -Fix: moved saveload static variables out of g_global
14:30:50 <TrueBrain> that is what I meant
14:31:02 <TrueBrain> doesn't compile because ActionType is not known in object.h :P
14:31:45 <Alberth> something in that direction indeed :)
14:32:14 <Alberth> although I am surprised it is such few changes
14:32:18 <TrueBrain> (I am not going to finish that patch; I was just trying to understand what you found as problem to keep uitn16)
14:32:31 <TrueBrain> I can't find any other constraints regarding :)
14:33:56 <TrueBrain> anyway, I have to make an assignment regarding Pareto ...
14:34:02 <TrueBrain> wish I understood the explenation :D
14:40:39 <Alberth> as in 80% of your problems originate from 20% of the assignments? :p
14:42:20 <TrueBrain> Pareto Optimal solutions, to be exact
14:42:24 <TrueBrain> Pareto did a bit too much tbfh :P
14:46:04 <Alberth> yeah, it looks very complicated
14:47:21 <TrueBrain> lucky we have google
14:49:09 <DorpsGek> SVN: alberth (r1944) -Fix: Change of a csip variable to its native pointer type.
14:49:27 <Alberth> unfortunately, the teachers are also aware of it
14:50:40 <Alberth> with one revision before the end of WW II, I am afk now to make some diner.
16:06:35 <DorpsGek> SVN: glx (r1945) -Fix: moved playerHouseID, gameMode, scenarioID and campaignID out of g_global
16:06:49 <glx> removed a lot of (uint8) casts ;)
16:17:02 <glx> maybe PoolFindStruct could have uint8 instead uint16 for type and houseID
16:21:32 <glx> hmm index is still uint16 for objects and houses
16:27:15 <DorpsGek> SVN: alberth (r1946) -Fix: Moved variable_2582 out of global data.
16:48:57 <DorpsGek> SVN: glx (r1947) -Fix: use uint8 for all houseID
16:49:17 <glx> (and removed all unused stuff from House struct
17:48:25 <DorpsGek> SVN: alberth (r1948) -Fix: Remove some mentat help variables from global.
17:51:06 <glx> hmm seems I broke savegame loading
17:52:09 <Alberth> it loads the unused data?
17:53:02 <glx> saving is broken too I geuss
17:53:21 <Alberth> that would be a quite safe bet :)
17:54:33 <glx> save/load is ok, if you ignore old savegames ;)
17:56:49 <TrueBrain> glx: lol; didn't I told you about that? :P :P
17:56:54 <TrueBrain> we need our own Save/Load routines :)
18:02:38 <TrueBrain> maybe something like OpenTTD
18:02:45 <TrueBrain> a struct which says which field of which size?
18:05:36 <TrueBrain> you on that glx, or can I? :D
18:26:38 <glx> for now I'll partly revert r1947
18:27:01 <glx> and let you do the savegame stuff
18:27:28 <TrueBrain> just hold off with that a bit then ;)
18:28:01 <TrueBrain> hardest part was writing a offset() function
18:31:39 <TrueBrain> bah; ai_structureRebuild
18:32:07 <glx> remember I removed 8 bits from flags
18:33:06 <TrueBrain> ah, good point, tnx
18:33:09 <glx> 8 bits from index and 16 bits between palacePosition and variable_24
18:33:56 <TrueBrain> hmm ... I now wonder how to do this nicely
18:34:04 <TrueBrain> I remember OpenTTD's approach was always a bitch to work with
18:35:02 <Alberth> yes, I agree it is somewhat messy, especially the long save game conversion functions
18:35:42 <TrueBrain> on the other hand, it still loads REALLY old savegames
18:35:49 <TrueBrain> which is why I am in doubt :D
18:36:19 <Alberth> if you generate loading/saving code, you don't need the meta offset stuff
18:36:43 <glx> nnice thing, dune2 has version in the savegame
18:37:38 <Alberth> save_field(x.field1); save_field(x.field2); etc has no implicit need in offsets of x.fieldY
18:37:59 <Alberth> glx: wow, they were far ahead of their time :)
18:38:05 <TrueBrain> ah, yes it does Alberth :P
18:38:26 <TrueBrain> x.field1 only works in defines :)
18:38:54 <Alberth> well, p->field1 then :)
18:39:03 <TrueBrain> still doens't work in structs
18:40:04 <glx> current version is 0x0290 and it even has mecanism to load different version
18:41:22 <TrueBrain> maybe that makes it more clear to you why an offset() is required
18:43:58 <Alberth> yes, if you want a list of fields to store, you need it. I was talking about saving each field directly, not through a data structure
18:44:53 <TrueBrain> which is a bit nasty :D
18:45:22 <TrueBrain> I really like that part of OpenTTD .. but I dunno .. it is difficult :P
18:45:47 <Alberth> I mentioned code generation for a reason :p
18:47:13 <Alberth> which basically takes your list of fields, and turns them into my saves/loads
18:47:30 <TrueBrain> yeah .. I don't like code generators :D
18:47:36 <TrueBrain> causes deps in projects
18:48:35 * Alberth graduated in compiler construction :)
18:50:51 <Alberth> not to mention that I built compilers and simulators for the last 13 or so years :D
18:51:32 <Alberth> although down to C level only
18:51:43 <TrueBrain> just doesn't work for these projects I experienced ... projects grow away from the resulting code, and people lose knowledge of those tools :P
18:52:44 <Alberth> no problem, just thought I should explain a bit where I am coming from :)
18:54:52 <glx> static inline void *GetVariableAddress(const void *object, const SaveLoad *sld)
18:54:52 <glx> return (byte*)(sld->global ? NULL : object) + (ptrdiff_t)sld->address;
18:54:52 <glx> you'll need something like that too
18:55:28 <glx> sld->address being offset in your code
18:56:00 <TrueBrain> just to show my idea
18:56:43 <glx> (((uint8 *)&hl) + sd->offset) <-- that is the GetVariableAddress ;)
18:58:30 <TrueBrain> now if only I had a clue why it fails .... :P
18:59:04 <glx> when loading uint16 into uint8 maybe
18:59:36 <TrueBrain> length -= sizeof(House)
19:02:10 <glx> maybe need a function to get size of SaveDesc data
19:02:19 <TrueBrain> yeah, for a bit later :)
19:03:16 <glx> oh and you inverted memory and disk
19:03:44 <glx> anyway hawaii 5.0 for me now
19:10:59 <TrueBrain> oeh, savegames load
19:13:08 <TrueBrain> what do you guys think?
19:13:49 <TrueBrain> don't want to do arrays atm :P Will fix them when I make it more general tbh :P
19:14:52 * Alberth misses all forms of documentation :)
19:15:07 <Alberth> shouldn't we add version numbers as well?
19:15:09 <TrueBrain> oogkleppenopzetten and only look at the code :P
19:15:37 <TrueBrain> yeah, versions should be added at some point
19:15:59 <TrueBrain> for now I was thinking we keep it simple, and keep storing in the method designed by Dune2
19:16:08 <TrueBrain> so Dune2.exe can also load our savegames
19:19:27 <Alberth> sd->type_memory <-- doesn't that switch need to examine sd->type_disk to know what you just loaded?
19:20:19 <Alberth> if I save a UINT16 and store it in memory as UINT32 for example
19:20:40 <TrueBrain> follow what happens plz :D
19:21:39 <glx> doesn't the second switch warn ?
19:21:41 <Alberth> oh, it is much smarter!
19:22:53 <glx> there's already 2 versions :)
19:23:19 <Alberth> do we put the 'break' outside the curly brackets? it looks ugly imho
19:23:25 <TrueBrain> yeah .. if we can get !0x0290 savegames and how they look, we can figure it out :P
19:23:45 <TrueBrain> my habbit of programming tbh
19:23:55 <TrueBrain> easier to read for me .. dunno if we have a coding style for it :P
19:24:28 <TrueBrain> used a lot already :P
19:24:38 <TrueBrain> so it now is coding style :D Sorry Alberth :P
19:24:47 <TrueBrain> the reason I like this, is because I dislike C needed the break :P
19:25:03 <TrueBrain> it should always be break, and some statement to explicitly allow flowing through
19:25:29 <TrueBrain> this way I always remember to put the breaks; there, as they are not inside the code block
19:25:34 <TrueBrain> (as it is unrelated to the code block)
19:26:25 <TrueBrain> aren't all reasons regarding coding style stupid?
19:27:04 <Alberth> possibly, but if we all find the same thing non-stupid, it is ok ;)
19:28:32 <Alberth> but on this we are not going to agree on non-stupidness, I am afraid
19:29:43 <TrueBrain> hmm ... I only moved everything to other places, and now it doesn't want to load :(
19:39:19 <TrueBrain> comments on missing anything?
19:39:25 <TrueBrain> parameters in right order?
19:43:46 <TrueBrain> was thinking about first reading the index, and reading the rest directly at the right place ..
19:43:52 <TrueBrain> but not sure if that is general enough?
19:44:55 <glx> theorically index is always the first but better safe than sorry
19:46:06 <glx> and it won't be uint16 on disk forever
19:46:36 <TrueBrain> although Houses will :P
19:47:29 <glx> index is already uint8 in memory
19:50:23 <TrueBrain> reading the whole struct at once
19:51:05 <TrueBrain> quick fix for broken free() :D
19:51:59 <TrueBrain> I am not sure if the penalty for malloc() is better or worse than doing fread over and over
19:57:04 <Alberth> fread gets cached by c lib
19:57:29 <TrueBrain> so fread() is better?
19:59:30 <Alberth> disk IO is slow anyway, and you are not loading MBs, so I'd do fread yeah
19:59:43 <Alberth> the #define's need doxycomments
19:59:57 <TrueBrain> yeah, I don't know how to do doxygen around #defines
20:00:11 <Alberth> just like function parameters
20:00:47 <Alberth> fields of the SaveLoadDesc needs some explanation too
20:02:01 <Alberth> extern bool House_Save(FILE *fp); <-- you kept that in src/house.h on purpose?
20:02:18 <TrueBrain> patch has Save incomplete
20:02:30 <TrueBrain> got sidetracked by the malloc idea :D
20:03:29 <Alberth> if fread() is too slow, it should be easy to make a static buffer of 1K or so
20:04:02 <Alberth> I am not sure how useful it is to have length in bytes, a count would be sufficient, right?
20:05:54 <TrueBrain> new patch, working save()
20:06:17 <TrueBrain> if this is what you mean: for loading we know the size of the chunk
20:06:21 <TrueBrain> that doesn't tell us anything really
20:06:35 <TrueBrain> so we need to have some notion of byte-size to know when we are done reading the chunk
20:07:27 <TrueBrain> OpenTTD for example does it by storing an entry with index of -1
20:07:28 <Alberth> it would be useful to store the #houses first somewhen in the future :p
20:07:31 <TrueBrain> but Dune2 never does :(
20:08:00 <TrueBrain> although I believe even OpenTTD does it by counting bytes in the background
20:08:04 <TrueBrain> not sure .. to long ago :P
20:08:16 <TrueBrain> good thing about byte counting, even broken savegames are detected :D
20:08:38 <TrueBrain> but we can hide the length stuff a bit, by unifying it
20:09:09 <TrueBrain> another update to my patch
20:09:40 <TrueBrain> and Alberth, first I passed a uint32 *length to SaveLoad_Load, to keep track of the length .. but that is even more ugly :D
20:10:11 <Alberth> I didn't see that version :)
20:10:13 <TrueBrain> glx: if your serie is done, can you spin this through MSVC, see if it complains? (I think I have all correct casts)
20:10:30 <TrueBrain> my doxygen comments can use work, but meh .. at least I wrote something :D
20:11:52 <glx> Erreur 1 error C2065: 'House_Save' : identificateur non déclaré d:\developpement\opendune\trunk2\src\save.c 171
20:12:20 <Alberth> why do you keep such big distances between eg enum fields and doxygen comment?
20:14:32 <TrueBrain> Alberth: _all_ comments start at position 61 with tab-size 4
20:14:45 <Alberth> return (length == 0);
20:15:15 <Alberth> possibly without the parentheses :)
20:15:30 <TrueBrain> even (length == 0) ? a : b, in our code please :D
20:16:39 <Alberth> yeah, I prefer that too :)
20:17:02 <Alberth> +static SaveLoadDesc s_saveHouse[] <-- I was pondering src/table/saveload.c
20:17:42 <TrueBrain> I was considering src/table/saveload_house.c
20:17:45 <TrueBrain> but it became so long
20:17:58 <TrueBrain> and this also allows me to store the 2 save/load functions, which are directly related to them
20:18:21 <Alberth> ok, leave it as it is :)
20:19:03 <Alberth> seems ok, except for the @param entries of the #define 's
20:19:49 <glx> gcc and msvc compiles cleanly
20:19:53 <Alberth> you typed the hard parts already :)
20:24:23 <TrueBrain> Alberth: better? :D
20:25:11 <Alberth> I am completely happy now ;)
20:27:14 <DorpsGek> SVN: truebrain (r1949) -Add: introducing a more feature save way of Save/Load, which also resolves the loading issues introduced in r1947 ;)
20:27:25 <TrueBrain> now Structure and Unit ... which are much harder :P
20:29:37 <Alberth> we know you like a challenge :)
20:30:31 <TrueBrain> think I make an Object one
20:30:35 <TrueBrain> and a Structure and Unit one
20:30:39 <TrueBrain> and a ScriptEngine one
20:30:45 <TrueBrain> to avoid duplication
20:31:10 <Alberth> structure and unit so closely related?
20:32:04 <Alberth> hmm, pehaps I should read more code :)
20:32:41 <TrueBrain> Structure and Unit both have Object and ScriptEngine
20:33:08 <glx> ScriptEngine is part of Object :)
20:33:36 <Alberth> sounds like a class hierarchy :)
20:37:59 <glx> any objection if I try to add something for arrays ?
20:38:16 <TrueBrain> should not be too hard
20:38:35 <Alberth> and something for pointers :p
20:39:30 <glx> we don't save pointers for now I think :)
20:40:47 <TrueBrain> well, we have a few pointers
20:40:50 <TrueBrain> in ScriptEngine for example
20:40:55 <TrueBrain> but that will be special types
20:41:07 <glx> they are still csip for now
20:41:22 <TrueBrain> yeah ... but not for long :D
20:41:28 <TrueBrain> k, going to do Structure / Unit / Object / ScriptEngine
20:41:31 <TrueBrain> first, the easy way ;)
20:54:07 <TrueBrain> I kinda need your patch for arrays for that
20:54:10 <TrueBrain> so I will wait for that a bit :D
20:57:11 <TrueBrain> I have some more types to add after that :D
20:57:16 <TrueBrain> DIR24, INT8, INT16, INT32
21:29:03 <TrueBrain> GetLength is a bit of a waste ;)
21:29:09 <TrueBrain> why not make a temp var, and multiply?
21:29:36 <TrueBrain> why count from count to 0
21:29:39 <TrueBrain> and do tricky substraction?
21:29:46 <TrueBrain> isn't counting from 0 to count easier then?
21:30:36 <TrueBrain> and count a size_t .. isn't size_t only for pointer casts?
21:30:46 <TrueBrain> uint16 or uint32 better? (asking, don't know the answer)
21:37:37 <TrueBrain> scriptly another bracket is not needed for + i, but fair enoguh :)
21:39:31 <TrueBrain> sld_offset is also a byte-offset
21:39:44 <glx> *((uint16 *)(((uint8 *)object) + sld->offset) + i) <-- without the extra parenthesis I need to * sizeof(uint16)
21:41:42 <DorpsGek> SVN: glx (r1950) -Add: support for loading/saving arrays
21:45:37 <glx> about dir24, I'll integrate the struct in Unit struct
21:51:44 <glx> btw it won't fix the problem ;)
21:52:03 <glx> it's still an array of struct
21:53:01 <glx> idea: recursion in SaveLoadDesc :)
21:55:37 <TrueBrain> let me do my patch first ;)
21:55:40 <TrueBrain> then it is all yours :P
22:05:49 <TrueBrain> depends on alignment what happens there
22:06:40 <TrueBrain> your idea of recursion would solve it too
22:06:46 <TrueBrain> so you can do that after me, and make this ugly I am doing nicer :D
22:11:49 <TrueBrain> please, wait for my patch :P
22:11:53 <TrueBrain> it will collide so hard
22:12:39 <glx> yes I'll wait (I need your stuff to test mine)
22:13:02 <TrueBrain> k, it compiles, lets ship it
22:13:37 <TrueBrain> amasing, it also works!
22:15:06 <glx> why not use UINT32.. for INT32... ?
22:15:19 <TrueBrain> I remember that from OpenTTD
22:15:26 <TrueBrain> it is possible for int32
22:15:32 <TrueBrain> but when going to uint64
22:15:36 <TrueBrain> it gave problems again
22:15:39 <TrueBrain> which took HOURS to find
22:15:44 <TrueBrain> so kinda want to do it clean :D
22:16:20 <TrueBrain> can you try it in MSVC btw, to see if I didn't add warnings?
22:23:25 <DorpsGek> SVN: truebrain (r1951) -Add: also move Unit and Structure (and with that ScriptEngine and Object) to new SaveLoad method
22:23:47 <TrueBrain> I am thinking about adding a SLD_ that allows a callback proc
22:23:51 <TrueBrain> for the scriptengine pointer
22:25:42 <TrueBrain> first going to see for callback
22:30:26 <TrueBrain> ugh, my callback idea won't work till we make real pointers out of it I think
22:32:06 <TrueBrain> hmm .. I have some ideas
22:32:10 <TrueBrain> but I am going to wait till you are all done with it
22:32:14 <TrueBrain> not sure how big of an impact :D
22:42:29 <TrueBrain> doxygen comments ;)
22:42:47 <TrueBrain> owh, it is fine in fact
22:42:52 <TrueBrain> meh .. we need to fix the defines anyway :P
22:43:04 <TrueBrain> const struct SaveLoadDesc *sld; /*!< The SaveLoadDesc. */
22:43:11 <TrueBrain> the rest is AWESOME
22:43:25 <glx> noticed the align fail ;)
22:44:40 <TrueBrain> something feels off atm ..
22:44:56 <TrueBrain> owh, it is my local patch
22:45:27 <TrueBrain> I hope your patch solves it
22:45:57 <TrueBrain> all units point north when loading a savegame with trunk
22:46:11 <TrueBrain> and 1951 is to blame
22:46:13 <TrueBrain> dir24, I would guess
22:46:19 <DorpsGek> SVN: glx (r1952) -Add: support for loading/saving embeded structs
22:49:00 <TrueBrain> I am now working on unit.h and structure.h btw
22:50:13 <TrueBrain> but it seems I broke something again :P
22:50:45 <TrueBrain> or something still depends on offsets .. dunno ..
22:53:19 <TrueBrain> GetLength returns wrong value
22:54:06 <TrueBrain> it is your fault :D
22:54:22 <glx> oh missing a * sld->count
22:54:43 <DorpsGek> SVN: truebrain (r1953) -Fix (r1952): SLD includes can also be repeated
22:55:03 <glx> strange my saves loaded correctly
22:55:34 <TrueBrain> can you add Team please? :D
23:04:01 <DorpsGek> SVN: truebrain (r1954) -Fix: made Unit/Structure length-independant removed unused variable from Unit struct, cleaned up all PACKS and no-longer-needed comments around [Unit|Structure|Object][Info]
23:04:07 <TrueBrain> there ... readable code :D
23:04:18 <TrueBrain> when Team is done, ScriptEngine can also be done
23:05:05 <DorpsGek> SVN: truebrain (r1955) -Fix: some alignment to hopefully improve readability a bit
23:05:41 <TrueBrain> script delay of units is reset upon load .. but not that of structures
23:16:09 <TrueBrain> right; enough coding for me for one day :D
23:35:53 <DorpsGek> SVN: glx (r1956) -Add: move Team to new SaveLoad method and cleaned Team struct
continue to next day ⏵