-char * s[26];
+char * s[27];
s[S_CMD_PICKUP] = "pick_up";
s[S_CMD_DROP] = "drop";
s[S_CMD_USE] = "use";
+ s[S_FCN_SPRINTF] = "sprintf()";
}
S_CMD_MOVE,
S_CMD_PICKUP,
S_CMD_DROP,
- S_CMD_USE
+ S_CMD_USE,
+ S_FCN_SPRINTF
};
extern void init_strings();
-extern char * s[26];
+extern char * s[27];
world.file_out = try_fopen(s[S_PATH_OUT], "w", f_name);
world.server_test = try_malloc(10 + 1 + 10 + 1 + 1, f_name);
test = sprintf(world.server_test, "%d %d\n", getpid(), (int) time(0));
- exit_trouble(test < 0, f_name, "sprintf()");
+ exit_trouble(test < 0, f_name, s[S_FCN_SPRINTF]);
try_fwrite(world.server_test, strlen(world.server_test), 1,
world.file_out, f_name);
fflush(world.file_out);
char * command = s[S_CMD_MAKE_WORLD];
char * msg = try_malloc(strlen(command) + 1 + 11 + 1, f_name);
int test = sprintf(msg, "%s %d", command, (int) time(NULL));
- exit_trouble(test < 0, f_name, "sprintf()");
+ exit_trouble(test < 0, f_name, s[S_FCN_SPRINTF]);
obey_msg(msg, 1);
free(msg);
}
try_fwrite(key, strlen(key), 1, file, f_name);
try_fputc(' ', file, f_name);
char * line = try_malloc(11, f_name);
- exit_trouble(-1 == sprintf(line, "%u", value), f_name, "sprintf()");
+ exit_trouble(-1 == sprintf(line, "%u", value), f_name, s[S_FCN_SPRINTF]);
try_fwrite(line, strlen(line), 1, file, f_name);
free(line);
try_fputc('\n', file, f_name);
uint16_t size = strlen(s[S_PATH_WORLDSTATE])+strlen(s[S_PATH_SUFFIX_TMP])+1;
char * path_tmp = try_malloc(size, f_name);
int test=sprintf(path_tmp,"%s%s",s[S_PATH_WORLDSTATE],s[S_PATH_SUFFIX_TMP]);
- exit_trouble(test < 0, f_name, "sprintf()");
+ exit_trouble(test < 0, f_name, s[S_FCN_SPRINTF]);
FILE * file = try_fopen(path_tmp, "w", f_name);
struct Thing * player = get_player();
write_value_as_line(world.turn, file);
{
char * f_name = "write_value_as_line()";
char write_buf[12]; /* Holds 10 digits of uint32_t maximum + \n + \0. */
- exit_trouble(sprintf(write_buf, "%u\n", value) < 0, f_name, "sprintf()");
+ exit_trouble(sprintf(write_buf, "%u\n",value) < 0, f_name,s[S_FCN_SPRINTF]);
try_fwrite(write_buf, strlen(write_buf), 1, file, f_name);
}
uint16_t size = strlen(s[S_PATH_RECORD]) + strlen(s[S_PATH_SUFFIX_TMP]) + 1;
char * path_tmp = try_malloc(size, f_name);
int test = sprintf(path_tmp, "%s%s", s[S_PATH_RECORD],s[S_PATH_SUFFIX_TMP]);
- exit_trouble(test < 0, f_name, "sprintf()");
+ exit_trouble(test < 0, f_name, s[S_FCN_SPRINTF]);
FILE * file_tmp = try_fopen(path_tmp, "w", f_name);
if (!access(s[S_PATH_RECORD], F_OK))
{
#include "../common/try_malloc.h" /* try_malloc() */
#include "../common/yx_uint8.h" /* struct yx_uint8 */
#include "field_of_view.h" /* build_fov_map() */
+#include "hardcoded_strings.h" /* s */
#include "things.h" /* structs Thing, ThingType, get_player(), own_thing(),
* set_thing_position(), get_thing_type()
*/
char * new_text = try_malloc(len_whole, f_name);
memcpy(new_text, world.log + offset, len_old);
int test = sprintf(new_text + len_old, "%s", text);
- exit_trouble(test < 0, f_name, "sprintf()");
+ exit_trouble(test < 0, f_name, s[S_FCN_SPRINTF]);
free(world.log);
world.log = new_text;
}
uint8_t len = 1 + strlen(msg1) + 1 + strlen(msg2) + 1 + strlen(msg3) + 2;
char * msg = try_malloc(len, f_name);
int test = sprintf(msg, "\n%s %s %s.", msg1, msg2, msg3);
- exit_trouble(test < 0, f_name, "sprintf()");
+ exit_trouble(test < 0, f_name, s[S_FCN_SPRINTF]);
update_log(msg);
free(msg);
hitted->lifepoints--;
}
char * msg = try_malloc(strlen(dsc_move) + strlen (dsc_dir) + 3, f_name);
int test = sprintf(msg, "\n%s%s.", dsc_move, dsc_dir);
- exit_trouble(test < 0, f_name, "sprintf()");
+ exit_trouble(test < 0, f_name, s[S_FCN_SPRINTF]);
update_log(msg);
free(msg);
}
#include "../common/rexit.h" /* exit_err(), exit_trouble() */
#include "../common/try_malloc.h" /* try_malloc() */
#include "../common/yx_uint8.h" /* yx_uint8 */
+#include "hardcoded_strings.h" /* s */
#include "map.h" /* is_passable() */
#include "rrand.h" /* rrand() */
#include "world.h" /* global world */
char * err_intro = "Requested thing type of unused ID ";
uint16_t size = strlen(err_intro) + 3 + 1 + 1;
char * err = try_malloc(size, f_name);
- exit_trouble(sprintf(err, "%s%d.", err_intro, id) < 0, f_name, "sprintf()");
+ exit_trouble(sprintf(err,"%s%d.",err_intro,id) < 0,f_name,s[S_FCN_SPRINTF]);
exit_err(NULL == tt, err);
free(err);
return tt;