View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0000471 | LDMud 3.3 | Implementation | public | 2006-06-05 10:20 | 2008-07-26 12:17 |
| Reporter | fufu | Assigned To | fufu | ||
| Priority | normal | Severity | feature | Reproducibility | always |
| Status | resolved | Resolution | fixed | ||
| Summary | 0000471: use tell_object_str() function in e_say() and e_tell_room() | ||||
| Description | (was: The tell_object_str() function in object.c (and object.h) is unused and can be removed.) See Gnomi's comment below. | ||||
| Tags | No tags attached. | ||||
| Attached Files | use-tell_object.patch (3,955 bytes)
diff --git a/src/object.c b/src/object.c
index 86ab239..9a355fe 100644
--- a/src/object.c
+++ b/src/object.c
@@ -1299,34 +1299,6 @@ tell_object (object_t *ob, string_t *str)
}
/*-------------------------------------------------------------------------*/
-void
-tell_object_str (object_t *ob, const char *str)
-
-/* Send message <str> to object <ob>. If <ob> is an interactive player,
- * it will go to his screen (unless a shadow catches it - see shadow_catch_
- * message() ). If <ob> is not interactive, the message will go
- * to the lfun 'catch_tell()' via a call to tell_npc().
- */
-
-{
- object_t *save_command_giver;
- interactive_t *ip;
-
- if (ob->flags & O_DESTRUCTED)
- return;
-
- if (O_SET_INTERACTIVE(ip, ob))
- {
- save_command_giver = command_giver;
- command_giver = ob;
- add_message("%s", str);
- command_giver = save_command_giver;
- return;
- }
- tell_npc_str(ob, str);
-}
-
-/*-------------------------------------------------------------------------*/
Bool
shadow_catch_message (object_t *ob, const char *str)
@@ -4607,7 +4579,7 @@ e_say (svalue_t *v, vector_t *avoid)
object_t *ob;
object_t *save_command_giver = command_giver;
object_t *origin;
- char *message;
+ string_t *message;
#define INITIAL_MAX_RECIPIENTS 48
int max_recipients = INITIAL_MAX_RECIPIENTS;
/* Current size of the recipients table.
@@ -4626,7 +4598,6 @@ e_say (svalue_t *v, vector_t *avoid)
&first_recipients[INITIAL_MAX_RECIPIENTS-1];
/* Last entry in the current table.
*/
- object_t *save_again;
/* Determine the command_giver to use */
if (current_object->flags & O_ENABLE_COMMANDS)
@@ -4730,7 +4701,7 @@ e_say (svalue_t *v, vector_t *avoid)
switch(v->type)
{
case T_STRING:
- message = get_txt(v->u.str);
+ message = v->u.str;
break;
case T_OBJECT:
@@ -4777,22 +4748,12 @@ e_say (svalue_t *v, vector_t *avoid)
for (curr_recipient = recipients; NULL != (ob = *curr_recipient++); )
{
- interactive_t *ip;
-
if (ob->flags & O_DESTRUCTED)
continue;
stmp.u.ob = ob;
if (lookup_key(&stmp, avoid) >= 0)
continue;
- if (!(O_SET_INTERACTIVE(ip, ob)))
- {
- tell_npc_str(ob, message);
- continue;
- }
- save_again = command_giver;
- command_giver = ob;
- add_message("%s", message);
- command_giver = save_again;
+ tell_object (ob, message);
}
pop_stack(); /* free avoid alist */
@@ -4901,12 +4862,11 @@ e_tell_room (object_t *room, svalue_t *v, vector_t *avoid)
{
object_t *ob;
- object_t *save_command_giver;
int num_recipients = 0;
object_t *some_recipients[20];
object_t **recipients;
object_t **curr_recipient;
- char *message;
+ string_t *message;
static svalue_t stmp = { T_OBJECT, } ;
/* Like in say(), collect the possible recipients.
@@ -4950,7 +4910,7 @@ e_tell_room (object_t *room, svalue_t *v, vector_t *avoid)
switch(v->type)
{
case T_STRING:
- message = get_txt(v->u.str);
+ message = v->u.str;
break;
case T_OBJECT:
@@ -5003,20 +4963,10 @@ e_tell_room (object_t *room, svalue_t *v, vector_t *avoid)
for (curr_recipient = recipients; NULL != (ob = *curr_recipient++); )
{
- interactive_t *ip;
-
if (ob->flags & O_DESTRUCTED) continue;
stmp.u.ob = ob;
if (lookup_key(&stmp, avoid) >= 0) continue;
- if (!(O_SET_INTERACTIVE(ip, ob)))
- {
- tell_npc_str(ob, message);
- continue;
- }
- save_command_giver = command_giver;
- command_giver = ob;
- add_message("%s", message);
- command_giver = save_command_giver;
+ tell_object(ob, message);
}
} /* e_tell_room() */
| ||||
|
|
I agree. Does anybody object to remove the function? |
|
|
I vote for actually using this function. e_say() and e_tell_room() do exactly the same thing as tell_object_str(), so if they would call tell_object_str instead we would have less double code. |
|
|
Good point, that is even better. ;-) Removing duplicate code is always nice. In this case, this is related to Fuchurs Bug 0000472. |
|
|
In fact, we can do both: e_say and e_tell_room extract their string from a string_t, only to let tell_object_str create a new one if the target is an npc. It's better to use tell_object. This makes tell_object_str superfluous again. (see patch) |
|
|
Looks good. |
|
|
Good idea. :) |
|
|
fixed in commit 2395 |
| Date Modified | Username | Field | Change |
|---|---|---|---|
| 2006-06-05 10:20 | fufu | New Issue | |
| 2008-06-30 17:18 | zesstra | Status | new => assigned |
| 2008-06-30 17:18 | zesstra | Assigned To | => zesstra |
| 2008-07-08 15:06 | zesstra | Note Added: 0000687 | |
| 2008-07-09 00:55 | Gnomi | Note Added: 0000696 | |
| 2008-07-09 01:45 | zesstra | Relationship added | related to 0000472 |
| 2008-07-09 01:45 | zesstra | Note Added: 0000699 | |
| 2008-07-09 08:02 | zesstra | Assigned To | zesstra => fufu |
| 2008-07-09 08:03 | fufu | Summary | remove tell_object_str() function => use tell_object_str() function in e_say() and e_tell_room() |
| 2008-07-09 08:04 | fufu | Description Updated | |
| 2008-07-09 10:43 | fufu | File Added: use-tell_object.patch | |
| 2008-07-09 10:44 | fufu | Note Added: 0000705 | |
| 2008-07-10 08:28 | Gnomi | Note Added: 0000719 | |
| 2008-07-10 14:24 | zesstra | Note Added: 0000721 | |
| 2008-07-26 12:17 | fufu | Status | assigned => resolved |
| 2008-07-26 12:17 | fufu | Resolution | open => fixed |
| 2008-07-26 12:17 | fufu | Note Added: 0000751 |