Clean up signs when reading

This commit is contained in:
Simon Robertshaw 2011-06-08 18:09:03 +01:00
parent 3ea25c83b7
commit 09a3670d64
3 changed files with 16 additions and 0 deletions

View File

@ -44,6 +44,8 @@ void strlist_free(struct strlist **list);
void save_presets(int do_update);
void clean_text(char *text, int vwidth);
void load_presets(void);
void save_string(FILE *f, char *str);

View File

@ -1036,6 +1036,7 @@ int parse_save(void *save, int size, int replace, int x0, int y0, unsigned char
{
memcpy(signs[k].text, d+p, x);
signs[k].text[x] = 0;
clean_text(signs[k].text, 158-14 /* Current max sign length */);
}
p += x;
}

View File

@ -99,6 +99,19 @@ void strlist_free(struct strlist **list)
}
}
void clean_text(char *text, int vwidth)
{
int i = 0;
if(textwidth(text) > vwidth){
text[textwidthx(text, vwidth)] = 0;
}
for(i = 0; i < strlen(text); i++){
if(! (text[i]>=' ' && text[i]<127)){
text[i] = ' ';
}
}
}
void save_presets(int do_update)
{
FILE *f=fopen("powder.def", "wb");