if (d->outtop + length >= 32000)
{
d->outsize = 15999;
d->outbuf = alloc_mem( d->outsize );
d->outtop = 1000;
write_to_buffer(d, " Spam Choke\n\r", 0);
bug("outtop size",0);
}
else
{
/* 'drop all' or 'drop all.obj' */
// OK, let's do this like 'Drops quite a few items'
// With a random chance to notice a few of them?
// IE Joe drops a lot of items, you notice an arrow, a dagger, and many more.
// IE Joe puts a lot of items into the pit, you spot an apple, and much more.
found = FALSE;
int amount_drop = 0; // anti-spam
int item_dropped = 0; // pre-count
// Let's count how many first, then do the full one once we know that.
for (obj = ch->carrying; obj != NULL; obj = obj_next)
{
obj_next = obj->next_content;
if ((arg[3] == '\0' || is_name (&arg[4], obj->name))
&& can_see_obj (ch, obj)
&& obj->wear_loc == WEAR_NONE && can_drop_obj (ch, obj))
{
found = TRUE;
item_dropped ++; // one more.
}
}
char buf[256];
/* sprintf (buf, "Total items was %d.\r\n", item_dropped);
send_to_char (buf, ch);*/
for (obj = ch->carrying; obj != NULL; obj = obj_next)
{
obj_next = obj->next_content;
if ((arg[3] == '\0' || is_name (&arg[4], obj->name))
&& can_see_obj (ch, obj)
&& obj->wear_loc == WEAR_NONE && can_drop_obj (ch, obj))
{
found = TRUE;
amount_drop ++; // one more.
obj_from_char (obj);
if (IS_OBJ_STAT (obj, ITEM_MELT_DROP))
{
if (amount_drop < 2)
{
act ("$n drops $p, which dissolves into smoke.", ch, obj, NULL, TO_ROOM_SEE);
act ("You drop $p, which dissolves into smoke.", ch, obj, NULL, TO_CHAR);
}
extract_obj (obj);
}
else
{
to_room = obj_drop_to_room (obj, ch->in_room);
if (ch->in_room == to_room)
{
if (amount_drop < 2)
{
act ("$n drops $p.", ch, obj, NULL, TO_ROOM_SEE);
act ("You hear something hit the floor.", ch, NULL, NULL, TO_ROOM_HEAR_ONLY);
act ("You drop $p.", ch, obj, NULL, TO_CHAR);
}
if (obj->item_type == ITEM_FISH)
{
if (to_room->sector_type == SECT_WATER_SWIM
|| to_room->sector_type == SECT_WATER_NOSWIM
|| to_room->sector_type == SECT_UNDERWATER
|| to_room->fpool != NULL)
{
//fish splash or sink if dead
if (obj->timer > 0 && obj->timer < 25) // dead fish
act ("$p hits the water and sinks out of sight.", ch, obj, NULL, TO_ALL);
else // live fish, swim off
act ("$p hits the water and swims away!", ch, obj, NULL, TO_ALL);
extract_obj (obj);
}
else
{
switch (to_room->sector_type)
{
default:
case SECT_INSIDE:
if (obj->timer > 0 && obj->timer < 25) // dead fish
act ("$p hits the floor with a splat.", ch, obj, NULL, TO_ALL);
else // live fish, swim off
act ("$p hits the floor and flops around for a bit.", ch, obj, NULL, TO_ALL);
break;
case SECT_CITY:
case SECT_FIELD:
case SECT_FOREST:
case SECT_HILLS:
case SECT_MOUNTAIN:
if (obj->timer > 0 && obj->timer < 25) // dead fish
act ("$p hits the ground with a splat.", ch, obj, NULL, TO_ALL);
else // live fish, swim off
act ("$p hits the ground and flops around for a bit.", ch, obj, NULL, TO_ALL);
break;
case SECT_DESERT:
if (obj->timer > 0 && obj->timer < 25) // dead fish
act ("$p hits the sand with a dull thud.", ch, obj, NULL, TO_ALL);
else // live fish, swim off
act ("$p hits the sand and flops around painfully.", ch, obj, NULL, TO_ALL);
break;
}
}
}
if (obj->item_type == ITEM_DICE)
{
obj->value[1] = number_range (1, obj->value[0]);
diceroll(ch, obj);
}
}
else
{
/* Check to see if it floated up. */
if ((ch->in_room->sector_type == SECT_UNDERWATER)
&& ((obj->materials.major == MAT_WOOD)
|| (obj->materials.major == MAT_CORK)))
{
if (amount_drop < 2)
{
act ("$n lets go of $p, which floats from sight above you.",
ch, obj, NULL, TO_ROOM_SEE);
act ("You let go of $p, which floats from sight above you.",
ch, obj, NULL, TO_CHAR);
for (vch = char_list; vch; vch = vch->next)
if (vch->in_room == to_room)
act ("$p floats up from below!", vch, obj, NULL, TO_CHAR);
}
}
else /* It fell or sank. */
{
if (amount_drop < 2)
{
act("$n drops $p, which vanishes from sight below you.",
ch, obj, NULL, TO_ROOM_SEE);
act("You drop $p, which vanishes from sight below you.",
ch, obj, NULL, TO_CHAR);
for (vch = char_list; vch; vch = vch->next)
if (vch->in_room == to_room)
act ("$p falls from the sky!", vch, obj, NULL, TO_CHAR);
}
}
}
if (obj)
{
if (HAS_TRIGGER_OBJ (obj, TRIG_DROP))
p_give_trigger (NULL, obj, NULL, ch, obj, TRIG_DROP);
if (HAS_TRIGGER_ROOM (ch->in_room, TRIG_DROP))
p_give_trigger (NULL, NULL, to_room, ch, obj, TRIG_DROP);
}
}
}
}
if (amount_drop > 1)
{
int quant = amount_drop -1;
sprintf (buf, "Along with %s more thing%s.", quant == 1 ? "one" : quant < 3 ? "a couple" : quant < 5 ? "a few" : quant < 10 ? "some" : quant < 50 ? "a lot" : quant < 100 ? "a ton" : "more things than Tasslehoff has and some", quant == 1 ? "" : "s");
act (buf, ch, obj, NULL, TO_CHAR);
act (buf, ch, NULL, NULL, TO_ROOM);
}
/* 'drop all' or 'drop all.obj' */
//The following is from Skol of Ansalon MUD
// OK, let's do this like 'Drops quite a few items'
// With a random chance to notice a few of them?
// IE Joe drops a lot of items, you notice an arrow, a dagger, and many more.
// IE Joe puts a lot of items into the pit, you spot an apple, and much more.
found = FALSE;
int amount_drop = 0; // anti-spam
int item_dropped = 0; // pre-count
// Let's count how many first, then do the full one once we know that.
for (obj = ch->carrying; obj != NULL; obj = obj_next)
{
obj_next = obj->next_content;
if ((arg[3] == '\0' || is_name (&arg[4], obj->name))
&& can_see_obj (ch, obj)
&& obj->wear_loc == WEAR_NONE && can_drop_obj (ch, obj))
{
found = TRUE;
item_dropped ++; // one more.
}
}
char buf[256];
for (obj = ch->carrying; obj != NULL; obj = obj_next)
{
obj_next = obj->next_content;
if ((arg[3] == '\0' || is_name (&arg[4], obj->name))
&& can_see_obj (ch, obj)
&& obj->wear_loc == WEAR_NONE && can_drop_obj (ch, obj))
{
found = TRUE;
amount_drop ++; // one more.
obj_from_char (obj);
if (IS_OBJ_STAT (obj, ITEM_VANISH))
{
if (amount_drop < 2)
{
act ("$n drops $p, which dissolves into smoke.", ch, obj, NULL, TO_ROOM);
act ("You drop $p, which dissolves into smoke.", ch, obj, NULL, TO_CHAR);
}
extract_obj (obj);
}
else
{
int to_room;
to_room = bobj_to_room(obj, ch->in_room);
if(to_room == 1)
{
if (amount_drop < 2)
{
act ("$n drops $p.", ch, obj, NULL, TO_ROOM);
//act ("You hear something hit the floor.", ch, NULL, NULL, TO_ROOM);
act ("You drop $p.", ch, obj, NULL, TO_CHAR);
}
}
if (obj)
{
if (HAS_TRIGGER_OBJ (obj, TRIG_DROP))
p_give_trigger (NULL, obj, NULL, ch, obj, TRIG_DROP);
if (HAS_TRIGGER_ROOM (ch->in_room, TRIG_DROP))
p_give_trigger (NULL, NULL, ch->in_room, ch, obj, TRIG_DROP);
}
}
}
}
if (amount_drop > 1)
{
int quant = amount_drop -1;
sprintf (buf, "Along with %s more thing%s.", quant == 1 ? "one" : quant < 3 ? "a couple" : quant < 5 ? "a few" : quant < 10 ? "some" : quant < 50 ? "a lot" : quant < 100 ? "a ton" : "things than you can count.. spammer.", quant == 1 ? "" : "s");
act (buf, ch, obj, NULL, TO_CHAR);
act (buf, ch, NULL, NULL, TO_ROOM);
}
/* 'drop all' or 'drop all.obj' */
// modified Skol's code into various pieces to make maintenance/addition easier
// we now call mggdp_processor for any multi get give drop put obj command and let it do the actual work
// we will just keep count of it had a hit, or not.
found = FALSE; // preset false condition
char buf[256];
for (obj = ch->carrying; obj != NULL; obj = obj_next)
{
obj_next = obj->next_content;
i = mggdp_processor(ch, obj, arg[3], arg[4], 1, dc);
if( i == 1 )
{
found = TRUE;
dc++;
}
}
}
if ( dc > 1)
{
mosm_message(ch, obj, dc);
}
int mggdp_processor(CHAR_DATA *ch, OBJ_DATA *obj, char *arg1, char *arg2, int *type, int *dc)
{
if(type == 1)//drop
{
if ((arg1 == '\0' || is_name (arg2, obj->name)) && can_see_obj (ch, obj) && obj->wear_loc == WEAR_NONE && can_drop_obj (ch, obj))
{
obj_from_char (obj);
if (IS_OBJ_STAT (obj, ITEM_VANISH))
{
if (dc < 1)
{
act ("$n drops $p, which dissolves into smoke.", ch, obj, NULL, TO_ROOM);
act ("You drop $p, which dissolves into smoke.", ch, obj, NULL, TO_CHAR);
}
extract_obj (obj);
}
else
{
int to_room;
to_room = bobj_to_room(obj, ch->in_room);
if(to_room == 1)
{
if (dc < 1)
{
act ("$n #0drops#n $p#0.#n", ch, obj, NULL, TO_ROOM);
act ("#0You drop #n$p#0.#n", ch, obj, NULL, TO_CHAR);
}
}
if (obj)
{
if (HAS_TRIGGER_OBJ (obj, TRIG_DROP))
p_give_trigger (NULL, obj, NULL, ch, obj, TRIG_DROP);
if (HAS_TRIGGER_ROOM (ch->in_room, TRIG_DROP))
p_give_trigger (NULL, NULL, ch->in_room, ch, obj, TRIG_DROP);
}
}
return 1;
}
return 0;
}
…
void mosm_message(CHAR_DATA *ch, OBJ_DATA *obj, int *dc)
{
char mbuf[256];
int i = 0;
int q = dc -1;
// set up some ranges!
if( q <= 1 )
i = 1;
else if( q < 10 )
i = 2;
else if( q < 25 )
i = 3;
else if( q < 50 )
i = 4;
else if( q > 50 )
i = 5;
if( i == 0 ) //we got passed some bad joojoo
return;
// lets make this a bit easier to maintain - for me
switch (i)
{
case 1:
sprintf(mbuf, "#0And one more object.#n");
act (mbuf, ch, obj, NULL, TO_CHAR);
act (mbuf, ch, NULL, NULL, TO_ROOM);
break;
case 2:
sprintf(mbuf, "#0And a few other things.#n");
act (mbuf, ch, obj, NULL, TO_CHAR);
act (mbuf, ch, NULL, NULL, TO_ROOM);
break;
case 3:
sprintf(mbuf, "#0Along with quite a few more items.#n");
act (mbuf, ch, obj, NULL, TO_CHAR);
act (mbuf, ch, NULL, NULL, TO_ROOM);
break;
case 4:
case 5:
sprintf(mbuf, "#0Along with more things than you can count.. #RS#rp#Ra#rm#Rm#re#Rr#r!#R!#0.. #n");
act (mbuf, ch, obj, NULL, TO_CHAR);
act (mbuf, ch, NULL, NULL, TO_ROOM);
break;
}
}
/* 'drop all' or 'drop all.obj' */
// modified Skol's code into various pieces to make maintenance/addition easier
// we now call mggdp_processor for any multi get give drop put obj command and let it do the actual work
// we will just keep count of it had a hit, or not.
found = FALSE; // preset false condition
char buf[256];
for (obj = ch->carrying; obj != NULL; obj = obj_next)
{
obj_next = obj->next_content;
i = mggdp_processor(ch, obj, arg[3], arg[4], 1, dc);
if( i == 1 )
{
found = TRUE;
dc++;
}
}
} // <– no matching open brace…
if ( dc > 1)
{
mosm_message(ch, obj, dc);
}
int mggdp_processor(CHAR_DATA *ch, OBJ_DATA *obj, char *arg1, char *arg2, int *type, int *dc)
{
if(type == 1)//drop
{
if ((arg1 == '\0' || is_name (arg2, obj->name)) && can_see_obj (ch, obj) && obj->wear_loc == WEAR_NONE && can_drop_obj (ch, obj))
{
obj_from_char (obj);
if (IS_OBJ_STAT (obj, ITEM_VANISH))
{
if (dc < 1)
{
act ("$n drops $p, which dissolves into smoke.", ch, obj, NULL, TO_ROOM);
act ("You drop $p, which dissolves into smoke.", ch, obj, NULL, TO_CHAR);
}
extract_obj (obj);
}
else
{
int to_room;
to_room = bobj_to_room(obj, ch->in_room);
if(to_room == 1)
{
if (dc < 1)
{
act ("$n #0drops#n $p#0.#n", ch, obj, NULL, TO_ROOM);
act ("#0You drop #n$p#0.#n", ch, obj, NULL, TO_CHAR);
}
}
if (obj)
{
if (HAS_TRIGGER_OBJ (obj, TRIG_DROP))
p_give_trigger (NULL, obj, NULL, ch, obj, TRIG_DROP);
if (HAS_TRIGGER_ROOM (ch->in_room, TRIG_DROP))
p_give_trigger (NULL, NULL, ch->in_room, ch, obj, TRIG_DROP);
}
}
return 1;
}
return 0;
}
// …
} // <– added missing closing brace that would have been further down
void mosm_message(CHAR_DATA *ch, OBJ_DATA *obj, int *dc)
{
char mbuf[256];
int i = 0;
int q = dc -1;
// set up some ranges!
if( q <= 1 )
i = 1;
else if( q < 10 )
i = 2;
else if( q < 25 )
i = 3;
else if( q < 50 )
i = 4;
else if( q > 50 )
i = 5;
if( i == 0 ) //we got passed some bad joojoo
return;
// lets make this a bit easier to maintain - for me
switch (i)
{
case 1:
sprintf(mbuf, "#0And one more object.#n");
act (mbuf, ch, obj, NULL, TO_CHAR);
act (mbuf, ch, NULL, NULL, TO_ROOM);
break;
case 2:
sprintf(mbuf, "#0And a few other things.#n");
act (mbuf, ch, obj, NULL, TO_CHAR);
act (mbuf, ch, NULL, NULL, TO_ROOM);
break;
case 3:
sprintf(mbuf, "#0Along with quite a few more items.#n");
act (mbuf, ch, obj, NULL, TO_CHAR);
act (mbuf, ch, NULL, NULL, TO_ROOM);
break;
case 4:
case 5:
sprintf(mbuf, "#0Along with more things than you can count.. #RS#rp#Ra#rm#Rm#re#Rr#r!#R!#0.. #n");
act (mbuf, ch, obj, NULL, TO_CHAR);
act (mbuf, ch, NULL, NULL, TO_ROOM);
break;
}
}
/*
* Emits a message based on the number of repetitions of the same object.
* dc is the duplicate count value, 0 meaning not duplicated.
*/
void mosm_message( CHAR_DATA *ch, OBJ_DATA *obj, int dc )
{
int i = 0;
const char **msgs[5] = {
"#0And one more object.#n",
"#0And a few other things.#n",
"#0Along with quite a few more items.#n",
"#0Along with more things than you can count.. #RS#rp#Ra#rm#Rm#re#Rr#r!#R!#0.. #n",
"#0Along with more things than you can count.. #RS#rp#Ra#rm#Rm#re#Rr#r!#R!#0.. #n"
};
if( dc <= 0) return;
if( dc > 1 ) i++;
if( dc > 10) i++;
if( dc > 25) i++;
if( dc > 50) i++;
act( msgs[i], ch, obj, NULL, TO_CHAR );
act( msgs[i], ch, NULL, NULL, TO_ROOM );
}
Long time no see..
Anywho.
I am struggling mightily with this and I am sure I am being overly obtuse or blind.
Effectively what I am trying to do, and what partially works is:
Character receives a massive amount of data output (eg, a drop all)
Something detects this, and chokes off the output to the character (optionally providing a message).
The End.
I have fiddled with write_to_buffer, and have been able to get it to recognize an initial 'spam' burst. Great. I choke it off and send a message or take it on a date. Its golden.
Then, I get another amount of lines remaining past this choke point as further display.
It is irking me because then I have (output)spam message(output) and it just looks and feels disjointed to me. This happens moreso on a 'get all' than a 'drop all' I would assume due to the construction of both of those and how they are scanning/sending the data.
Depending on how i play with write_to_buffer I can increase or decrease the first amount of (output)msg(output) but I cant figure out how to simply call off the final burst.
If anyone is familiar with the codebase in general, or perhaps what I should look towards that would be greatly appreciated.
I have basically tried to do variations of the following: