[crossfire] undecipherable code

tchize tchize at myrealbox.com
Sun Aug 28 10:54:37 CDT 2005


Hello,

While trying to speed up map loading process,
i run into the code at bottom of mail.
op, is where object read from map file is stored waiting  to
be inserted in map.
What am wondering about is the unique variable.
If i read well, if anything on square where op is going 
to be insterted is unique, then op will not be flagged 
as FLAG_OBJ_ORIGINAL.

First, what is the purpose of FLAG_OBJ_ORIGINAL
Second, why do other unique objets present on this map
square influence the behaviour of op. And if this is legitimate,
why do they only influence object put on top of them?

I it was to me this loop would be deleted as a bug. But am not sure
i should do it. Thanks for informations.

ho and btw, the loop 
for (otmp = get_map_ob(m, op->x, op->y); otmp; otmp = ootmp)
is using approx 16% of total cpu time on my map loading stress test,
so my question is not as innocent as it seems.

    while((i=load_object(fp,op,bufstate, mapflags))) {
	/* Since the loading of the map header does not load an object
	 * anymore, we need to pass LO_NEWFILE for the first object loaded,
	 * and then switch to LO_REPEAT for faster loading.
	 */
	bufstate = LO_REPEAT;

	/* if the archetype for the object is null, means that we
	 * got an invalid object.  Don't do anything with it - the game
	 * or editor will not be able to do anything with it either.
	 */
	if (op->arch==NULL) {
	    LOG(llevDebug,"Discarding object without arch: %s\n", 
op->name?op->name:"(null)");
	    continue;
	}

	/* check for unique items, or unique squares */
	unique = 0;
	for (otmp = get_map_ob(m, op->x, op->y); otmp; otmp = ootmp) {
	    ootmp = otmp->above;
	    if (QUERY_FLAG(otmp, FLAG_UNIQUE))
		unique = 1;
	}
	if (QUERY_FLAG(op, FLAG_UNIQUE) || QUERY_FLAG(op, FLAG_OBJ_SAVE_ON_OVL))
	    unique = 1;
	if (!(mapflags & (MAP_OVERLAY|MAP_PLAYER_UNIQUE) || unique))
	   SET_FLAG(op, FLAG_OBJ_ORIGINAL);


-- 
--
Tchize (David Delbecq)
     
     tchize at myrealbox.com
     
     
Public PGP KEY FINGERPRINT:
    F4BC EF69 54CC F2B5 4621  8DAF 1C71 8E6B 5436 C17C
Public PGP KEY location:
    
     
     http://wwwkeys.pgp.net/pgpnet/wwwkeys.html
     
     
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : 
     
     http://shadowknight.real-time.com/pipermail/crossfire/attachments/20050828/d55c85dc/attachment.pgp
     
     
    


More information about the crossfire mailing list