10 Commits

Author SHA1 Message Date
Copilot 552461df51 Fix all compiler warnings in build output (#176)
Agent-Logs-Url: https://github.com/tbamud/tbamud/sessions/d031438d-2711-4447-b3df-9819d95d4058

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: welcor <357770+welcor@users.noreply.github.com>
2026-04-21 23:50:55 +02:00
Thomas Arp 10251814f6 Potential fix for code scanning alert no. 55: Call to alloca in a loop (#175)
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2026-04-21 23:20:23 +02:00
Thomas Arp d4089c58e8 Potential fix for code scanning alert no. 73: Potential use after free (#168)
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2026-04-21 23:15:35 +02:00
Thomas Arp a465860553 Potential fix for code scanning alert no. 70: Incorrect return-value check for a 'scanf'-like function (#169)
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2026-04-21 23:14:48 +02:00
Thomas Arp b9f49478a3 Potential fix for code scanning alert no. 1: Workflow does not contain permissions (#170)
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2026-04-21 23:14:01 +02:00
Thomas Arp 171381f0ea Potential fix for code scanning alert no. 5: Redundant null check due to previous dereference (#174)
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2026-04-21 23:13:20 +02:00
Thomas Arp dbd6bfc103 Potential fix for code scanning alert no. 4: Redundant null check due to previous dereference (#173)
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2026-04-21 23:12:55 +02:00
Thomas Arp 1dfbe0fa83 Potential fix for code scanning alert no. 3: Redundant null check due to previous dereference (#172)
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2026-04-21 23:10:46 +02:00
Thomas Arp 039e45c5ef Potential fix for code scanning alert no. 2: Redundant null check due to previous dereference (#171)
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2026-04-21 23:10:26 +02:00
Thomas Arp 862c887b54 Better naming in do_drink. An unlimited source is never empty. (#167)
* Better naming in do_drink. An unlimited source is never empty.
* Add guard for negative amount when drinking from infinite source
* Allow drinking from unlimited containers with current value of 0
* Fix unlimited drink container definition to allow negative current values

Tested manually on localhost. 

Fixes #156


Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-04-21 22:36:56 +02:00
13 changed files with 118 additions and 84 deletions
+3
View File
@@ -6,6 +6,9 @@ on:
pull_request_target: pull_request_target:
branches: [ "master" ] branches: [ "master" ]
permissions:
contents: read
jobs: jobs:
build: build:
+75 -55
View File
@@ -777,6 +777,15 @@ void weight_change_object(struct obj_data *obj, int weight)
} }
} }
#define DRINK_CON_MAX(cont) (GET_OBJ_VAL((cont), 0))
#define DRINK_CON_NOW(cont) (GET_OBJ_VAL((cont), 1))
#define DRINK_CON_TYPE(cont) (GET_OBJ_VAL((cont), 2))
#define DRINK_CON_POISON(cont) (GET_OBJ_VAL((cont), 3))
#define LIMITED_DRINK_CONTAINER(cont) (DRINK_CON_MAX((cont)) >= 0 && DRINK_CON_NOW((cont)) >= 0)
#define EMPTY_DRINK_CONTAINER(cont) (LIMITED_DRINK_CONTAINER((cont)) && DRINK_CON_NOW((cont)) < 1)
void name_from_drinkcon(struct obj_data *obj) void name_from_drinkcon(struct obj_data *obj)
{ {
const char *liqname; const char *liqname;
@@ -788,13 +797,12 @@ void name_from_drinkcon(struct obj_data *obj)
if (obj->name == obj_proto[GET_OBJ_RNUM(obj)].name) if (obj->name == obj_proto[GET_OBJ_RNUM(obj)].name)
obj->name = strdup(obj_proto[GET_OBJ_RNUM(obj)].name); obj->name = strdup(obj_proto[GET_OBJ_RNUM(obj)].name);
liqname = drinknames[GET_OBJ_VAL(obj, 2)]; liqname = drinknames[DRINK_CON_TYPE(obj)];
remove_from_string(obj->name, liqname); remove_from_string(obj->name, liqname);
new_name = right_trim_whitespace(obj->name); new_name = right_trim_whitespace(obj->name);
free(obj->name); free(obj->name);
obj->name = new_name; obj->name = new_name;
} }
void name_to_drinkcon(struct obj_data *obj, int type) void name_to_drinkcon(struct obj_data *obj, int type)
@@ -813,6 +821,7 @@ void name_to_drinkcon(struct obj_data *obj, int type)
obj->name = new_name; obj->name = new_name;
} }
ACMD(do_drink) ACMD(do_drink)
{ {
char arg[MAX_INPUT_LENGTH]; char arg[MAX_INPUT_LENGTH];
@@ -873,7 +882,7 @@ ACMD(do_drink)
send_to_char(ch, "Your stomach can't contain anymore!\r\n"); send_to_char(ch, "Your stomach can't contain anymore!\r\n");
return; return;
} }
if (GET_OBJ_VAL(temp, 1) < 1) { if (EMPTY_DRINK_CONTAINER(temp)) {
send_to_char(ch, "It is empty.\r\n"); send_to_char(ch, "It is empty.\r\n");
return; return;
} }
@@ -884,33 +893,38 @@ ACMD(do_drink)
if (subcmd == SCMD_DRINK) { if (subcmd == SCMD_DRINK) {
char buf[MAX_STRING_LENGTH]; char buf[MAX_STRING_LENGTH];
snprintf(buf, sizeof(buf), "$n drinks %s from $p.", drinks[GET_OBJ_VAL(temp, 2)]); snprintf(buf, sizeof(buf), "$n drinks %s from $p.", drinks[DRINK_CON_TYPE(temp)]);
act(buf, TRUE, ch, temp, 0, TO_ROOM); act(buf, TRUE, ch, temp, 0, TO_ROOM);
send_to_char(ch, "You drink the %s.\r\n", drinks[GET_OBJ_VAL(temp, 2)]); send_to_char(ch, "You drink the %s.\r\n", drinks[DRINK_CON_TYPE(temp)]);
if (drink_aff[GET_OBJ_VAL(temp, 2)][DRUNK] > 0) if (drink_aff[DRINK_CON_TYPE(temp)][DRUNK] > 0)
amount = (25 - GET_COND(ch, THIRST)) / drink_aff[GET_OBJ_VAL(temp, 2)][DRUNK]; amount = (25 - GET_COND(ch, THIRST)) / drink_aff[DRINK_CON_TYPE(temp)][DRUNK];
else else
amount = rand_number(3, 10); amount = rand_number(3, 10);
} else { } else {
act("$n sips from $p.", TRUE, ch, temp, 0, TO_ROOM); act("$n sips from $p.", TRUE, ch, temp, 0, TO_ROOM);
send_to_char(ch, "It tastes like %s.\r\n", drinks[GET_OBJ_VAL(temp, 2)]); send_to_char(ch, "It tastes like %s.\r\n", drinks[DRINK_CON_TYPE(temp)]);
amount = 1; amount = 1;
} }
amount = MIN(amount, GET_OBJ_VAL(temp, 1)); /* For limited drink containers with remaining contents, don't drink more
* than the amount currently in the container. Unlimited containers are
* handled separately and are not clamped here.
*/
if (LIMITED_DRINK_CONTAINER(temp))
amount = MIN(amount, DRINK_CON_NOW(temp));
/* You can't subtract more than the object weighs, unless its unlimited. */ /* You can't subtract more than the object weighs, unless its unlimited. */
if (GET_OBJ_VAL(temp, 0) > 0) { if (LIMITED_DRINK_CONTAINER(temp)) {
weight = MIN(amount, GET_OBJ_WEIGHT(temp)); weight = MIN(amount, GET_OBJ_WEIGHT(temp));
weight_change_object(temp, -weight); /* Subtract amount */ weight_change_object(temp, -weight); /* Subtract amount */
} }
gain_condition(ch, DRUNK, drink_aff[GET_OBJ_VAL(temp, 2)][DRUNK] * amount / 4); gain_condition(ch, DRUNK, drink_aff[DRINK_CON_TYPE(temp)][DRUNK] * amount / 4);
gain_condition(ch, HUNGER, drink_aff[GET_OBJ_VAL(temp, 2)][HUNGER] * amount / 4); gain_condition(ch, HUNGER, drink_aff[DRINK_CON_TYPE(temp)][HUNGER] * amount / 4);
gain_condition(ch, THIRST, drink_aff[GET_OBJ_VAL(temp, 2)][THIRST] * amount / 4); gain_condition(ch, THIRST, drink_aff[DRINK_CON_TYPE(temp)][THIRST] * amount / 4);
if (GET_COND(ch, DRUNK) > 10) if (GET_COND(ch, DRUNK) > 10)
send_to_char(ch, "You feel drunk.\r\n"); send_to_char(ch, "You feel drunk.\r\n");
@@ -921,7 +935,7 @@ ACMD(do_drink)
if (GET_COND(ch, HUNGER) > 20) if (GET_COND(ch, HUNGER) > 20)
send_to_char(ch, "You are full.\r\n"); send_to_char(ch, "You are full.\r\n");
if (GET_OBJ_VAL(temp, 3) && GET_LEVEL(ch) < LVL_IMMORT) { /* The crap was poisoned ! */ if (DRINK_CON_POISON(temp) && GET_LEVEL(ch) < LVL_IMMORT) { /* The crap was poisoned ! */
send_to_char(ch, "Oops, it tasted rather strange!\r\n"); send_to_char(ch, "Oops, it tasted rather strange!\r\n");
act("$n chokes and utters some strange sounds.", TRUE, ch, 0, 0, TO_ROOM); act("$n chokes and utters some strange sounds.", TRUE, ch, 0, 0, TO_ROOM);
@@ -932,12 +946,13 @@ ACMD(do_drink)
affect_join(ch, &af, FALSE, FALSE, FALSE, FALSE); affect_join(ch, &af, FALSE, FALSE, FALSE, FALSE);
} }
/* Empty the container (unless unlimited), and no longer poison. */ /* Empty the container (unless unlimited), and no longer poison. */
if (GET_OBJ_VAL(temp, 0) > 0) { if (LIMITED_DRINK_CONTAINER(temp)) {
GET_OBJ_VAL(temp, 1) -= amount; amount = MIN(amount, DRINK_CON_NOW(temp)); // never subtract more than the current amount
if (!GET_OBJ_VAL(temp, 1)) { /* The last bit */ DRINK_CON_NOW(temp) -= amount;
if (!DRINK_CON_NOW(temp)) { /* The last bit */
name_from_drinkcon(temp); name_from_drinkcon(temp);
GET_OBJ_VAL(temp, 2) = 0; DRINK_CON_TYPE(temp) = 0;
GET_OBJ_VAL(temp, 3) = 0; DRINK_CON_POISON(temp) = 0;
} }
} }
return; return;
@@ -1064,7 +1079,7 @@ ACMD(do_pour)
return; return;
} }
} }
if (GET_OBJ_VAL(from_obj, 1) == 0) { if (EMPTY_DRINK_CONTAINER(from_obj)) {
act("The $p is empty.", FALSE, ch, from_obj, 0, TO_CHAR); act("The $p is empty.", FALSE, ch, from_obj, 0, TO_CHAR);
return; return;
} }
@@ -1074,19 +1089,22 @@ ACMD(do_pour)
return; return;
} }
if (!str_cmp(arg2, "out")) { if (!str_cmp(arg2, "out")) {
if (GET_OBJ_VAL(from_obj, 0) > 0) { if (!LIMITED_DRINK_CONTAINER(from_obj)) {
send_to_char(ch, "You can't pour that out! There's simply too much in it.\r\n");
return;
}
/* pour out */
act("$n empties $p.", TRUE, ch, from_obj, 0, TO_ROOM); act("$n empties $p.", TRUE, ch, from_obj, 0, TO_ROOM);
act("You empty $p.", FALSE, ch, from_obj, 0, TO_CHAR); act("You empty $p.", FALSE, ch, from_obj, 0, TO_CHAR);
weight_change_object(from_obj, -GET_OBJ_VAL(from_obj, 1)); /* Empty */ weight_change_object(from_obj, -DRINK_CON_NOW(from_obj)); /* Empty */
name_from_drinkcon(from_obj); name_from_drinkcon(from_obj);
GET_OBJ_VAL(from_obj, 1) = 0;
GET_OBJ_VAL(from_obj, 2) = 0; DRINK_CON_NOW(from_obj) = 0;
GET_OBJ_VAL(from_obj, 3) = 0; DRINK_CON_TYPE(from_obj) = 0;
} DRINK_CON_POISON(from_obj) = 0;
else
send_to_char(ch, "You can't possibly pour that container out!\r\n");
return; return;
} }
@@ -1094,8 +1112,7 @@ ACMD(do_pour)
send_to_char(ch, "You can't find it!\r\n"); send_to_char(ch, "You can't find it!\r\n");
return; return;
} }
if ((GET_OBJ_TYPE(to_obj) != ITEM_DRINKCON) && if ((GET_OBJ_TYPE(to_obj) != ITEM_DRINKCON) && (GET_OBJ_TYPE(to_obj) != ITEM_FOUNTAIN)) {
(GET_OBJ_TYPE(to_obj) != ITEM_FOUNTAIN)) {
send_to_char(ch, "You can't pour anything into that.\r\n"); send_to_char(ch, "You can't pour anything into that.\r\n");
return; return;
} }
@@ -1104,59 +1121,62 @@ ACMD(do_pour)
send_to_char(ch, "A most unproductive effort.\r\n"); send_to_char(ch, "A most unproductive effort.\r\n");
return; return;
} }
if ((GET_OBJ_VAL(to_obj, 0) < 0) || if (!EMPTY_DRINK_CONTAINER(to_obj) && DRINK_CON_TYPE(to_obj) != DRINK_CON_TYPE(from_obj)) {
(!(GET_OBJ_VAL(to_obj, 1) < GET_OBJ_VAL(to_obj, 0)))) {
send_to_char(ch, "There is already another liquid in it!\r\n"); send_to_char(ch, "There is already another liquid in it!\r\n");
return; return;
} }
if (!(GET_OBJ_VAL(to_obj, 1) < GET_OBJ_VAL(to_obj, 0))) { // Not allowed to fill an unlimited container, or a container that is already full.
if (!LIMITED_DRINK_CONTAINER(to_obj) || DRINK_CON_NOW(to_obj) >= DRINK_CON_MAX(to_obj)) {
send_to_char(ch, "There is no room for more.\r\n"); send_to_char(ch, "There is no room for more.\r\n");
return; return;
} }
if (subcmd == SCMD_POUR) if (subcmd == SCMD_POUR)
send_to_char(ch, "You pour the %s into the %s.", drinks[GET_OBJ_VAL(from_obj, 2)], arg2); send_to_char(ch, "You pour the %s into the %s.\r\n", drinks[DRINK_CON_TYPE(from_obj)], arg2);
if (subcmd == SCMD_FILL) { if (subcmd == SCMD_FILL) {
act("You gently fill $p from $P.", FALSE, ch, to_obj, from_obj, TO_CHAR); act("You gently fill $p from $P.", FALSE, ch, to_obj, from_obj, TO_CHAR);
act("$n gently fills $p from $P.", TRUE, ch, to_obj, from_obj, TO_ROOM); act("$n gently fills $p from $P.", TRUE, ch, to_obj, from_obj, TO_ROOM);
} }
/* New alias */ /* New alias */
if (GET_OBJ_VAL(to_obj, 1) == 0) if (EMPTY_DRINK_CONTAINER(to_obj))
name_to_drinkcon(to_obj, GET_OBJ_VAL(from_obj, 2)); name_to_drinkcon(to_obj, DRINK_CON_TYPE(from_obj));
/* First same type liq. */ /* First same type liq. */
GET_OBJ_VAL(to_obj, 2) = GET_OBJ_VAL(from_obj, 2); DRINK_CON_TYPE(to_obj) = DRINK_CON_TYPE(from_obj);
/* Then how much to pour */ /* Then how much to pour */
if (GET_OBJ_VAL(from_obj, 0) > 0) { if (LIMITED_DRINK_CONTAINER(from_obj)) {
GET_OBJ_VAL(from_obj, 1) -= (amount = amount = MIN(DRINK_CON_NOW(from_obj), DRINK_CON_MAX(to_obj) - DRINK_CON_NOW(to_obj));
(GET_OBJ_VAL(to_obj, 0) - GET_OBJ_VAL(to_obj, 1))); DRINK_CON_NOW(from_obj) -= amount;
DRINK_CON_NOW(to_obj) += amount;
GET_OBJ_VAL(to_obj, 1) = GET_OBJ_VAL(to_obj, 0); if (DRINK_CON_NOW(from_obj) == 0) { /* It was emptied */
if (GET_OBJ_VAL(from_obj, 1) < 0) { /* There was too little */
GET_OBJ_VAL(to_obj, 1) += GET_OBJ_VAL(from_obj, 1);
amount += GET_OBJ_VAL(from_obj, 1);
name_from_drinkcon(from_obj); name_from_drinkcon(from_obj);
GET_OBJ_VAL(from_obj, 1) = 0; DRINK_CON_NOW(from_obj) = 0;
GET_OBJ_VAL(from_obj, 2) = 0; DRINK_CON_TYPE(from_obj) = 0;
GET_OBJ_VAL(from_obj, 3) = 0; DRINK_CON_POISON(from_obj) = 0;
} }
} } else {
else { amount = DRINK_CON_MAX(to_obj) - DRINK_CON_NOW(to_obj);
GET_OBJ_VAL(to_obj, 1) = GET_OBJ_VAL(to_obj, 0); DRINK_CON_NOW(to_obj) = DRINK_CON_MAX(to_obj);
amount = GET_OBJ_VAL(to_obj, 0);
} }
/* Poisoned? */ /* Poisoned? */
GET_OBJ_VAL(to_obj, 3) = (GET_OBJ_VAL(to_obj, 3) || GET_OBJ_VAL(from_obj, 3)) DRINK_CON_POISON(to_obj) = (DRINK_CON_POISON(to_obj) || DRINK_CON_POISON(from_obj));
;
/* Weight change, except for unlimited. */ /* Weight change, except for unlimited. */
if (GET_OBJ_VAL(from_obj, 0) > 0) { if (LIMITED_DRINK_CONTAINER(from_obj)) {
weight_change_object(from_obj, -amount); weight_change_object(from_obj, -amount);
} }
weight_change_object(to_obj, amount); /* Add weight */ weight_change_object(to_obj, amount); /* Add weight */
} }
#undef DRINK_CON_MAX
#undef DRINK_CON_NOW
#undef DRINK_CON_TYPE
#undef DRINK_CON_POISON
#undef LIMITED_DRINK_CONTAINER
#undef EMPTY_DRINK_CONTAINER
static void wear_message(struct char_data *ch, struct obj_data *obj, int where) static void wear_message(struct char_data *ch, struct obj_data *obj, int where)
{ {
const char *wear_messages[][2] = { const char *wear_messages[][2] = {
+1 -1
View File
@@ -56,7 +56,7 @@ ACMD(do_action)
if (!action->char_found) if (!action->char_found)
*arg = '\0'; *arg = '\0';
if (action->char_found && argument) if (action->char_found)
one_argument(argument, arg); one_argument(argument, arg);
else else
*arg = '\0'; *arg = '\0';
+4 -1
View File
@@ -2396,7 +2396,10 @@ ACMD(do_wizutil)
act("A sudden fireball conjured from nowhere thaws $n!", FALSE, vict, 0, 0, TO_ROOM); act("A sudden fireball conjured from nowhere thaws $n!", FALSE, vict, 0, 0, TO_ROOM);
break; break;
case SCMD_UNAFFECT: case SCMD_UNAFFECT:
if (vict->affected || AFF_FLAGS(vict)) { for (taeller = 0; taeller < AF_ARRAY_MAX; taeller++)
if (AFF_FLAGS(vict)[taeller])
break;
if (vict->affected || taeller < AF_ARRAY_MAX) {
while (vict->affected) while (vict->affected)
affect_remove(vict, vict->affected); affect_remove(vict, vict->affected);
for(taeller=0; taeller < AF_ARRAY_MAX; taeller++) for(taeller=0; taeller < AF_ARRAY_MAX; taeller++)
+3 -3
View File
@@ -374,9 +374,9 @@ SPECIAL(king_welmar)
"$n proclaims 'principe dignos'." "$n proclaims 'principe dignos'."
}; };
const char bedroom_path[] = "s33004o1c1S."; static const char bedroom_path[] = "s33004o1c1S.";
const char throne_path[] = "W3o3cG52211rg."; static const char throne_path[] = "W3o3cG52211rg.";
const char monolog_path[] = "ABCDPPPP."; static const char monolog_path[] = "ABCDPPPP.";
static const char *path; static const char *path;
static int path_index; static int path_index;
+3 -1
View File
@@ -246,7 +246,8 @@ void entry_memory_mtrigger(char_data *ch)
for (actor = world[IN_ROOM(ch)].people; actor && SCRIPT_MEM(ch); for (actor = world[IN_ROOM(ch)].people; actor && SCRIPT_MEM(ch);
actor = actor->next_in_room) { actor = actor->next_in_room) {
if (actor!=ch && SCRIPT_MEM(ch)) { if (actor!=ch && SCRIPT_MEM(ch)) {
for (mem = SCRIPT_MEM(ch); mem && SCRIPT_MEM(ch); mem = mem->next) { for (mem = SCRIPT_MEM(ch); mem && SCRIPT_MEM(ch); ) {
struct script_memory *next_mem = mem->next;
if (char_script_id(actor)==mem->id) { if (char_script_id(actor)==mem->id) {
struct script_memory *prev; struct script_memory *prev;
if (mem->cmd) command_interpreter(ch, mem->cmd); if (mem->cmd) command_interpreter(ch, mem->cmd);
@@ -271,6 +272,7 @@ void entry_memory_mtrigger(char_data *ch)
if (mem->cmd) free(mem->cmd); if (mem->cmd) free(mem->cmd);
free(mem); free(mem);
} }
mem = next_mem;
} /* for (mem =..... */ } /* for (mem =..... */
} }
} }
+2 -2
View File
@@ -465,7 +465,7 @@ void find_replacement(void *go, struct script_data *sc, trig_data *trig,
* will return the number of bags of gold. * will return the number of bags of gold.
* Addition inspired by Jamie Nelson */ * Addition inspired by Jamie Nelson */
else if (!str_cmp(var, "findmob")) { else if (!str_cmp(var, "findmob")) {
if (!field || !*field || !subfield || !*subfield) { if (!*field || !subfield || !*subfield) {
script_log("findmob.vnum(mvnum) - illegal syntax"); script_log("findmob.vnum(mvnum) - illegal syntax");
strcpy(str, "0"); strcpy(str, "0");
} else { } else {
@@ -486,7 +486,7 @@ void find_replacement(void *go, struct script_data *sc, trig_data *trig,
} }
/* Addition inspired by Jamie Nelson. */ /* Addition inspired by Jamie Nelson. */
else if (!str_cmp(var, "findobj")) { else if (!str_cmp(var, "findobj")) {
if (!field || !*field || !subfield || !*subfield) { if (!*field || !subfield || !*subfield) {
script_log("findobj.vnum(ovnum) - illegal syntax"); script_log("findobj.vnum(ovnum) - illegal syntax");
strcpy(str, "0"); strcpy(str, "0");
} else { } else {
+2 -2
View File
@@ -367,7 +367,7 @@ void parse_edit_action(int command, char *string, struct descriptor_data *d)
s++; s++;
temp = *s; temp = *s;
*s = '\0'; *s = '\0';
char buf3[9]; char buf3[13];
sprintf(buf3, "%4d: ", (i - 1)); sprintf(buf3, "%4d: ", (i - 1));
strncat(buf, buf3, sizeof(buf) - strlen(buf) - 1); strncat(buf, buf3, sizeof(buf) - strlen(buf) - 1);
strncat(buf, t, sizeof(buf) - strlen(buf) - 1); strncat(buf, t, sizeof(buf) - strlen(buf) - 1);
@@ -421,7 +421,7 @@ void parse_edit_action(int command, char *string, struct descriptor_data *d)
strncat(buf, *d->str, sizeof(buf) - strlen(buf) - 1); strncat(buf, *d->str, sizeof(buf) - strlen(buf) - 1);
*s = temp; *s = temp;
strncat(buf, buf2, sizeof(buf) - strlen(buf) - 1); strncat(buf, buf2, sizeof(buf) - strlen(buf) - 1);
if (s && *s) if (*s)
strncat(buf, s, sizeof(buf) - strlen(buf) - 1); strncat(buf, s, sizeof(buf) - strlen(buf) - 1);
RECREATE(*d->str, char, strlen(buf) + 3); RECREATE(*d->str, char, strlen(buf) + 3);
+2 -1
View File
@@ -1612,8 +1612,9 @@ void nanny(struct descriptor_data *d, char *arg)
if (load_result == CLASS_UNDEFINED) { if (load_result == CLASS_UNDEFINED) {
write_to_output(d, "\r\nThat's not a class.\r\nClass: "); write_to_output(d, "\r\nThat's not a class.\r\nClass: ");
return; return;
} else } else {
GET_CLASS(d->character) = load_result; GET_CLASS(d->character) = load_result;
}
if (d->olc) { if (d->olc) {
free(d->olc); free(d->olc);
+6 -1
View File
@@ -2102,9 +2102,11 @@ static void ExecuteMSDPPair( descriptor_t *apDescriptor, const char *apVariable,
!strcmp(apDescriptor->pProtocol->pVariables[i]->pValueString, "Unknown") ) !strcmp(apDescriptor->pProtocol->pVariables[i]->pValueString, "Unknown") )
{ {
/* Store the new value if it's valid */ /* Store the new value if it's valid */
char *pBuffer = alloca(VariableNameTable[i].Max+1); char *pBuffer = malloc(VariableNameTable[i].Max + 1);
int j; /* Loop counter */ int j; /* Loop counter */
if ( pBuffer != NULL )
{
for ( j = 0; j < VariableNameTable[i].Max && *apValue != '\0'; ++apValue ) for ( j = 0; j < VariableNameTable[i].Max && *apValue != '\0'; ++apValue )
{ {
if ( isprint(*apValue) ) if ( isprint(*apValue) )
@@ -2117,6 +2119,9 @@ static void ExecuteMSDPPair( descriptor_t *apDescriptor, const char *apVariable,
free(apDescriptor->pProtocol->pVariables[i]->pValueString); free(apDescriptor->pProtocol->pVariables[i]->pValueString);
apDescriptor->pProtocol->pVariables[i]->pValueString = AllocString(pBuffer); apDescriptor->pProtocol->pVariables[i]->pValueString = AllocString(pBuffer);
} }
free(pBuffer);
}
} }
} }
else /* This variable only accepts numeric values */ else /* This variable only accepts numeric values */
+1 -1
View File
@@ -650,7 +650,7 @@ static void quest_show(struct char_data *ch, mob_vnum qm)
send_to_char(ch, "There are no quests available here at the moment.\r\n"); send_to_char(ch, "There are no quests available here at the moment.\r\n");
} }
static void quest_stat(struct char_data *ch, char argument[MAX_STRING_LENGTH]) static void quest_stat(struct char_data *ch, char *argument)
{ {
qst_rnum rnum; qst_rnum rnum;
mob_rnum qmrnum; mob_rnum qmrnum;
+1 -1
View File
@@ -1052,7 +1052,7 @@ static void read_line(FILE *shop_f, const char *string, void *data)
{ {
char buf[READ_SIZE]; char buf[READ_SIZE];
if (!get_line(shop_f, buf) || !sscanf(buf, string, data)) { if (!get_line(shop_f, buf) || sscanf(buf, string, data) != 1) {
log("SYSERR: Error in shop #%d, near '%s' with '%s'", SHOP_NUM(top_shop), buf, string); log("SYSERR: Error in shop #%d, near '%s' with '%s'", SHOP_NUM(top_shop), buf, string);
exit(1); exit(1);
} }
+2 -2
View File
@@ -202,9 +202,9 @@ SPECIAL(mayor)
{ {
char actbuf[MAX_INPUT_LENGTH]; char actbuf[MAX_INPUT_LENGTH];
const char open_path[] = static const char open_path[] =
"W3a3003b33000c111d0d111Oe333333Oe22c222112212111a1S."; "W3a3003b33000c111d0d111Oe333333Oe22c222112212111a1S.";
const char close_path[] = static const char close_path[] =
"W3a3003b33000c111d0d111CE333333CE22c222112212111a1S."; "W3a3003b33000c111d0d111CE333333CE22c222112212111a1S.";
static const char *path = NULL; static const char *path = NULL;