AGS: Removed String's "const char*" conversion operator

From upstream 7c426674e7e53bffe9120f8ffc059b77fa03a606
This commit is contained in:
Paul Gilbert 2021-06-06 21:06:45 -07:00
parent cd8a0cff0d
commit eb1e337edd
46 changed files with 108 additions and 107 deletions

View file

@ -146,7 +146,7 @@ Common::Error AGSEngine::run() {
return Common::kUnknownError;
if (_G(justDisplayVersion)) {
_G(platform)->WriteStdOut(AGS3::get_engine_string());
_G(platform)->WriteStdOut(AGS3::get_engine_string().GetCStr());
return Common::kNoError;
}

View file

@ -83,11 +83,11 @@ void Button_Animate(GUIButton *butt, int view, int loop, int speed, int repeat)
}
const char *Button_GetText_New(GUIButton *butt) {
return CreateNewScriptString(butt->GetText());
return CreateNewScriptString(butt->GetText().GetCStr());
}
void Button_GetText(GUIButton *butt, char *buffer) {
strcpy(buffer, butt->GetText());
strcpy(buffer, butt->GetText().GetCStr());
}
void Button_SetText(GUIButton *butt, const char *newtx) {

View file

@ -196,9 +196,9 @@ int run_dialog_script(DialogTopic *dtpp, int dialogID, int offse, int optionInde
param1 = _GP(game).playercharacter;
if (param1 == DCHAR_NARRATOR)
Display(get_translation(_G(old_speech_lines)[param2]));
Display(get_translation(_G(old_speech_lines)[param2].GetCStr()));
else
DisplaySpeech(get_translation(_G(old_speech_lines)[param2]), param1);
DisplaySpeech(get_translation(_G(old_speech_lines)[param2].GetCStr()), param1);
_G(said_speech_line) = 1;
break;
@ -346,7 +346,7 @@ int write_dialog_options(Bitmap *ds, bool ds_has_alpha, int dlgxp, int curyp, in
wouttext_outline(ds, dlgxp + actualpicwid, curyp, usingfont, text_color, tempbfr);
}
for (size_t cc = 0; cc < Lines.Count(); cc++) {
wouttext_outline(ds, dlgxp + ((cc == 0) ? 0 : 9) + bullet_wid, curyp, usingfont, text_color, Lines[cc]);
wouttext_outline(ds, dlgxp + ((cc == 0) ? 0 : 9) + bullet_wid, curyp, usingfont, text_color, Lines[cc].GetCStr());
curyp += linespacing;
}
if (ww < numdisp - 1)
@ -983,8 +983,8 @@ void DialogOptions::Close() {
invalidate_screen();
if (parserActivated) {
strcpy(_GP(play).lastParserEntry, parserInput->Text);
ParseText(parserInput->Text);
strcpy(_GP(play).lastParserEntry, parserInput->Text.GetCStr());
ParseText(parserInput->Text.GetCStr());
chose = CHOSE_TEXTPARSER;
}

View file

@ -210,11 +210,11 @@ int _display_main(int xx, int yy, int wii, const char *text, int disp_type, int
else
text_color = text_window_ds->GetCompatibleColor(-asspch);
wouttext_aligned(text_window_ds, ttxleft, ttyp, oriwid, usingfont, text_color, Lines[ee], _GP(play).text_align);
wouttext_aligned(text_window_ds, ttxleft, ttyp, oriwid, usingfont, text_color, Lines[ee].GetCStr(), _GP(play).text_align);
} else {
text_color = text_window_ds->GetCompatibleColor(asspch);
//wouttext_outline(ttxp,ttyp,usingfont,lines[ee]);
wouttext_aligned(text_window_ds, ttxleft, ttyp, wii, usingfont, text_color, Lines[ee], _GP(play).speech_text_align);
wouttext_aligned(text_window_ds, ttxleft, ttyp, wii, usingfont, text_color, Lines[ee].GetCStr(), _GP(play).speech_text_align);
}
}
} else {
@ -228,7 +228,7 @@ int _display_main(int xx, int yy, int wii, const char *text, int disp_type, int
adjust_y_coordinate_for_text(&yoffs, usingfont);
for (size_t ee = 0; ee < Lines.Count(); ee++)
wouttext_aligned(text_window_ds, xoffs, yoffs + ee * disp.linespacing, oriwid, usingfont, text_color, Lines[ee], _GP(play).text_align);
wouttext_aligned(text_window_ds, xoffs, yoffs + ee * disp.linespacing, oriwid, usingfont, text_color, Lines[ee].GetCStr(), _GP(play).text_align);
}
int ovrtype = OVER_TEXTMSG;

View file

@ -2189,7 +2189,7 @@ void construct_engine_overlay() {
_G(debugConsoleBuffer)->FillRect(Rect(0, 0, viewport.GetWidth() - 1, barheight), draw_color);
color_t text_color = _G(debugConsoleBuffer)->GetCompatibleColor(16);
for (int jj = _G(first_debug_line); jj != _G(last_debug_line); jj = (jj + 1) % DEBUG_CONSOLE_NUMLINES) {
wouttextxy(_G(debugConsoleBuffer), 1, ypp, font, text_color, _G(debug_line)[jj]);
wouttextxy(_G(debugConsoleBuffer), 1, ypp, font, text_color, _G(debug_line)[jj].GetCStr());
ypp += txtspacing;
}

View file

@ -305,12 +305,12 @@ void DrawingSurface_DrawStringWrapped(ScriptDrawingSurface *sds, int xx, int yy,
int drawAtX = xx;
if (alignment & kMAlignHCenter) {
drawAtX = xx + ((wid / 2) - wgettextwidth(Lines[i], font) / 2);
drawAtX = xx + ((wid / 2) - wgettextwidth(Lines[i].GetCStr(), font) / 2);
} else if (alignment & kMAlignRight) {
drawAtX = (xx + wid) - wgettextwidth(Lines[i], font);
drawAtX = (xx + wid) - wgettextwidth(Lines[i].GetCStr(), font);
}
wouttext_outline(ds, drawAtX, yy + linespacing * i, font, text_color, Lines[i]);
wouttext_outline(ds, drawAtX, yy + linespacing * i, font, text_color, Lines[i].GetCStr());
}
sds->FinishedDrawing();

View file

@ -73,10 +73,10 @@ int File_Delete(const char *fnmm) {
if (!ResolveScriptPath(fnmm, false, rp))
return 0;
if (::remove(rp.FullPath) == 0)
if (::remove(rp.FullPath.GetCStr()) == 0)
return 1;
if (_G(errnum) == AL_ENOENT && !rp.AltPath.IsEmpty() && rp.AltPath.Compare(rp.FullPath) != 0)
return ::remove(rp.AltPath) == 0 ? 1 : 0;
return ::remove(rp.AltPath.GetCStr()) == 0 ? 1 : 0;
return 0;
}
@ -307,7 +307,7 @@ bool ResolveScriptPath(const String &orig_sc_path, bool read_only, ResolvedPath
debugC(::AGS::kDebugFilePath, "ResolveScriptPath(%s)", orig_sc_path.GetCStr());
rp = ResolvedPath();
bool is_absolute = !is_relative_filename(orig_sc_path);
bool is_absolute = !is_relative_filename(orig_sc_path.GetCStr());
if (is_absolute && !read_only) {
debug_script_warn("Attempt to access file '%s' denied (cannot write to absolute path)", orig_sc_path.GetCStr());
return false;
@ -348,7 +348,7 @@ bool ResolveScriptPath(const String &orig_sc_path, bool read_only, ResolvedPath
child_path = sc_path.Mid(GameInstallRootToken.GetLength());
} else if (sc_path.CompareLeft(GameSavedgamesDirToken) == 0) {
parent_dir = get_save_game_directory();
child_path = sc_path.Mid(strlen(GameSavedgamesDirToken));
child_path = sc_path.Mid(strlen(GameSavedgamesDirToken.GetCStr()));
#if AGS_PLATFORM_SCUMMVM
// Remap "agsgame.*"
const char *agsSavePrefix = "/agssave.";
@ -522,12 +522,12 @@ bool DoesAssetExistInLib(const AssetPath &path) {
}
String find_assetlib(const String &filename) {
String libname = cbuf_to_string_and_free(ci_find_file(_GP(ResPaths).DataDir, filename));
String libname = cbuf_to_string_and_free(ci_find_file(_GP(ResPaths).DataDir.GetCStr(), filename.GetCStr()));
if (AssetManager::IsDataFile(libname))
return libname;
if (Path::ComparePaths(_GP(ResPaths).DataDir, _GP(ResPaths).DataDir2) != 0) {
// Hack for running in Debugger
libname = cbuf_to_string_and_free(ci_find_file(_GP(ResPaths).DataDir2, filename));
libname = cbuf_to_string_and_free(ci_find_file(_GP(ResPaths).DataDir2.GetCStr(), filename.GetCStr()));
if (AssetManager::IsDataFile(libname))
return libname;
}

View file

@ -343,7 +343,7 @@ int Game_SetSaveGameDirectory(const String &newFolder) {
const char *Game_GetSaveSlotDescription(int slnum) {
String description;
if (read_savedgame_description(get_save_game_path(slnum), description)) {
return CreateNewScriptString(description);
return CreateNewScriptString(description.GetCStr());
}
return nullptr;
}
@ -635,7 +635,7 @@ void Game_SetIgnoreUserInputAfterTextTimeoutMs(int newValueMs) {
}
const char *Game_GetFileName() {
return CreateNewScriptString(_GP(ResPaths).GamePak.Name);
return CreateNewScriptString(_GP(ResPaths).GamePak.Name.GetCStr());
}
const char *Game_GetName() {
@ -1069,7 +1069,7 @@ bool try_restore_save(const Shared::String &path, int slot) {
if (data_overwritten)
quitprintf("%s", error.GetCStr());
else
Display(error);
Display(error.GetCStr());
return false;
}
return true;
@ -1360,7 +1360,7 @@ void get_message_text(int msnum, char *buffer, char giveErr) {
}
buffer[0] = 0;
replace_tokens(get_translation(_GP(thisroom).Messages[msnum]), buffer, maxlen);
replace_tokens(get_translation(_GP(thisroom).Messages[msnum].GetCStr()), buffer, maxlen);
}
bool unserialize_audio_script_object(int index, const char *objectType, const char *serializedData, int dataSize) {

View file

@ -162,7 +162,7 @@ void RawPrintMessageWrapped(int xx, int yy, int wid, int font, int msgm) {
RAW_START();
color_t text_color = _GP(play).raw_color;
for (size_t i = 0; i < Lines.Count(); i++)
wouttext_outline(RAW_SURFACE(), xx, yy + linespacing * i, font, text_color, Lines[i]);
wouttext_outline(RAW_SURFACE(), xx, yy + linespacing * i, font, text_color, Lines[i].GetCStr());
invalidate_screen();
mark_current_background_dirty();
RAW_END();

View file

@ -587,7 +587,7 @@ void GetLocationName(int xxx, int yyy, char *tempo) {
// on object
if (loctype == LOCTYPE_OBJ) {
aa = _G(getloctype_index);
strcpy(tempo, get_translation(_GP(thisroom).Objects[aa].Name));
strcpy(tempo, get_translation(_GP(thisroom).Objects[aa].Name.GetCStr()));
// Compatibility: < 3.1.1 games returned space for nameless object
// (presumably was a bug, but fixing it affected certain games behavior)
if (_G(loaded_game_file_version) < kGameVersion_311 && tempo[0] == 0) {
@ -600,7 +600,7 @@ void GetLocationName(int xxx, int yyy, char *tempo) {
return;
}
onhs = _G(getloctype_index);
if (onhs > 0) strcpy(tempo, get_translation(_GP(thisroom).Hotspots[onhs].Name));
if (onhs > 0) strcpy(tempo, get_translation(_GP(thisroom).Hotspots[onhs].Name.GetCStr()));
if (_GP(play).get_loc_name_last_time != onhs)
GUI::MarkSpecialLabelsForUpdate(kLabelMacro_Overhotspot);
_GP(play).get_loc_name_last_time = onhs;

View file

@ -97,7 +97,7 @@ void GetHotspotName(int hotspot, char *buffer) {
if ((hotspot < 0) || (hotspot >= MAX_ROOM_HOTSPOTS))
quit("!GetHotspotName: invalid hotspot number");
strcpy(buffer, get_translation(_GP(thisroom).Hotspots[hotspot].Name));
strcpy(buffer, get_translation(_GP(thisroom).Hotspots[hotspot].Name.GetCStr()));
}
void RunHotspotInteraction(int hotspothere, int mood) {

View file

@ -389,7 +389,7 @@ void GetObjectName(int obj, char *buffer) {
if (!is_valid_object(obj))
quit("!GetObjectName: invalid object number");
strcpy(buffer, get_translation(_GP(thisroom).Objects[obj].Name));
strcpy(buffer, get_translation(_GP(thisroom).Objects[obj].Name.GetCStr()));
}
void MoveObject(int objj, int xx, int yy, int spp) {

View file

@ -320,7 +320,7 @@ void remove_popup_interface(int ifacenum) {
void process_interface_click(int ifce, int btn, int mbut) {
if (btn < 0) {
// click on GUI background
QueueScriptFunction(kScInstGame, _GP(guis)[ifce].OnClickHandler, 2,
QueueScriptFunction(kScInstGame, _GP(guis)[ifce].OnClickHandler.GetCStr(), 2,
RuntimeScriptValue().SetDynamicObject(&_G(scrGui)[ifce], &_GP(ccDynamicGUI)),
RuntimeScriptValue().SetInt32(mbut));
return;
@ -345,14 +345,14 @@ void process_interface_click(int ifce, int btn, int mbut) {
// otherwise, run interface_click
if ((theObj->GetEventCount() > 0) &&
(!theObj->EventHandlers[0].IsEmpty()) &&
(!_G(gameinst)->GetSymbolAddress(theObj->EventHandlers[0]).IsNull())) {
(!_G(gameinst)->GetSymbolAddress(theObj->EventHandlers[0].GetCStr()).IsNull())) {
// control-specific event handler
if (strchr(theObj->GetEventArgs(0), ',') != nullptr)
QueueScriptFunction(kScInstGame, theObj->EventHandlers[0], 2,
if (strchr(theObj->GetEventArgs(0).GetCStr(), ',') != nullptr)
QueueScriptFunction(kScInstGame, theObj->EventHandlers[0].GetCStr(), 2,
RuntimeScriptValue().SetDynamicObject(theObj, &_GP(ccDynamicGUIObject)),
RuntimeScriptValue().SetInt32(mbut));
else
QueueScriptFunction(kScInstGame, theObj->EventHandlers[0], 1,
QueueScriptFunction(kScInstGame, theObj->EventHandlers[0].GetCStr(), 1,
RuntimeScriptValue().SetDynamicObject(theObj, &_GP(ccDynamicGUIObject)));
} else
QueueScriptFunction(kScInstGame, "interface_click", 2,

View file

@ -95,7 +95,7 @@ void Hotspot_GetName(ScriptHotspot *hss, char *buffer) {
}
const char *Hotspot_GetName_New(ScriptHotspot *hss) {
return CreateNewScriptString(get_translation(_GP(thisroom).Hotspots[hss->id].Name));
return CreateNewScriptString(get_translation(_GP(thisroom).Hotspots[hss->id].Name.GetCStr()));
}
bool Hotspot_IsInteractionAvailable(ScriptHotspot *hhot, int mood) {

View file

@ -36,11 +36,11 @@ namespace AGS3 {
// ** LABEL FUNCTIONS
const char *Label_GetText_New(GUILabel *labl) {
return CreateNewScriptString(labl->GetText());
return CreateNewScriptString(labl->GetText().GetCStr());
}
void Label_GetText(GUILabel *labl, char *buffer) {
strcpy(buffer, labl->GetText());
strcpy(buffer, labl->GetText().GetCStr());
}
void Label_SetText(GUILabel *labl, const char *newtx) {

View file

@ -151,7 +151,7 @@ int ListBox_GetItemAtLocation(GUIListBox *listbox, int x, int y) {
char *ListBox_GetItemText(GUIListBox *listbox, int index, char *buffer) {
if ((index < 0) || (index >= listbox->ItemCount))
quit("!ListBoxGetItemText: invalid item specified");
strncpy(buffer, listbox->Items[index], 198);
strncpy(buffer, listbox->Items[index].GetCStr(), 198);
buffer[199] = 0;
return buffer;
}
@ -160,14 +160,14 @@ const char *ListBox_GetItems(GUIListBox *listbox, int index) {
if ((index < 0) || (index >= listbox->ItemCount))
quit("!ListBox.Items: invalid index specified");
return CreateNewScriptString(listbox->Items[index]);
return CreateNewScriptString(listbox->Items[index].GetCStr());
}
void ListBox_SetItemText(GUIListBox *listbox, int index, const char *newtext) {
if ((index < 0) || (index >= listbox->ItemCount))
quit("!ListBoxSetItemText: invalid item specified");
if (strcmp(listbox->Items[index], newtext)) {
if (strcmp(listbox->Items[index].GetCStr(), newtext)) {
listbox->SetItemText(index, newtext);
}
}

View file

@ -269,7 +269,7 @@ const char *Object_GetName_New(ScriptObject *objj) {
if (!is_valid_object(objj->id))
quit("!Object.Name: invalid object number");
return CreateNewScriptString(get_translation(_GP(thisroom).Objects[objj->id].Name));
return CreateNewScriptString(get_translation(_GP(thisroom).Objects[objj->id].Name.GetCStr()));
}
bool Object_IsInteractionAvailable(ScriptObject *oobj, int mood) {

View file

@ -87,7 +87,7 @@ int find_word_in_dictionary(const char *lookfor) {
if ((lastletter == 's') || (lastletter == 'S') || (lastletter == '\'')) {
String singular = lookfor;
singular.ClipRight(1);
return find_word_in_dictionary(singular);
return find_word_in_dictionary(singular.GetCStr());
}
}
return -1;

View file

@ -77,7 +77,7 @@ void get_text_property(const StringIMap &st_prop, const StringIMap &rt_prop, con
return;
String val = get_property_value(st_prop, rt_prop, property, desc.DefaultValue);
strcpy(bufer, val);
strcpy(bufer, val.GetCStr());
}
const char *get_text_property_dynamic_string(const StringIMap &st_prop, const StringIMap &rt_prop, const char *property) {
@ -86,7 +86,7 @@ const char *get_text_property_dynamic_string(const StringIMap &st_prop, const St
return nullptr;
String val = get_property_value(st_prop, rt_prop, property, desc.DefaultValue);
return CreateNewScriptString(val);
return CreateNewScriptString(val.GetCStr());
}
bool set_int_property(StringIMap &rt_prop, const char *property, int value) {

View file

@ -162,7 +162,7 @@ const char *Room_GetMessages(int index) {
}
char buffer[STD_BUFFER_SIZE];
buffer[0] = 0;
replace_tokens(get_translation(_GP(thisroom).Messages[index]), buffer, STD_BUFFER_SIZE);
replace_tokens(get_translation(_GP(thisroom).Messages[index].GetCStr()), buffer, STD_BUFFER_SIZE);
return CreateNewScriptString(buffer);
}

View file

@ -253,13 +253,13 @@ size_t break_up_text_into_lines(const char *todis, SplitLines &lines, int wii, i
if (_GP(game).options[OPT_RIGHTLEFTWRITE])
for (size_t rr = 0; rr < lines.Count(); rr++) {
lines[rr].Reverse();
line_length = wgettextwidth_compensate(lines[rr], fonnt);
line_length = wgettextwidth_compensate(lines[rr].GetCStr(), fonnt);
if (line_length > _G(longestline))
_G(longestline) = line_length;
}
else
for (size_t rr = 0; rr < lines.Count(); rr++) {
line_length = wgettextwidth_compensate(lines[rr], fonnt);
line_length = wgettextwidth_compensate(lines[rr].GetCStr(), fonnt);
if (line_length > _G(longestline))
_G(longestline) = line_length;
}

View file

@ -98,7 +98,7 @@ int System_GetViewportWidth() {
}
const char *System_GetVersion() {
return CreateNewScriptString(_G(EngineVersion).LongString);
return CreateNewScriptString(_G(EngineVersion).LongString.GetCStr());
}
int System_GetHardwareAcceleration() {

View file

@ -35,11 +35,11 @@ namespace AGS3 {
// ** TEXT BOX FUNCTIONS
const char *TextBox_GetText_New(GUITextBox *texbox) {
return CreateNewScriptString(texbox->Text);
return CreateNewScriptString(texbox->Text.GetCStr());
}
void TextBox_GetText(GUITextBox *texbox, char *buffer) {
strcpy(buffer, texbox->Text);
strcpy(buffer, texbox->Text.GetCStr());
}
void TextBox_SetText(GUITextBox *texbox, const char *newtex) {

View file

@ -498,7 +498,7 @@ void scriptDebugHook(ccInstance *ccinst, int linenum) {
if (pluginsWantingDebugHooks > 0) {
// a plugin is handling the debugging
String scname = GetScriptName(ccinst);
pl_run_plugin_debug_hooks(scname, linenum);
pl_run_plugin_debug_hooks(scname.GetCStr(), linenum);
return;
}

View file

@ -48,10 +48,10 @@ void LogFile::PrintMessage(const DebugMessage &msg) {
}
if (!msg.GroupName.IsEmpty()) {
_file->Write(msg.GroupName, msg.GroupName.GetLength());
_file->Write(msg.GroupName.GetCStr(), msg.GroupName.GetLength());
_file->Write(" : ", 3);
}
_file->Write(msg.Text, msg.Text.GetLength());
_file->Write(msg.Text.GetCStr(), msg.Text.GetLength());
_file->WriteInt8('\n');
// We should flush after every write to the log; this will make writing
// bit slower, but will increase the chances that all latest output

View file

@ -117,7 +117,7 @@ int loadgamedialog() {
else {
toret = _G(filenumbers)[cursel];
String path = get_save_game_path(toret);
strcpy(_G(bufTemp), path);
strcpy(_G(bufTemp), path.GetCStr());
_G(lpTemp) = &_G(bufTemp)[0];
}
} else if (mes.id == ctrlcancel) {
@ -237,7 +237,7 @@ int savegamedialog() {
toret = highestnum + 1;
String path = get_save_game_path(toret);
strcpy(_G(bufTemp), path);
strcpy(_G(bufTemp), path.GetCStr());
} else {
toret = _G(filenumbers)[cursell];
_G(bufTemp)[0] = 0;
@ -245,7 +245,7 @@ int savegamedialog() {
if (_G(bufTemp)[0] == 0) {
String path = get_save_game_path(toret);
strcpy(_G(bufTemp), path);
strcpy(_G(bufTemp), path.GetCStr());
}
_G(lpTemp) = &_G(bufTemp)[0];

View file

@ -119,19 +119,19 @@ void GUIObject::NotifyParentChanged() {
}
void GUILabel::PrepareTextToDraw() {
replace_macro_tokens(Flags & kGUICtrl_Translated ? String(get_translation(Text)) : Text, _textToDraw);
replace_macro_tokens((Flags & kGUICtrl_Translated) ? get_translation(Text.GetCStr()) : Text.GetCStr(), _textToDraw);
}
size_t GUILabel::SplitLinesForDrawing(SplitLines &lines) {
// Use the engine's word wrap tool, to have hebrew-style writing and other features
return break_up_text_into_lines(_textToDraw, lines, Width, Font);
return break_up_text_into_lines(_textToDraw.GetCStr(), lines, Width, Font);
}
void GUITextBox::DrawTextBoxContents(Bitmap *ds, color_t text_color) {
wouttext_outline(ds, X + 1 + get_fixed_pixel_size(1), Y + 1 + get_fixed_pixel_size(1), Font, text_color, Text);
wouttext_outline(ds, X + 1 + get_fixed_pixel_size(1), Y + 1 + get_fixed_pixel_size(1), Font, text_color, Text.GetCStr());
if (IsGUIEnabled(this)) {
// draw a cursor
int draw_at_x = wgettextwidth(Text, Font) + X + 3;
int draw_at_x = wgettextwidth(Text.GetCStr(), Font) + X + 3;
int draw_at_y = Y + 1 + getfontheight(Font);
ds->DrawRect(Rect(draw_at_x, draw_at_y, draw_at_x + get_fixed_pixel_size(5), draw_at_y + (get_fixed_pixel_size(1) - 1)), text_color);
}
@ -147,14 +147,14 @@ void GUIListBox::DrawItemsUnfix() {
void GUIListBox::PrepareTextToDraw(const String &text) {
if (Flags & kGUICtrl_Translated)
_textToDraw = get_translation(text);
_textToDraw = get_translation(text.GetCStr());
else
_textToDraw = text;
}
void GUIButton::PrepareTextToDraw() {
if (Flags & kGUICtrl_Translated)
_textToDraw = get_translation(_text);
_textToDraw = get_translation(_text.GetCStr());
else
_textToDraw = _text;
}

View file

@ -50,7 +50,7 @@ void MyLabel::draw(Bitmap *ds) {
if (break_up_text_into_lines(teptr, Lines, wid, _G(acdialog_font)) == 0)
return;
for (size_t ee = 0; ee < Lines.Count(); ee++) {
wouttext_outline(ds, x, cyp, _G(acdialog_font), text_color, Lines[ee]);
wouttext_outline(ds, x, cyp, _G(acdialog_font), text_color, Lines[ee].GetCStr());
cyp += TEXT_HT;
}
}

View file

@ -69,7 +69,7 @@ int INIreadint(const ConfigTree &cfg, const String &sectn, const String &item, i
if (!INIreaditem(cfg, sectn, item, str))
return def_value;
return atoi(str);
return atoi(str.GetCStr());
}
float INIreadfloat(const ConfigTree &cfg, const String &sectn, const String &item, float def_value) {
@ -77,7 +77,7 @@ float INIreadfloat(const ConfigTree &cfg, const String &sectn, const String &ite
if (!INIreaditem(cfg, sectn, item, str))
return def_value;
return atof(str);
return atof(str.GetCStr());
}
String INIreadstring(const ConfigTree &cfg, const String &sectn, const String &item, const String &def_value) {

View file

@ -854,7 +854,7 @@ void engine_init_game_settings() {
void engine_setup_scsystem_auxiliary() {
// ScriptSystem::aci_version is only 10 chars long
strncpy(_GP(scsystem).aci_version, _G(EngineVersion).LongString, 10);
strncpy(_GP(scsystem).aci_version, _G(EngineVersion).LongString.GetCStr(), 10);
if (_GP(usetup).override_script_os >= 0) {
_GP(scsystem).os = _GP(usetup).override_script_os;
} else {

View file

@ -59,7 +59,7 @@ using namespace AGS::Engine;
void quit_tell_editor_debugger(const String &qmsg, QuitReason qreason) {
if (_G(editor_debugging_initialized)) {
if (qreason & kQuitKind_GameException)
_G(handledErrorInEditor) = send_exception_to_editor(qmsg);
_G(handledErrorInEditor) = send_exception_to_editor(qmsg.GetCStr());
send_message_to_editor("EXIT");
_G(editor_debugger)->Shutdown();
}

View file

@ -183,10 +183,10 @@ int run_interaction_script(InteractionScripts *nint, int evnt, int chkAny, int i
if ((strstr(_G(evblockbasename), "character") != nullptr) || (strstr(_G(evblockbasename), "inventory") != nullptr)) {
// Character or Inventory (global script)
QueueScriptFunction(kScInstGame, nint->ScriptFuncNames[evnt]);
QueueScriptFunction(kScInstGame, nint->ScriptFuncNames[evnt].GetCStr());
} else {
// Other (room script)
QueueScriptFunction(kScInstRoom, nint->ScriptFuncNames[evnt]);
QueueScriptFunction(kScInstRoom, nint->ScriptFuncNames[evnt].GetCStr());
}
int retval = 0;
@ -548,7 +548,7 @@ void post_script_cleanup() {
for (jj = 0; jj < copyof.numanother; jj++) {
old_room_number = _G(displayed_room);
QueuedScript &script = copyof.ScFnQueue[jj];
RunScriptFunction(script.Instance, script.FnName, script.ParamCount, script.Param1, script.Param2);
RunScriptFunction(script.Instance, script.FnName.GetCStr(), script.ParamCount, script.Param1, script.Param2);
if (script.Instance == kScInstRoom && script.ParamCount == 1) {
// some bogus hack for "on_call" event handler
_GP(play).roomscript_finished = 1;

View file

@ -316,7 +316,7 @@ void IAGSEngine::DrawTextWrapped(int32 xx, int32 yy, int32 wid, int32 font, int3
color_t text_color = ds->GetCompatibleColor(color);
data_to_game_coords((int *)&xx, (int *)&yy); // stupid! quick tweak
for (size_t i = 0; i < Lines.Count(); i++)
draw_and_invalidate_text(ds, xx, yy + linespacing * i, font, text_color, Lines[i]);
draw_and_invalidate_text(ds, xx, yy + linespacing * i, font, text_color, Lines[i].GetCStr());
}
Bitmap glVirtualScreenWrap;

View file

@ -335,7 +335,7 @@ void GameSetupStruct::read_room_names(Stream *in, GameDataVersion data_ver) {
roomNumbers[bb] = in->ReadInt32();
pexbuf.Read(in, STD_BUFFER_SIZE);
roomNames[bb] = new char[pexbuf.GetLength() + 1];
strcpy(roomNames[bb], pexbuf);
strcpy(roomNames[bb], pexbuf.GetCStr());
}
} else {
roomCount = 0;

View file

@ -61,7 +61,7 @@ bool AssetManager::LibsByPriority::operator()(const AssetLibInfo *lib1, const As
/* static */ bool AssetManager::IsDataFile(const String &data_file) {
Stream *in = ci_fopen(data_file, Shared::kFile_Open, Shared::kFile_Read);
Stream *in = ci_fopen(data_file.GetCStr(), Shared::kFile_Open, Shared::kFile_Read);
if (in) {
MFLUtil::MFLError err = MFLUtil::TestIsMFL(in, true);
delete in;
@ -71,7 +71,7 @@ bool AssetManager::LibsByPriority::operator()(const AssetLibInfo *lib1, const As
}
/* static */ AssetError AssetManager::ReadDataFileTOC(const String &data_file, AssetLibInfo &lib) {
Stream *in = ci_fopen(data_file, Shared::kFile_Open, Shared::kFile_Read);
Stream *in = ci_fopen(data_file.GetCStr(), Shared::kFile_Open, Shared::kFile_Read);
if (in) {
MFLUtil::MFLError err = MFLUtil::ReadHeader(lib, in);
delete in;
@ -178,7 +178,7 @@ AssetError AssetManager::RegisterAssetLib(const String &path, AssetLibEx *&out_l
}
// ...else try open a data library
else {
Stream *in = ci_fopen(path, Shared::kFile_Open, Shared::kFile_Read);
Stream *in = ci_fopen(path.GetCStr(), Shared::kFile_Open, Shared::kFile_Read);
if (!in)
return kAssetErrNoLibFile; // can't be opened, return error code
@ -234,7 +234,7 @@ bool AssetManager::GetAssetFromLib(const AssetLibInfo *lib, const String &asset_
if (asset == nullptr)
return false;
String libfile = cbuf_to_string_and_free(ci_find_file(lib->BaseDir, lib->LibFileNames[asset->LibUid]));
String libfile = cbuf_to_string_and_free(ci_find_file(lib->BaseDir.GetCStr(), lib->LibFileNames[asset->LibUid].GetCStr()));
if (libfile.IsEmpty())
return false;
if (loc) {
@ -247,7 +247,7 @@ bool AssetManager::GetAssetFromLib(const AssetLibInfo *lib, const String &asset_
bool AssetManager::GetAssetFromDir(const AssetLibInfo *lib, const String &file_name,
AssetLocation *loc, FileOpenMode open_mode, FileWorkMode work_mode) const {
String found_file = cbuf_to_string_and_free(ci_find_file(lib->BaseDir, file_name));
String found_file = cbuf_to_string_and_free(ci_find_file(lib->BaseDir.GetCStr(), file_name.GetCStr()));
if (found_file.IsEmpty() || !Path::IsFile(found_file))
return false; // not found, or not a file

View file

@ -349,7 +349,7 @@ void InteractionVariable::Read(Stream *in) {
}
void InteractionVariable::Write(Shared::Stream *out) const {
out->Write(Name, INTER_VAR_NAME_LENGTH);
out->Write(Name.GetCStr(), INTER_VAR_NAME_LENGTH);
out->WriteInt8(Type);
out->WriteInt32(Value);
}

View file

@ -893,7 +893,7 @@ void WriteMainBlock(const RoomStruct *room, Stream *out) {
out->WriteInt8(room->MessageInfos[i].Flags);
}
for (size_t i = 0; i < room->MessageCount; ++i)
write_string_encrypt(out, room->Messages[i]);
write_string_encrypt(out, room->Messages[i].GetCStr());
out->WriteInt16(0); // legacy room animations

View file

@ -322,7 +322,7 @@ void GUIButton::DrawText(Bitmap *ds, bool draw_disabled) {
color_t text_color = ds->GetCompatibleColor(TextColor);
if (draw_disabled)
text_color = ds->GetCompatibleColor(8);
GUI::DrawTextAligned(ds, _textToDraw, Font, text_color, frame, TextAlignment);
GUI::DrawTextAligned(ds, _textToDraw.GetCStr(), Font, text_color, frame, TextAlignment);
}
void GUIButton::DrawTextButton(Bitmap *ds, bool draw_disabled) {

View file

@ -66,7 +66,7 @@ void GUILabel::Draw(Shared::Bitmap *ds) {
for (size_t i = 0;
i < Lines.Count() && (!limit_by_label_frame || at_y <= Y + Height);
++i, at_y += linespacing) {
GUI::DrawTextAlignedHor(ds, Lines[i], Font, text_color, X, X + Width - 1, at_y,
GUI::DrawTextAlignedHor(ds, Lines[i].GetCStr(), Font, text_color, X, X + Width - 1, at_y,
(FrameAlignment)TextAlignment);
}
}

View file

@ -159,7 +159,7 @@ void GUIListBox::Draw(Shared::Bitmap *ds) {
int item_index = item + TopItem;
PrepareTextToDraw(Items[item_index]);
GUI::DrawTextAlignedHor(ds, _textToDraw, Font, text_color, X + 1 + pixel_size, right_hand_edge, at_y + 1,
GUI::DrawTextAlignedHor(ds, _textToDraw.GetCStr(), Font, text_color, X + 1 + pixel_size, right_hand_edge, at_y + 1,
(FrameAlignment)TextAlignment);
}

View file

@ -80,7 +80,7 @@ void GUITextBox::OnKeyPress(int keycode) {
Text.AppendChar(keycode);
// if the new string is too long, remove the new character
if (wgettextwidth(Text, Font) > (Width - (6 + get_fixed_pixel_size(5))))
if (wgettextwidth(Text.GetCStr(), Font) > (Width - (6 + get_fixed_pixel_size(5))))
Text.ClipRight(1);
}

View file

@ -48,11 +48,11 @@ void cc_error(const char *descr, ...) {
if (_G(currentline) > 0) {
// [IKM] Implementation is project-specific
std::pair<String, String> errinfo = cc_error_at_line(displbuf);
std::pair<String, String> errinfo = cc_error_at_line(displbuf.GetCStr());
_G(ccErrorString) = errinfo.first;
_G(ccErrorCallStack) = errinfo.second;
} else {
_G(ccErrorString) = cc_error_without_line(displbuf);
_G(ccErrorString) = cc_error_without_line(displbuf.GetCStr());
_G(ccErrorCallStack) = "";
}

View file

@ -194,7 +194,7 @@ void FileStream::Open(const String &file_name, FileOpenMode open_mode, FileWorkM
if (!file_name.CompareLeftNoCase(SAVE_FOLDER_PREFIX)) {
_outSave = g_system->getSavefileManager()->openForSaving(
file_name + strlen(SAVE_FOLDER_PREFIX), false);
file_name.GetCStr() + strlen(SAVE_FOLDER_PREFIX), false);
} else {
Common::String fname = file_name;
if (fname.hasPrefix("./"))

View file

@ -328,7 +328,7 @@ MFLUtil::MFLError MFLUtil::ReadV30(AssetLibInfo &lib, Stream *in, MFLVersion /*
}
void MFLUtil::WriteHeader(const AssetLibInfo &lib, MFLVersion lib_version, int lib_index, Stream *out) {
out->Write(MFLUtil::HeadSig, MFLUtil::HeadSig.GetLength());
out->Write(MFLUtil::HeadSig.GetCStr(), MFLUtil::HeadSig.GetLength());
out->WriteByte(lib_version);
out->WriteByte(lib_index); // file number
@ -361,7 +361,7 @@ void MFLUtil::WriteEnder(soff_t lib_offset, MFLVersion lib_index, Stream *out) {
out->WriteInt32((int32_t)lib_offset);
else
out->WriteInt64(lib_offset);
out->Write(TailSig, TailSig.GetLength());
out->Write(TailSig.GetCStr(), TailSig.GetLength());
}
void MFLUtil::DecryptText(char *text) {

View file

@ -71,11 +71,11 @@ bool IsFileOrDir(const String &filename) {
}
String GetFilename(const String &path) {
return get_filename(path);
return get_filename(path.GetCStr());
}
String GetFileExtension(const String &path) {
return get_extension(path);
return get_extension(path.GetCStr());
}
int ComparePaths(const String &path1, const String &path2) {
@ -120,8 +120,8 @@ bool IsSameOrSubDir(const String &parent, const String &path) {
char can_path[MAX_PATH];
char relative[MAX_PATH];
// canonicalize_filename treats "." as "./." (file in working dir)
const char *use_parent = parent == "." ? "./" : parent;
const char *use_path = path == "." ? "./" : path;
const char *use_parent = parent == "." ? "./" : parent.GetCStr();
const char *use_path = path == "." ? "./" : path.GetCStr();
canonicalize_filename(can_parent, use_parent, MAX_PATH);
canonicalize_filename(can_path, use_path, MAX_PATH);
const char *pstr = make_relative_filename(relative, can_parent, can_path, MAX_PATH);
@ -136,7 +136,7 @@ bool IsSameOrSubDir(const String &parent, const String &path) {
}
bool IsRelativePath(const String &path) {
return is_relative_filename(path);
return is_relative_filename(path.GetCStr()) != 0;
}
void FixupPath(String &path) {
@ -185,7 +185,7 @@ String MakeAbsolutePath(const String &path) {
//}
#endif
char buf[MAX_PATH];
canonicalize_filename(buf, abs_path, MAX_PATH);
canonicalize_filename(buf, abs_path.GetCStr(), MAX_PATH);
abs_path = buf;
FixupPath(abs_path);
return abs_path;
@ -196,8 +196,8 @@ String MakeRelativePath(const String &base, const String &path) {
char can_path[MAX_PATH];
char relative[MAX_PATH];
// canonicalize_filename treats "." as "./." (file in working dir)
const char *use_parent = base == "." ? "./" : base;
const char *use_path = path == "." ? "./" : path; // FIXME?
const char *use_parent = base == "." ? "./" : base.GetCStr();
const char *use_path = path == "." ? "./" : path.GetCStr(); // FIXME?
canonicalize_filename(can_parent, use_parent, MAX_PATH);
canonicalize_filename(can_path, use_path, MAX_PATH);
String rel_path = make_relative_filename(relative, can_parent, can_path, MAX_PATH);
@ -249,7 +249,7 @@ String FixupSharedFilename(const String &filename) {
String GetPathInASCII(const String &path) {
#if AGS_PLATFORM_OS_WINDOWS
char ascii_buffer[MAX_PATH];
if (GetShortPathNameA(path, ascii_buffer, MAX_PATH) == 0)
if (GetShortPathNameA(path.GetCStr(), ascii_buffer, MAX_PATH) == 0)
return "";
return ascii_buffer;
#else

View file

@ -140,29 +140,29 @@ public:
int CompareNoCase(const char *cstr) const;
// Compares the leftmost part of this string with given string
int CompareLeft(const String &str, size_t count = -1) const {
return CompareLeft(str._cstr, count != -1 ? count : str._len);
return CompareLeft(str._cstr, count != npos ? count : str._len);
}
int CompareLeft(const char *cstr, size_t count = -1) const;
int CompareLeftNoCase(const String &str, size_t count = -1) const {
return CompareLeftNoCase(str._cstr, count != -1 ? count : str._len);
return CompareLeftNoCase(str._cstr, count != npos ? count : str._len);
}
int CompareLeftNoCase(const char *cstr, size_t count = -1) const;
// Compares any part of this string with given string
int CompareMid(const String &str, size_t from, size_t count = -1) const {
return CompareMid(str._cstr, from, count != -1 ? count : str._len);
return CompareMid(str._cstr, from, count != npos ? count : str._len);
}
int CompareMid(const char *cstr, size_t from, size_t count = -1) const;
int CompareMidNoCase(const String &str, size_t from, size_t count = -1) const {
return CompareMidNoCase(str._cstr, from, count != -1 ? count : str._len);
return CompareMidNoCase(str._cstr, from, count != npos ? count : str._len);
}
int CompareMidNoCase(const char *cstr, size_t from, size_t count = -1) const;
// Compares the rightmost part of this string with given C-string
int CompareRight(const String &str, size_t count = -1) const {
return CompareRight(str._cstr, count != -1 ? count : str._len);
return CompareRight(str._cstr, count != npos ? count : str._len);
}
int CompareRight(const char *cstr, size_t count = -1) const;
int CompareRightNoCase(const String &str, size_t count = -1) const {
return CompareRightNoCase(str._cstr, count != -1 ? count : str._len);
return CompareRightNoCase(str._cstr, count != npos ? count : str._len);
}
int CompareRightNoCase(const char *cstr, size_t count = -1) const;
// Convenience aliases for Compare functions
@ -379,9 +379,6 @@ public:
// Operators
//-------------------------------------------------------------------------
inline operator const char *() const {
return _cstr;
}
// Assign String by sharing data reference
String &operator=(const String &str);
// Move operator
@ -414,6 +411,10 @@ public:
operator Common::String() const {
return Common::String(_cstr);
}
// Fixes compilation error in script_set
operator bool() const {
return !IsEmpty();
}
private:
// Creates new empty string with buffer enough to fit given length