[CF-Devel] Patch: inscription fixes

crossfire-devel at archives.real-time.com crossfire-devel at archives.real-time.com
Sat Jan 3 05:56:08 CST 2004


Promised thing, due thing :)

Here's a patch to fix inscription skill, the spell writing part (text writing 
works fine, it seems).

2 things are fixed:
* when succeeding in writing, nothing was inserted in inventory. That's because 
at some point the scroll was inserted in the spell, so could not be inserted 
into the player's inventory. Obviously, we want to insert the spell into the 
scroll, not the other way :) Doing this correctly inserts newly written scroll 
in inventory, and removes warning messages in log ^_-

* if you write on a scroll which has nrof == 1, the server will crash. That's 
because we do:

  	if (newscroll->inv) {
  	    remove_ob(newscroll->inv);
  	    free_object(newscroll->inv);

Alas, remove_ob will clear newscroll->inv (op->env->inv), so free_object gets 
called with a NULL pointer... Something obviously bad & crashing :)
So I stored the inv in a temporary pointer, to free it correctly.

Nicolas 'Ryo'
-------------- next part --------------
Index: server/skills.c
===================================================================
RCS file: /cvsroot/crossfire/crossfire/server/skills.c,v
retrieving revision 1.45
diff -u -r1.45 skills.c
--- server/skills.c	20 Dec 2003 16:13:40 -0000	1.45
+++ server/skills.c	3 Jan 2004 11:48:27 -0000
@@ -1203,12 +1203,13 @@
 	}
 
 	if (newscroll->inv) {
-	    remove_ob(newscroll->inv);
-	    free_object(newscroll->inv);
+        object* inv = newscroll->inv;
+	    remove_ob(inv);
+	    free_object(inv);
 	}
 	tmp = get_object();
 	copy_object(chosen_spell, tmp);
-	insert_ob_in_ob(newscroll, tmp);
+	insert_ob_in_ob(tmp, newscroll);
 
 	/* wait until finished manipulating the scroll before inserting it */
 	if (newscroll != scroll)
-------------- 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