SCI: Changed some char* into Common::String
svn-id: r39663
This commit is contained in:
parent
33895c0220
commit
b76f7fea4e
10 changed files with 25 additions and 63 deletions
|
@ -603,7 +603,7 @@ int game_init(EngineState *s) {
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
s->successor = NULL; // No successor
|
s->successor = NULL; // No successor
|
||||||
s->status_bar_text = NULL; // Status bar is blank
|
s->_statusBarText.clear(); // Status bar is blank
|
||||||
s->status_bar_foreground = 0;
|
s->status_bar_foreground = 0;
|
||||||
s->status_bar_background = s->resmgr->_sciVersion >= SCI_VERSION_01_VGA ? 255 : 15;
|
s->status_bar_background = s->resmgr->_sciVersion >= SCI_VERSION_01_VGA ? 255 : 15;
|
||||||
|
|
||||||
|
@ -628,20 +628,16 @@ int game_init(EngineState *s) {
|
||||||
game_obj = script_lookup_export(s, 0, 0);
|
game_obj = script_lookup_export(s, 0, 0);
|
||||||
// The first entry in the export table of script 0 points to the game object
|
// The first entry in the export table of script 0 points to the game object
|
||||||
|
|
||||||
s->game_name = sci_strdup(obj_get_name(s, game_obj));
|
const char *tmp = obj_get_name(s, game_obj);
|
||||||
|
|
||||||
if (!s->game_name) {
|
if (!tmp) {
|
||||||
sciprintf("Error: script.000, export 0 ("PREG") does not\n"
|
sciprintf("Error: script.000, export 0 ("PREG") does not\n"
|
||||||
" yield an object with a name -> sanity check failed\n", PRINT_REG(game_obj));
|
" yield an object with a name -> sanity check failed\n", PRINT_REG(game_obj));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
s->_gameName = tmp;
|
||||||
|
|
||||||
sciprintf(" \"%s\" at "PREG"\n", s->game_name, PRINT_REG(game_obj));
|
sciprintf(" \"%s\" at "PREG"\n", s->_gameName.c_str(), PRINT_REG(game_obj));
|
||||||
|
|
||||||
if (strlen((char *)s->game_name) >= MAX_GAMEDIR_SIZE) {
|
|
||||||
s->game_name[MAX_GAMEDIR_SIZE - 1] = 0; // Fix length with brute force
|
|
||||||
sciprintf(" Designation too long; was truncated to \"%s\"\n", s->game_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
s->game_obj = game_obj;
|
s->game_obj = game_obj;
|
||||||
|
|
||||||
|
@ -684,8 +680,6 @@ int game_exit(EngineState *s) {
|
||||||
|
|
||||||
_free_graphics_input(s);
|
_free_graphics_input(s);
|
||||||
|
|
||||||
free(s->game_name);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1297,7 +1297,10 @@ static void _k_disable_delete_for_now(EngineState *s, reg_t obj) {
|
||||||
int type = GET_SEL32V(obj, type);
|
int type = GET_SEL32V(obj, type);
|
||||||
int state = GET_SEL32V(obj, state);
|
int state = GET_SEL32V(obj, state);
|
||||||
|
|
||||||
if (type == K_CONTROL_BUTTON && text && !strcmp(s->game_name, "sq4") &&
|
// FIXME: This seems to be some kind of of game specific workaround.
|
||||||
|
// Therefore, a proper WORKAROUND comment should be added here which
|
||||||
|
// explains what this does.
|
||||||
|
if (type == K_CONTROL_BUTTON && text && (s->_gameName == "sq4") &&
|
||||||
s->version < SCI_VERSION(1, 001, 000) && !strcmp(text, " Delete ")) {
|
s->version < SCI_VERSION(1, 001, 000) && !strcmp(text, " Delete ")) {
|
||||||
PUT_SEL32V(obj, state, (state | CONTROL_STATE_GRAY) & ~CONTROL_STATE_ENABLED);
|
PUT_SEL32V(obj, state, (state | CONTROL_STATE_GRAY) & ~CONTROL_STATE_ENABLED);
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,15 +76,12 @@ reg_t kDrawStatus(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||||
s->status_bar_foreground = fgcolor;
|
s->status_bar_foreground = fgcolor;
|
||||||
s->status_bar_background = bgcolor;
|
s->status_bar_background = bgcolor;
|
||||||
|
|
||||||
if (NULL != s->status_bar_text) {
|
if (text.segment) {
|
||||||
free(s->status_bar_text);
|
const char *tmp = sci_strdup(kernel_dereference_char_pointer(s, text, 0));
|
||||||
s->status_bar_text = NULL;
|
s->_statusBarText = tmp ? tmp : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (text.segment)
|
sciw_set_status_bar(s, s->titlebar_port, s->_statusBarText, fgcolor, bgcolor);
|
||||||
s->status_bar_text = sci_strdup(kernel_dereference_char_pointer(s, text, 0));
|
|
||||||
|
|
||||||
sciw_set_status_bar(s, s->titlebar_port, s->status_bar_text, fgcolor, bgcolor);
|
|
||||||
|
|
||||||
gfxop_update(s->gfx_state);
|
gfxop_update(s->gfx_state);
|
||||||
|
|
||||||
|
@ -97,7 +94,7 @@ reg_t kDrawMenuBar(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||||
if (SKPV(0))
|
if (SKPV(0))
|
||||||
sciw_set_menubar(s, s->titlebar_port, s->_menubar, -1);
|
sciw_set_menubar(s, s->titlebar_port, s->_menubar, -1);
|
||||||
else
|
else
|
||||||
sciw_set_status_bar(s, s->titlebar_port, NULL, 0, 0);
|
sciw_set_status_bar(s, s->titlebar_port, "", 0, 0);
|
||||||
|
|
||||||
s->titlebar_port->draw(GFXW(s->titlebar_port), Common::Point(0, 0));
|
s->titlebar_port->draw(GFXW(s->titlebar_port), Common::Point(0, 0));
|
||||||
gfxop_update(s->gfx_state);
|
gfxop_update(s->gfx_state);
|
||||||
|
@ -317,7 +314,7 @@ reg_t kMenuSelect(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||||
port->widfree(GFXW(port));
|
port->widfree(GFXW(port));
|
||||||
port = NULL;
|
port = NULL;
|
||||||
|
|
||||||
sciw_set_status_bar(s, s->titlebar_port, s->status_bar_text, s->status_bar_foreground, s->status_bar_background);
|
sciw_set_status_bar(s, s->titlebar_port, s->_statusBarText, s->status_bar_foreground, s->status_bar_background);
|
||||||
gfxop_update(s->gfx_state);
|
gfxop_update(s->gfx_state);
|
||||||
}
|
}
|
||||||
FULL_REDRAW;
|
FULL_REDRAW;
|
||||||
|
|
|
@ -925,7 +925,7 @@ EngineState *gamestate_restore(EngineState *s, Common::SeekableReadStream *fh) {
|
||||||
|
|
||||||
retval->successor = NULL;
|
retval->successor = NULL;
|
||||||
retval->pic_priority_table = (int*)gfxop_get_pic_metainfo(retval->gfx_state);
|
retval->pic_priority_table = (int*)gfxop_get_pic_metainfo(retval->gfx_state);
|
||||||
retval->game_name = sci_strdup(obj_get_name(retval, retval->game_obj));
|
retval->_gameName = obj_get_name(retval, retval->game_obj);
|
||||||
|
|
||||||
retval->sound.it = NULL;
|
retval->sound.it = NULL;
|
||||||
retval->sound.flags = s->sound.flags;
|
retval->sound.flags = s->sound.flags;
|
||||||
|
|
|
@ -2781,7 +2781,7 @@ int c_statusbar(EngineState *s) {
|
||||||
s->status_bar_foreground = cmd_params[0].val;
|
s->status_bar_foreground = cmd_params[0].val;
|
||||||
s->status_bar_background = cmd_params[1].val;
|
s->status_bar_background = cmd_params[1].val;
|
||||||
|
|
||||||
sciw_set_status_bar(s, s->titlebar_port, s->status_bar_text, s->status_bar_foreground, s->status_bar_background);
|
sciw_set_status_bar(s, s->titlebar_port, s->_statusBarText, s->status_bar_foreground, s->status_bar_background);
|
||||||
gfxop_update(s->gfx_state);
|
gfxop_update(s->gfx_state);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -34,7 +34,6 @@ EngineState::EngineState() : _dirseeker(this) {
|
||||||
|
|
||||||
resmgr = 0;
|
resmgr = 0;
|
||||||
|
|
||||||
game_name = 0;
|
|
||||||
game_version = 0;
|
game_version = 0;
|
||||||
|
|
||||||
gfx_state = 0;
|
gfx_state = 0;
|
||||||
|
@ -55,8 +54,6 @@ EngineState::EngineState() : _dirseeker(this) {
|
||||||
|
|
||||||
pic_priority_table = 0;
|
pic_priority_table = 0;
|
||||||
|
|
||||||
status_bar_text = 0;
|
|
||||||
|
|
||||||
status_bar_foreground = 0;
|
status_bar_foreground = 0;
|
||||||
status_bar_background = 0;
|
status_bar_background = 0;
|
||||||
|
|
||||||
|
|
|
@ -76,7 +76,6 @@ public:
|
||||||
#define CURRENT_SAVEGAME_VERSION 8
|
#define CURRENT_SAVEGAME_VERSION 8
|
||||||
#define MINIMUM_SAVEGAME_VERSION 8
|
#define MINIMUM_SAVEGAME_VERSION 8
|
||||||
|
|
||||||
#define MAX_GAMEDIR_SIZE 32 /* Used for subdirectory inside of "~/.freesci/" */
|
|
||||||
#define MAX_SAVEGAME_NR 20 /* Maximum number of savegames */
|
#define MAX_SAVEGAME_NR 20 /* Maximum number of savegames */
|
||||||
|
|
||||||
#define MAX_SAVE_DIR_SIZE MAXPATHLEN
|
#define MAX_SAVE_DIR_SIZE MAXPATHLEN
|
||||||
|
@ -119,7 +118,7 @@ public:
|
||||||
|
|
||||||
ResourceManager *resmgr; /* The resource manager */
|
ResourceManager *resmgr; /* The resource manager */
|
||||||
|
|
||||||
char *game_name; /* Designation of the primary object (which inherits from Game) */
|
Common::String _gameName; /* Designation of the primary object (which inherits from Game) */
|
||||||
char *game_version;
|
char *game_version;
|
||||||
|
|
||||||
/* Non-VM information */
|
/* Non-VM information */
|
||||||
|
@ -142,7 +141,8 @@ public:
|
||||||
|
|
||||||
int *pic_priority_table; /* 16 entries with priorities or NULL if not present */
|
int *pic_priority_table; /* 16 entries with priorities or NULL if not present */
|
||||||
|
|
||||||
char *status_bar_text; /* Text on the status bar, or NULL if the title bar is blank */
|
/** Text on the status bar, or NULL if the title bar is blank */
|
||||||
|
Common::String _statusBarText;
|
||||||
|
|
||||||
int status_bar_foreground, status_bar_background;
|
int status_bar_foreground, status_bar_background;
|
||||||
|
|
||||||
|
|
|
@ -2078,7 +2078,7 @@ int objinfo(EngineState *s, reg_t pos);
|
||||||
int game_run(EngineState **_s) {
|
int game_run(EngineState **_s) {
|
||||||
EngineState *s = *_s;
|
EngineState *s = *_s;
|
||||||
|
|
||||||
sciprintf(" Calling %s::play()\n", s->game_name);
|
sciprintf(" Calling %s::play()\n", s->_gameName.c_str());
|
||||||
_init_stack_base_with_selector(s, s->selector_map.play); // Call the play selector
|
_init_stack_base_with_selector(s, s->selector_map.play); // Call the play selector
|
||||||
|
|
||||||
// Now: Register the first element on the execution stack-
|
// Now: Register the first element on the execution stack-
|
||||||
|
@ -2095,35 +2095,6 @@ int game_run(EngineState **_s) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
int game_restore(EngineState **_s, char *game_name) {
|
|
||||||
EngineState *s;
|
|
||||||
int debug_state = _debugstate_valid;
|
|
||||||
|
|
||||||
sciprintf("Restoring savegame '%s'...\n", game_name);
|
|
||||||
s = gamestate_restore(*_s, game_name);
|
|
||||||
|
|
||||||
if (!s) {
|
|
||||||
sciprintf("Restoring gamestate '%s' failed.\n", game_name);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
_debugstate_valid = debug_state;
|
|
||||||
script_abort_flag = 0;
|
|
||||||
s->restarting_flags = 0;
|
|
||||||
|
|
||||||
s->execution_stack_pos = -1; // Resatart with replay
|
|
||||||
|
|
||||||
_init_stack_base_with_selector(s, s->selector_map.replay);
|
|
||||||
|
|
||||||
send_selector(s, s->game_obj, s->game_obj, s->stack_base, 2, s->stack_base);
|
|
||||||
|
|
||||||
*_s = s = _game_run(s, 1);
|
|
||||||
|
|
||||||
sciprintf(" Game::play() finished.\n");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
Object *obj_get(EngineState *s, reg_t offset) {
|
Object *obj_get(EngineState *s, reg_t offset) {
|
||||||
MemObject *memobj = GET_OBJECT_SEGMENT(*s->seg_manager, offset.segment);
|
MemObject *memobj = GET_OBJECT_SEGMENT(*s->seg_manager, offset.segment);
|
||||||
Object *obj = NULL;
|
Object *obj = NULL;
|
||||||
|
|
|
@ -72,7 +72,7 @@ static gfxw_list_t *finish_titlebar_list(EngineState *s, gfxw_list_t *list, gfxw
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
void sciw_set_status_bar(EngineState *s, gfxw_port_t *status_bar, const char *text, int fgcolor, int bgcolor) {
|
void sciw_set_status_bar(EngineState *s, gfxw_port_t *status_bar, const Common::String &text, int fgcolor, int bgcolor) {
|
||||||
gfx_state_t *state;
|
gfx_state_t *state;
|
||||||
gfxw_list_t *list;
|
gfxw_list_t *list;
|
||||||
gfx_color_t bg = status_bar->bgcolor;
|
gfx_color_t bg = status_bar->bgcolor;
|
||||||
|
@ -93,9 +93,9 @@ void sciw_set_status_bar(EngineState *s, gfxw_port_t *status_bar, const char *te
|
||||||
|
|
||||||
clear_titlebar(status_bar);
|
clear_titlebar(status_bar);
|
||||||
|
|
||||||
if (text) {
|
if (!text.empty()) {
|
||||||
gfxw_text_t *textw = gfxw_new_text(state, gfx_rect(0, 0, status_bar->bounds.width, status_bar->bounds.height),
|
gfxw_text_t *textw = gfxw_new_text(state, gfx_rect(0, 0, status_bar->bounds.width, status_bar->bounds.height),
|
||||||
status_bar->font_nr, text, ALIGN_LEFT, ALIGN_CENTER,
|
status_bar->font_nr, text.c_str(), ALIGN_LEFT, ALIGN_CENTER,
|
||||||
fg, fg, bg, GFXR_FONT_FLAG_NO_NEWLINES);
|
fg, fg, bg, GFXR_FONT_FLAG_NO_NEWLINES);
|
||||||
|
|
||||||
list = make_titlebar_list(s, status_bar->bounds, status_bar);
|
list = make_titlebar_list(s, status_bar->bounds, status_bar);
|
||||||
|
|
|
@ -62,7 +62,7 @@ class Menu;
|
||||||
/* Used by the interpreter to flag buttons that are enabled */
|
/* Used by the interpreter to flag buttons that are enabled */
|
||||||
#define CONTROL_STATE_ENABLED 0x0001
|
#define CONTROL_STATE_ENABLED 0x0001
|
||||||
|
|
||||||
void sciw_set_status_bar(EngineState *s, gfxw_port_t *status_bar, const char *text, int fgcolor, int bgcolor);
|
void sciw_set_status_bar(EngineState *s, gfxw_port_t *status_bar, const Common::String &text, int fgcolor, int bgcolor);
|
||||||
/* Sets the contents of a port used as status bar
|
/* Sets the contents of a port used as status bar
|
||||||
** Parmeters: (EngineState *) s: The affected game state
|
** Parmeters: (EngineState *) s: The affected game state
|
||||||
** (gfxw_port_t *) status_bar: The status bar port
|
** (gfxw_port_t *) status_bar: The status bar port
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue