forked from github/server
use swap database for unit descriptions.
This commit is contained in:
parent
53e123b36a
commit
be0c0161da
2 changed files with 14 additions and 10 deletions
|
@ -474,8 +474,8 @@ attrib_type at_private = {
|
||||||
|
|
||||||
const char *u_description(const unit * u, const struct locale *lang)
|
const char *u_description(const unit * u, const struct locale *lang)
|
||||||
{
|
{
|
||||||
if (u->_display && u->_display[0]) {
|
if (u->display_id > 0) {
|
||||||
return u->_display;
|
return unit_getinfo(u);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
char zText[64];
|
char zText[64];
|
||||||
|
@ -1293,7 +1293,6 @@ void free_unit(unit * u)
|
||||||
{
|
{
|
||||||
assert(!u->region);
|
assert(!u->region);
|
||||||
free(u->_name);
|
free(u->_name);
|
||||||
free(u->_display);
|
|
||||||
free_order(u->thisorder);
|
free_order(u->thisorder);
|
||||||
free_orders(&u->orders);
|
free_orders(&u->orders);
|
||||||
if (u->skills)
|
if (u->skills)
|
||||||
|
@ -1522,16 +1521,20 @@ void unit_setname(unit * u, const char *name)
|
||||||
|
|
||||||
const char *unit_getinfo(const unit * u)
|
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)
|
void unit_setinfo(unit * u, const char *info)
|
||||||
{
|
{
|
||||||
free(u->_display);
|
if (info) {
|
||||||
if (info)
|
u->display_id = dbstring_save(info);
|
||||||
u->_display = str_strdup(info);
|
}
|
||||||
else
|
else {
|
||||||
u->_display = NULL;
|
u->display_id = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int unit_getid(const unit * u)
|
int unit_getid(const unit * u)
|
||||||
|
|
|
@ -21,6 +21,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
#include <util/resolve.h>
|
#include <util/resolve.h>
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
#include "database.h"
|
||||||
#include "skills.h"
|
#include "skills.h"
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
|
@ -89,7 +90,7 @@ extern "C" {
|
||||||
int no; /* id */
|
int no; /* id */
|
||||||
int hp;
|
int hp;
|
||||||
char *_name;
|
char *_name;
|
||||||
char *_display;
|
dbrow_id display_id;
|
||||||
struct faction *faction;
|
struct faction *faction;
|
||||||
struct building *building;
|
struct building *building;
|
||||||
struct ship *ship;
|
struct ship *ship;
|
||||||
|
|
Loading…
Reference in a new issue