use swap database for unit descriptions.

This commit is contained in:
Enno Rehling 2018-10-24 20:21:21 +02:00
parent 53e123b36a
commit be0c0161da
2 changed files with 14 additions and 10 deletions

View File

@ -474,8 +474,8 @@ attrib_type at_private = {
const char *u_description(const unit * u, const struct locale *lang)
{
if (u->_display && u->_display[0]) {
return u->_display;
if (u->display_id > 0) {
return unit_getinfo(u);
}
else {
char zText[64];
@ -1293,7 +1293,6 @@ void free_unit(unit * u)
{
assert(!u->region);
free(u->_name);
free(u->_display);
free_order(u->thisorder);
free_orders(&u->orders);
if (u->skills)
@ -1522,16 +1521,20 @@ void unit_setname(unit * u, const char *name)
const char *unit_getinfo(const unit * u)
{
return (const char *)u->_display;
if (u->display_id > 0) {
return dbstring_load(u->display_id, NULL);
}
return NULL;
}
void unit_setinfo(unit * u, const char *info)
{
free(u->_display);
if (info)
u->_display = str_strdup(info);
else
u->_display = NULL;
if (info) {
u->display_id = dbstring_save(info);
}
else {
u->display_id = 0;
}
}
int unit_getid(const unit * u)

View File

@ -21,6 +21,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <util/resolve.h>
#include "types.h"
#include "database.h"
#include "skills.h"
#include <stddef.h>
@ -89,7 +90,7 @@ extern "C" {
int no; /* id */
int hp;
char *_name;
char *_display;
dbrow_id display_id;
struct faction *faction;
struct building *building;
struct ship *ship;