[CF-Devel] Re: AW: [Crossfire-cvs] CVS commit: crossfire]

crossfire-devel at archives.real-time.com crossfire-devel at archives.real-time.com
Sat Dec 20 10:05:06 CST 2003


Actually, the fix does break a few things....
My mistake for not making sure that was ok.

Basically, when you login, player won't even move... (probably due to the call 
from check_login).

Here's the fix i propose (attached patch): set speed to 0 in clear_object, call 
update_ob_speed (if speed isn't 0 already, of course). This way, a call to 
clear_object certifies object is correctly removed from active list.

Doing that there was a trouble in treasure.c, during artifact initialization: 
init_artifacts would directly malloc( ) an object and call reset_object on it 
(thus some breakage in update_ob_speed due to uninitialized active_next/prev). 
So i changed to call get_object( ) (which is there to provide objects, isn't it? :))

And, to be on the safe side, i added a speed = 0 in common/arch.c : 
get_archetype_struct( )
(note that update_ob_speed wouldn't do anything, because arch_init is set at 
that point)

With those fixes i couldn't find any bug in newbie tower, even after resetting map.

Nicolas 'Ryo'
-------------- next part --------------
Index: common/treasure.c
===================================================================
RCS file: /cvsroot/crossfire/crossfire/common/treasure.c,v
retrieving revision 1.42
diff -u -r1.42 treasure.c
--- common/treasure.c	2 Nov 2003 05:18:02 -0000	1.42
+++ common/treasure.c	20 Dec 2003 15:53:18 -0000
@@ -1200,8 +1200,7 @@
 	else if (sscanf(cp, "difficulty %d", &value))
 	    art->difficulty = (uint8) value;
 	else if (!strncmp(cp, "Object",6)) {
-	    art->item = (object *) malloc(sizeof(object));
-	    reset_object(art->item);
+	    art->item = get_object( );
 	    if (!load_object(fp, art->item,LO_LINEMODE,0))
 		LOG(llevError,"Init_Artifacts: Could not load object.\n");
 	    art->item->name = add_string((strchr(cp, ' ')+1));
Index: common/object.c
===================================================================
RCS file: /cvsroot/crossfire/crossfire/common/object.c,v
retrieving revision 1.77
diff -u -r1.77 object.c
--- common/object.c	18 Dec 2003 20:39:44 -0000	1.77
+++ common/object.c	20 Dec 2003 15:53:36 -0000
@@ -511,6 +511,11 @@
     if (op->lore!=NULL)	    FREE_AND_CLEAR_STR(op->lore);
     if (op->materialname!= NULL) FREE_AND_CLEAR_STR(op->materialname);
 
+    if ( op->speed != 0 )
+        {
+        op->speed = 0;
+        update_ob_speed( op );
+        }
 
     /* Using this memset is a lot easier (and probably faster)
      * than explicitly clearing the fields.
@@ -534,8 +539,6 @@
     op->head=NULL;
     op->map=NULL;
     op->refcount=0;
-    op->active_next = NULL;
-    op->active_prev = NULL;
     /* What is not cleared is next, prev, and count */
 
     op->expmul=1.0;
@@ -705,6 +708,7 @@
   if(objects!=NULL)
     objects->prev=op;
   objects=op;
+  op->speed = 0;
   clear_object(op);
   SET_FLAG(op,FLAG_REMOVED);
   nroffreeobjects--;
Index: common/arch.c
===================================================================
RCS file: /cvsroot/crossfire/crossfire/common/arch.c,v
retrieving revision 1.29
diff -u -r1.29 arch.c
--- common/arch.c	27 Oct 2003 07:24:13 -0000	1.29
+++ common/arch.c	20 Dec 2003 15:53:41 -0000
@@ -366,6 +366,7 @@
   new->clone.race=NULL;
   new->clone.slaying=NULL;
   new->clone.msg=NULL;
+  new->clone.speed = 0;
   clear_object(&new->clone);  /* to initial state other also */
   CLEAR_FLAG((&new->clone),FLAG_FREED); /* This shouldn't matter, since copy_object() */
   SET_FLAG((&new->clone), FLAG_REMOVED); /* doesn't copy these flags... */
-------------- next part --------------
_______________________________________________
crossfire-devel mailing list
     
     crossfire-devel at lists.real-time.com
     
     
     https://mailman.real-time.com/mailman/listinfo/crossfire-devel
     
     
    


More information about the crossfire mailing list