#nuvie@irc.freenode.net logs for 10 Aug 2006 (GMT)

Archive Today Yesterday Tomorrow
Nuvie homepage


[00:00:19] <Yuv422> I was thinking about indenting yesterday
[00:00:30] <Yuv422> I would like to clean it up
[00:00:43] <Yuv422> I'm just changing over to tabbed indenting
[00:00:49] <Yuv422> ts=2
[00:00:59] <Yuv422> what do you use?
[00:01:53] <luteijn> hmm, I use vim, with shiftwidth of 2, not tabs but spaces to avoid weird layout when tab-width is mismatching.
[00:02:11] <Yuv422> right
[00:02:27] <Yuv422> I can set my editor to use 2 spaces too
[00:02:44] <Yuv422> I hit tab and get 2 spaces
[00:02:54] <Yuv422> sounds like a better plan really
[00:03:14] <luteijn> some things to consider are if you indent the { on the next line after an if.
[00:03:14] <Yuv422> if(exp)
[00:03:15] <Yuv422> {
[00:03:19] <Yuv422> code;
[00:03:21] <Yuv422> }
[00:03:38] <luteijn> I prefer that one, or even:
[00:03:43] <luteijn> if (exp) {
[00:03:49] <luteijn> blah;
[00:03:55] <luteijn> } else {
[00:04:02] <Yuv422> I'm not a big fan of (exp) {
[00:04:02] <luteijn> bleh;
[00:04:04] <luteijn> }
[00:04:15] <Yuv422> I like the new line
[00:04:18] <Yuv422> :)
[00:04:27] <luteijn> I can live with it, so lets newline ;)
[00:04:37] <Yuv422> yup :)
[00:05:03] <Yuv422> I will reformat the code
[00:05:08] <Yuv422> at some stage
[00:05:09] <luteijn> I like to put the ; on the last line of the {} block, (so it's easy to add new lines below it).
[00:05:12] <Yuv422> probably soon
[00:05:52] <Yuv422> can you give an example?
[00:06:02] <luteijn> and also I prefer to always use a {}block after an if, even if you're just doing a 'return x'.
[00:06:08] <luteijn> example:
[00:06:15] <luteijn> if (aap)
[00:06:16] <luteijn> {
[00:06:22] <luteijn> statement;
[00:06:26] <luteijn> statement;
[00:06:49] <luteijn> statement //doesn't need ; as end of block
[00:06:55] <luteijn> }
[00:07:32] <luteijn> i usually put the ; in anyway, so you can put in more statements without risking a missing ; later on.
[00:07:55] <luteijn> if (foo)
[00:08:04] <luteijn> return false;
[00:08:57] <Yuv422> oh yes
[00:09:05] <luteijn> is dangerous too, later on you might want to add something, and break the logic. so I just put the 'then' part into a block.
[00:09:10] <Yuv422> I always add the last ';'
[00:09:33] <Yuv422> have you ever seen this typo
[00:09:37] <Yuv422> if(exp);
[00:09:44] <Yuv422> statement;
[00:10:06] <Yuv422> that can be hard to find at times. ;-)
[00:10:28] <luteijn> never been hit by it, I usually get errors for missing semicolons instead ;). also I usually write:
[00:10:33] <luteijn> if (aap) {
[00:10:39] <luteijn> statement;
[00:10:49] <luteijn> } so it's harder to get a ; in the wrong place.
[00:12:47] <Yuv422> I find that harder to read
[00:14:19] <luteijn> well, the indentation already shows where it goes.. And I don't like to waste many lines with just a { or } on it. another thing I do is use lots of nested () to try to avoid issues with operator precedence.
[00:16:28] <Yuv422> else if
[00:16:35] <Yuv422> dangling if
[00:55:16] <Yuv422> time to go
[00:55:19] <Yuv422> cya
[00:55:23] <-- Yuv422 has left IRC ()
[01:38:09] <sbx|afk> why cant we just try to use one indent style per file so we don't have to change everything?\
[01:38:22] <sbx|afk> 2 spaces per tab is not enough
[01:38:28] --- sbx|afk is now known as SB-X
[01:40:32] <servus> I just try to follow the code around me.. :)
[01:40:39] <SB-X> same here
[01:40:46] <SB-X> that's probably why there's so many different styles used
[01:41:39] <servus> As soon as I create my own file from scratch, you can blame me!
[01:53:19] <-- Kirben has left IRC ("System Meltdown")
[01:58:48] --> Kirben has joined #nuvie
[02:21:07] <luteijn> another thing that could use cleaning up is variable names, e.g. plane,level,z can all refer to the same thing related to map-coordinates, but level can also mean something different relating to experience. Got into trouble already copy&pasting a function-call that used 'level' to an area where it should have used 'z'... :)
[05:06:34] <-- servus has left IRC (orwell.freenode.net irc.freenode.net)
[05:06:34] <-- luteijn has left IRC (orwell.freenode.net irc.freenode.net)
[05:06:34] <-- laxdragon has left IRC (orwell.freenode.net irc.freenode.net)
[05:18:50] --> laxdragon has joined #nuvie
[05:20:05] --> servus has joined #nuvie
[06:03:11] <-- SB-X has left IRC (Read error: 110 (Connection timed out))
[08:56:54] --> SB-X has joined #nuvie
[09:32:10] <-- SB-X has left IRC (Read error: 110 (Connection timed out))
[10:28:18] --> SB-X has joined #nuvie
[10:43:09] --> luteijn has joined #nuvie
[10:44:32] <-- luteijn has left IRC (Client Quit)
[10:45:12] --> luteijn has joined #nuvie
[11:14:55] <SB-X> hi luteijn
[11:33:57] <luteijn> hi. Isn't there a 'contained_in' pointer for objects to point to the container they are in?
[11:43:25] <SB-X> no, that's what you're supposed to be adding
[11:43:46] <SB-X> :)
[11:44:58] <SB-X> i'd prefer objblk_pt to make it obvious that it's converted from the objblk_n of the parent container
[11:45:18] <SB-X> but then contained_in is more obvious what it means
[11:45:25] <SB-X> or parent_obj
[11:45:56] <luteijn> ok, I'll start with adding something to add an obj to a c_obj at a specified position, then look at what i need to nicely remove things again.
[11:46:30] <SB-X> ObjManager::list_add_obj is for adding to containers
[11:47:05] <SB-X> you have to make sure to read the parent objs from obj->x when loading and write them when saving
[11:47:57] <SB-X> x is supposed to point to the parent objblk_n, but an objblk_n is only unique for one superchunk and we load the entire world map at once, so it's no longer unique
[11:48:24] <luteijn> probably just have to change the current loading routine a bit to do that.
[11:49:19] <SB-X> objblk_n is just the object's index when stored in the objblk file
[12:07:21] <luteijn> hmm should I call my function obj_add_obj, or just list_add_obj (first parameter is parent object instead of the linked list; it calls the existing list_add_obj)?
[12:26:51] <-- Kirben has left IRC (Read error: 110 (Connection timed out))
[12:31:40] <luteijn> Hurray: (gdb) call obj_manager->obj_add_obj((Obj *) 0x81a1bb8,(Obj *) 0x827d220,1,0)
[12:31:41] <luteijn> $1 = true
[12:31:42] <luteijn> (gdb) cont
[12:41:43] <SB-X> :D
[12:42:23] <SB-X> what happened?
[12:44:33] <SB-X> list_add_obj isnt accurate since you're not adding directly to a list, but obj_add_obj isn't obvious either
[12:48:19] <luteijn> maybe container_add_obj? or c_obj_add_obj?
[12:49:17] <SB-X> container_add_obj is better :)
[12:49:26] <luteijn> it did add the obj to the spellbook, (and didn't update the iventory-window, so adding something to redisplay that now). I could then cast the spell I just moved into the book. It doesn't save properly though, I think.
[12:51:00] <SB-X> on saving you'll have to convert the container pointers back to objblk_n's and store in obj->x (if an object is in a container probably just don't write it until you've written its container)
[12:51:13] <SB-X> that's cool though
[12:51:35] <SB-X> i think the inventory window update should be in a higher level function
[12:52:06] <SB-X> in InventorWidget, or DollWidget, for example
[12:52:47] <luteijn> hmm you're probably right.
[12:53:10] <SB-X> ObjManager shouldn't assume the inventory view needs to be updated. (or care about the inventory view at all)
[12:53:35] <SB-X> the object and container could be on the map too
[12:55:01] <luteijn> commented out, and added comment to put in higher level function. now going to try out the eclipse spell with my spellbook. ;)
[12:55:58] <SB-X> hehe ok
[12:56:04] <SB-X> did you buy it?
[12:57:51] <luteijn> no I plan to spam a quality 255 spell-scroll, use my obj_add_obj function on it and then cast the eclipse spell ;)
[13:01:36] <SB-X> where can you buy it?
[13:03:25] <luteijn> don't remember ;) probably xiao
[13:04:44] --> Yuv422 has joined #nuvie
[13:06:21] <luteijn> well the eclipse looks nice, and I've fixed the crash on casting when holding an empty spellbook.
[13:06:57] <Yuv422> hey luteijn
[13:08:01] <SB-X> hey yuv
[13:08:10] <SB-X> great
[13:09:05] <Yuv422> hi SB-X
[13:09:35] <luteijn> next I'll try to figure out how to set the x etc. for my contained _objects so they save properly.
[13:47:46] <SB-X> got to go for now
[13:47:48] <SB-X> cya
[13:47:50] --- SB-X is now known as sbx|afk
[13:57:38] <-- Yuv422 has left IRC ()
[22:06:57] <-- luteijn has left IRC ("[BX] Back wit anutha one of doz BitchX-rockin' beats!")
[22:14:02] <servus> Those sorts of quit messages make me feel that using BitchX is an embarassing experience.
[22:20:57] --> luteijn has joined #nuvie
[22:58:04] --> Kirben has joined #nuvie