if (ch->hitroll < 1001){
sprintf(arg, "%d", (hitroll / 8) + 1);
strcat (buf, "\n\r{cHitroll{W: {mCost is ");
strcat (buf, arg);
strcat (buf, " trains per point{x");
}
if (ch->hitroll < 1001){
sprintf(arg, "\n\r{cHitroll{W: {mCost is %d trains per point{x", (hitroll / 8) + 1);
strcat (buf, arg);
}
void cat_sprintf(char *dest, const char *fmt, …)
{
char buf[MAX_STRING_LENGTH];
va_list args;
va_start(args, fmt);
vsprintf(buf, fmt, args);
va_end(args);
strcat(dest, buf);
}
if (ch->hitroll < 1001)
{
cat_sprintf(buf, "\n\r{cHitroll{W: {m", (hitroll / 8) + 1);
}
void cat_sprintf(char *dest, const char *fmt, …)
{
char buf[MAX_STRING_LENGTH];
va_list args;
va_start(args, fmt);
vsprintf(buf, fmt, args);
va_end(args);
strcat(dest, buf);
}
if (ch->hitroll < 1001)
{
cat_sprintf(buf, "\n\r{cHitroll{W: {m", (hitroll / 8) + 1);
}
send_to_char(ch, "The number is %d.\r\n", number);
sprintf(buf, "The number is %d.\r\n", number);
send_to_char(buf, ch);
if (ch->hitroll < 1001){
sprintf(arg, "%d", (hitroll / 8) + 1);
strcat (buf, "\n\r{cHitroll{W: {mCost is ");
strcat (buf, arg);
strcat (buf, " trains per point{x");
}
if (ch->hitroll < 1001){
sprintf(arg, "\n\r{cHitroll{W: {mCost is %d trains per point{x", (hitroll / 8) + 1);
strcat (buf, arg);
}
if (ch->hitroll < 1001){
sprintf(arg, "%d", (hitroll / 8) + 1);
strcat (buf, "\n\r{cHitroll{W: {mCost is ");
strcat (buf, arg);
strcat (buf, " trains per point{x");
}
if (ch->hitroll < 1001){
sprintf(arg, "\n\r{cHitroll{W: {mCost is %d trains per point{x", (hitroll / 8) + 1);
strcat (buf, arg);
}
act_move.c: In function `do_train':
act_move.c:1792: warning: passing arg 1 of `sprintf' makes pointer from integer without a cast
act_move.c:1794: warning: passing arg 2 of `strcat' makes pointer from integer without a cast
act_move.c:1797: warning: passing arg 1 of `sprintf' makes pointer from integer without a cast
act_move.c:1799: warning: passing arg 2 of `strcat' makes pointer from integer without a cast
act_move.c:1694: warning: `arg' might be used uninitialized in this function
char* arg
if (foo > 10) {
arg = something_else;
}
do_blah(arg); /* arg has an undefined value if foo <= 10 */
char *arg;
sprintf(arg, "Some stuff."); /* copying a string into a random memory location */
char arg[MAX_STRING_LEN];
strcat(arg, "text to append"); /* appending text to a buffer that hasm't be initialized */
void do_train (CHAR_DATA * ch, char *argument)
{
char buf[MAX_STRING_LENGTH];
CHAR_DATA *mob;
sh_int stat = -1;
char *pOutput = NULL;
int cost;
if (IS_NPC (ch))
return;
/*
* Check for trainer.
*/
for (mob = ch->in_room->people; mob; mob = mob->next_in_room)
{
if (IS_NPC (mob) && IS_SET (mob->act, ACT_TRAIN))
break;
}
if (mob == NULL)
{
send_to_char ("You can't do that here.\n\r", ch);
return;
}
if (argument[0] == '\0')
{
sprintf (buf, "You have %d training sessions.\n\r", ch->train);
send_to_char (buf, ch);
argument = "foo";
}
cost = 1;
if (!str_cmp (argument, "str"))
{
if (class_table[ch->class].attr_prime == STAT_STR)
cost = 1;
stat = STAT_STR;
pOutput = "strength";
}
else if (!str_cmp (argument, "int"))
{
if (class_table[ch->class].attr_prime == STAT_INT)
cost = 1;
stat = STAT_INT;
pOutput = "intelligence";
}
else if (!str_cmp (argument, "wis"))
{
if (class_table[ch->class].attr_prime == STAT_WIS)
cost = 1;
stat = STAT_WIS;
pOutput = "wisdom";
}
else if (!str_cmp (argument, "dex"))
{
if (class_table[ch->class].attr_prime == STAT_DEX)
cost = 1;
stat = STAT_DEX;
pOutput = "dexterity";
}
else if (!str_cmp (argument, "con"))
{
if (class_table[ch->class].attr_prime == STAT_CON)
cost = 1;
stat = STAT_CON;
pOutput = "constitution";
}
else if (!str_cmp (argument, "hp"))
cost = 1;
else if (!str_cmp (argument, "mana"))
cost = 1;
else if (!str_cmp (argument, "move"))
cost = 1;
else if (!str_cmp (argument, "hitroll"))
cost = (ch->hitroll / 8) + 1;
else if (!str_cmp (argument, "damroll"))
cost = (ch->damroll / 8) + 1;
else
{
strcpy (buf, "{cYou can train{W:{x\n\r");
if (ch->perm_stat[STAT_STR] < get_max_train (ch, STAT_STR))
strcat (buf, " {Rstr{x");
if (ch->perm_stat[STAT_INT] < get_max_train (ch, STAT_INT))
strcat (buf, " {Yint{x");
if (ch->perm_stat[STAT_WIS] < get_max_train (ch, STAT_WIS))
strcat (buf, " {Gwis{x");
if (ch->perm_stat[STAT_DEX] < get_max_train (ch, STAT_DEX))
strcat (buf, " {Bdex{x");
if (ch->perm_stat[STAT_CON] < get_max_train (ch, STAT_CON))
strcat (buf, " {Mcon{x");
if (ch->hitroll < 1001)
sprintf(arg, "%d", (ch->hitroll / 8) + 1);
strcat (buf, "\n\r{cHitroll{W: {mCost is ");
strcat (buf, arg);
strcat (buf, " trains per point{x");
if (ch->damroll < 1001)
sprintf(arg, "%d", (ch->damroll / 8) +1);
strcat (buf, "\n\r{cDamroll{W: {mCost is ");
strcat (buf, arg);
strcat (buf, " trains per point{x");
strcat (buf, "\n\r{chp mana move{W: {mCost is 1 train per 10 points{x");
if (buf[strlen (buf) - 1] != ':')
{
strcat (buf, ".\n\r");
send_to_char (buf, ch);
}
else
{
/*
* This message dedicated to Jordan … you big stud!
*/
act ("You have nothing left to train, you $T!",
ch, NULL,
ch->sex == SEX_MALE ? "big stud" :
ch->sex == SEX_FEMALE ? "hot babe" : "wild thing", TO_CHAR);
}
return;
}
if (!str_cmp ("hp", argument))
{
if (cost > ch->train)
{
send_to_char ("You don't have enough training sessions.\n\r", ch);
return;
}
ch->train -= cost;
ch->pcdata->perm_hit += 10;
ch->max_hit += 10;
ch->hit += 10;
act ("Your durability increases!", ch, NULL, NULL, TO_CHAR);
act ("$n's durability increases!", ch, NULL, NULL, TO_ROOM);
return;
}
if (!str_cmp ("mana", argument))
{
if (cost > ch->train)
{
send_to_char ("You don't have enough training sessions.\n\r", ch);
return;
}
ch->train -= cost;
ch->pcdata->perm_mana += 10;
ch->max_mana += 10;
ch->mana += 10;
act ("Your power increases!", ch, NULL, NULL, TO_CHAR);
act ("$n's power increases!", ch, NULL, NULL, TO_ROOM);
return;
}
if (!str_cmp ("move", argument ))
{
if (cost > ch->train)
{
send_to_char ("You don't have enough training sessions.\n\r", ch);
return;
}
ch->train -= cost;
ch->pcdata->perm_move += 10;
ch->max_move += 10;
ch->move += 10;
act ("Your stamina improves!", ch, NULL, NULL, TO_CHAR);
act ("$n's stamina improves!", ch, NULL, NULL, TO_ROOM);
return;
}
if (!str_cmp ("damroll", argument ))
{
if (cost > ch->train)
{
send_to_char ("You don't have enough training sessions.\n\r", ch);
return;
}
ch->train -= cost;
ch->damroll += 1;
act ("You increase your damroll!", ch, NULL, NULL, TO_CHAR);
act ("$n's damroll increases!", ch, NULL, NULL, TO_ROOM);
return;
}
if (!str_cmp ("hitroll", argument ))
{
if (cost > ch->train)
{
send_to_char ("You don't have enough training sessions.\n\r", ch);
return;
}
ch->train -= cost;
ch->hitroll += 1;
act ("You increase your hitroll!", ch, NULL, NULL, TO_CHAR);
act ("$n's hitroll increases!", ch, NULL, NULL, TO_ROOM);
return;
}
if (ch->perm_stat[stat] >= get_max_train (ch, stat))
{
act ("Your $T is already at maximum.", ch, NULL, pOutput, TO_CHAR);
return;
}
if (cost > ch->train)
{
send_to_char ("You don't have enough training sessions.\n\r", ch);
return;
}
ch->train -= cost;
ch->perm_stat[stat] += 1;
act ("Your $T increases!", ch, NULL, pOutput, TO_CHAR);
act ("$n's $T increases!", ch, NULL, pOutput, TO_ROOM);
return;
}
char arg[MAX_INPUT_LENGTH];
sprintf(buf+strlen(buf), "\n\r{cHitroll{W: {mCost is %d trains per point{x", (hitroll / 8) + 1);
if (ch->hitroll < 1001)
sprintf(arg, "%d", (ch->hitroll / 8) + 1);
strcat (buf, "\n\r{cHitroll{W: {mCost is ");
strcat (buf, arg);
strcat (buf, " trains per point{x");
if (ch->damroll < 1001)
sprintf(arg, "%d", (ch->damroll / 8) +1);
strcat (buf, "\n\r{cDamroll{W: {mCost is ");
strcat (buf, arg);
strcat (buf, " trains per point{x");
if (ch->hitroll < 1001)
sprintf(buf+strlen(buf), "\n\r{cHitroll{W: {mCost is %d trains per point{x", (ch->hitroll / 8) + 1));
if (ch->damroll < 1001)
sprintf(buf+strlen(buf), "\n\r{cDamroll{W: {mCost is %d trains per point{x, (ch->damroll / 8) + 1));
if anybody can tell me how to do this it would help to restore a small portion of my sanity… maybe…
[edit to add] i'm probably going to put a maximum on it later on but for now i just want this to display the cost instead of making the players do the math themselves.