X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=Source%2FConsoleCmds.cpp;h=df26f820498d05c4a28f6ff1967430ba101b248b;hb=8a32dc9e4e1011b10f009e999d7d008aa2711d8a;hp=32e9c1cb6a8a3f174f48a52bb39a2177c53c14e1;hpb=6df65bf46ace2c0b8753115b8c39600f307e3452;p=lugaru.git diff --git a/Source/ConsoleCmds.cpp b/Source/ConsoleCmds.cpp index 32e9c1c..df26f82 100644 --- a/Source/ConsoleCmds.cpp +++ b/Source/ConsoleCmds.cpp @@ -20,6 +20,9 @@ along with Lugaru. If not, see . #include "ConsoleCmds.h" #include "Game.h" +#include "Dialog.h" +#include "Hotspot.h" +#include "Utils/Folders.h" const char *cmd_names[cmd_count] = { #define DECLARE_COMMAND(cmd) #cmd, @@ -47,12 +50,7 @@ extern float slomospeed; extern float slomofreq; extern int tutoriallevel; extern int hostile; -extern XYZ hotspot[40]; -extern int hotspottype[40]; -extern float hotspotsize[40]; -extern char hotspottext[40][256]; extern int maptype; -extern int numhotspots; extern Objects objects; extern int slomo; extern float slomodelay; @@ -141,7 +139,7 @@ static void set_noclothes(int pnum, const char *args) static void set_clothes(int pnum, const char *args) { char buf[64]; - snprintf(buf, 63, ":Data:Textures:%s.png", args); + snprintf(buf, 63, "Textures/%s.png", args); int id = Person::players[pnum]->numclothes; strcpy(Person::players[pnum]->clothes[id], buf); @@ -172,13 +170,12 @@ void ch_map(const char *args) void ch_save(const char *args) { - char buf[64]; - snprintf(buf, 63, ":Data:Maps:%s", args); + std::string map_path = Folders::getUserDataPath() + "/Maps/" + args; int mapvers = 12; FILE *tfile; - tfile = fopen( ConvertFileName(buf), "wb" ); + tfile = fopen( map_path.c_str(), "wb" ); fpackf(tfile, "Bi", mapvers); fpackf(tfile, "Bi", maptype); fpackf(tfile, "Bi", hostile); @@ -200,48 +197,7 @@ void ch_save(const char *args) fpackf(tfile, "Bi Bi", Person::players[0]->whichskin, Person::players[0]->creature); - fpackf(tfile, "Bi", numdialogues); - - for (int k = 0; k < numdialogues; k++) { - fpackf(tfile, "Bi", numdialogueboxes[k]); - fpackf(tfile, "Bi", dialoguetype[k]); - for (int l = 0; l < 10; l++) { - fpackf(tfile, "Bf Bf Bf", participantlocation[k][l].x, participantlocation[k][l].y, participantlocation[k][l].z); - fpackf(tfile, "Bf", participantyaw[k][l]); - } - for (int l = 0; l < numdialogueboxes[k]; l++) { - fpackf(tfile, "Bi", dialogueboxlocation[k][l]); - fpackf(tfile, "Bf", dialogueboxcolor[k][l][0]); - fpackf(tfile, "Bf", dialogueboxcolor[k][l][1]); - fpackf(tfile, "Bf", dialogueboxcolor[k][l][2]); - fpackf(tfile, "Bi", dialogueboxsound[k][l]); - - int templength = strlen(dialoguetext[k][l]); - fpackf(tfile, "Bi", (templength)); - for (int m = 0; m < templength; m++) { - fpackf(tfile, "Bb", dialoguetext[k][l][m]); - if (dialoguetext[k][l][m] == '\0') - break; - } - - templength = strlen(dialoguename[k][l]); - fpackf(tfile, "Bi", templength); - for (int m = 0; m < templength; m++) { - fpackf(tfile, "Bb", dialoguename[k][l][m]); - if (dialoguename[k][l][m] == '\0') - break; - } - - fpackf(tfile, "Bf Bf Bf", dialoguecamera[k][l].x, dialoguecamera[k][l].y, dialoguecamera[k][l].z); - fpackf(tfile, "Bi", participantfocus[k][l]); - fpackf(tfile, "Bi", participantaction[k][l]); - - for (int m = 0; m < 10; m++) - fpackf(tfile, "Bf Bf Bf", participantfacing[k][l][m].x, participantfacing[k][l][m].y, participantfacing[k][l][m].z); - - fpackf(tfile, "Bf Bf", dialoguecamerayaw[k][l], dialoguecamerapitch[k][l]); - } - } + Dialog::saveDialogs(tfile); for (int k = 0; k < Person::players[0]->numclothes; k++) { int templength = strlen(Person::players[0]->clothes[k]); @@ -259,13 +215,13 @@ void ch_save(const char *args) fpackf(tfile, "Bi Bf Bf Bf Bf Bf Bf", objects.type[k], objects.yaw[k], objects.pitch[k], objects.position[k].x, objects.position[k].y, objects.position[k].z, objects.scale[k]); - fpackf(tfile, "Bi", numhotspots); - for (int i = 0; i < numhotspots; i++) { - fpackf(tfile, "Bi Bf Bf Bf Bf", hotspottype[i], hotspotsize[i], hotspot[i].x, hotspot[i].y, hotspot[i].z); - int templength = strlen(hotspottext[i]); + fpackf(tfile, "Bi", Hotspot::hotspots.size()); + for (int i = 0; i < Hotspot::hotspots.size(); i++) { + fpackf(tfile, "Bi Bf Bf Bf Bf", Hotspot::hotspots[i].type, Hotspot::hotspots[i].size, Hotspot::hotspots[i].position.x, Hotspot::hotspots[i].position.y, Hotspot::hotspots[i].position.z); + int templength = strlen(Hotspot::hotspots[i].text); fpackf(tfile, "Bi", templength); for (int l = 0; l < templength; l++) - fpackf(tfile, "Bb", hotspottext[i][l]); + fpackf(tfile, "Bb", Hotspot::hotspots[i].text[l]); } fpackf(tfile, "Bi", Person::players.size()); @@ -340,7 +296,7 @@ void ch_save(const char *args) void ch_cellar(const char *args) { - Person::players[0]->skeleton.drawmodel.textureptr.load(":Data:Textures:Furdarko.jpg", 1, &Person::players[0]->skeleton.skinText[0], &Person::players[0]->skeleton.skinsize); + Person::players[0]->skeleton.drawmodel.textureptr.load("Textures/Furdarko.jpg", 1, &Person::players[0]->skeleton.skinText[0], &Person::players[0]->skeleton.skinsize); } void ch_tint(const char *args) @@ -482,15 +438,8 @@ void ch_cellophane(const char *args) void ch_funnybunny(const char *args) { - Person::players[0]->skeleton.id = 0; - Person::players[0]->skeleton.Load(":Data:Skeleton:Basic Figure", ":Data:Skeleton:Basic Figurelow", - ":Data:Skeleton:Rabbitbelt", ":Data:Models:Body.solid", - ":Data:Models:Body2.solid", ":Data:Models:Body3.solid", - ":Data:Models:Body4.solid", ":Data:Models:Body5.solid", - ":Data:Models:Body6.solid", ":Data:Models:Body7.solid", - ":Data:Models:Bodylow.solid", ":Data:Models:Belt.solid", 1); - Person::players[0]->skeleton.drawmodel.textureptr.load(":Data:Textures:fur3.jpg", 1, &Person::players[0]->skeleton.skinText[0], &Person::players[0]->skeleton.skinsize); Person::players[0]->creature = rabbittype; + Person::players[0]->skeletonLoad(true); Person::players[0]->scale = .2; Person::players[0]->headless = 0; Person::players[0]->damagetolerance = 200; @@ -499,15 +448,8 @@ void ch_funnybunny(const char *args) void ch_wolfie(const char *args) { - Person::players[0]->skeleton.id = 0; - Person::players[0]->skeleton.Load(":Data:Skeleton:Basic Figure Wolf", ":Data:Skeleton:Basic Figure Wolf Low", - ":Data:Skeleton:Rabbitbelt", ":Data:Models:Wolf.solid", - ":Data:Models:Wolf2.solid", ":Data:Models:Wolf3.solid", - ":Data:Models:Wolf4.solid", ":Data:Models:Wolf5.solid", - ":Data:Models:Wolf6.solid", ":Data:Models:Wolf7.solid", - ":Data:Models:Wolflow.solid", ":Data:Models:Belt.solid", 0); - Person::players[0]->skeleton.drawmodel.textureptr.load(":Data:Textures:Wolf.jpg", 1, &Person::players[0]->skeleton.skinText[0], &Person::players[0]->skeleton.skinsize); Person::players[0]->creature = wolftype; + Person::players[0]->skeletonLoad(); Person::players[0]->damagetolerance = 300; set_proportion(0, "1 1 1 1"); } @@ -519,37 +461,37 @@ void ch_wolfieisgod(const char *args) void ch_wolf(const char *args) { - Person::players[0]->skeleton.drawmodel.textureptr.load(":Data:Textures:Wolf.jpg", 1, &Person::players[0]->skeleton.skinText[0], &Person::players[0]->skeleton.skinsize); + Person::players[0]->skeleton.drawmodel.textureptr.load("Textures/Wolf.jpg", 1, &Person::players[0]->skeleton.skinText[0], &Person::players[0]->skeleton.skinsize); } void ch_snowwolf(const char *args) { - Person::players[0]->skeleton.drawmodel.textureptr.load(":Data:Textures:SnowWolf.jpg", 1, &Person::players[0]->skeleton.skinText[0], &Person::players[0]->skeleton.skinsize); + Person::players[0]->skeleton.drawmodel.textureptr.load("Textures/SnowWolf.jpg", 1, &Person::players[0]->skeleton.skinText[0], &Person::players[0]->skeleton.skinsize); } void ch_darkwolf(const char *args) { - Person::players[0]->skeleton.drawmodel.textureptr.load(":Data:Textures:DarkWolf.jpg", 1, &Person::players[0]->skeleton.skinText[0], &Person::players[0]->skeleton.skinsize); + Person::players[0]->skeleton.drawmodel.textureptr.load("Textures/DarkWolf.jpg", 1, &Person::players[0]->skeleton.skinText[0], &Person::players[0]->skeleton.skinsize); } void ch_lizardwolf(const char *args) { - Person::players[0]->skeleton.drawmodel.textureptr.load(":Data:Textures:Lizardwolf.jpg", 1, &Person::players[0]->skeleton.skinText[0], &Person::players[0]->skeleton.skinsize); + Person::players[0]->skeleton.drawmodel.textureptr.load("Textures/LizardWolf.jpg", 1, &Person::players[0]->skeleton.skinText[0], &Person::players[0]->skeleton.skinsize); } void ch_white(const char *args) { - Person::players[0]->skeleton.drawmodel.textureptr.load(":Data:Textures:fur.jpg", 1, &Person::players[0]->skeleton.skinText[0], &Person::players[0]->skeleton.skinsize); + Person::players[0]->skeleton.drawmodel.textureptr.load("Textures/Fur.jpg", 1, &Person::players[0]->skeleton.skinText[0], &Person::players[0]->skeleton.skinsize); } void ch_brown(const char *args) { - Person::players[0]->skeleton.drawmodel.textureptr.load(":Data:Textures:fur3.jpg", 1, &Person::players[0]->skeleton.skinText[0], &Person::players[0]->skeleton.skinsize); + Person::players[0]->skeleton.drawmodel.textureptr.load("Textures/Fur3.jpg", 1, &Person::players[0]->skeleton.skinText[0], &Person::players[0]->skeleton.skinsize); } void ch_black(const char *args) { - Person::players[0]->skeleton.drawmodel.textureptr.load(":Data:Textures:fur2.jpg", 1, &Person::players[0]->skeleton.skinText[0], &Person::players[0]->skeleton.skinsize); + Person::players[0]->skeleton.drawmodel.textureptr.load("Textures/Fur2.jpg", 1, &Person::players[0]->skeleton.skinText[0], &Person::players[0]->skeleton.skinsize); } void ch_sizemin(const char *args) @@ -591,134 +533,67 @@ void ch_path(const char *args) void ch_hs(const char *args) { - hotspot[numhotspots] = Person::players[0]->coords; - float size; int type, shift; sscanf(args, "%f%d %n", &size, &type, &shift); - hotspotsize[numhotspots] = size; - hotspottype[numhotspots] = type; + Hotspot::hotspots.emplace_back(Person::players[0]->coords, type, size); - strcpy(hotspottext[numhotspots], args + shift); - strcat(hotspottext[numhotspots], "\n"); - - numhotspots++; + strcpy(Hotspot::hotspots.back().text, args + shift); + strcat(Hotspot::hotspots.back().text, "\n"); } void ch_dialogue(const char *args) { - int dlg; - char buf1[32], buf2[64]; - - sscanf(args, "%d %31s", &dlg, buf1); - snprintf(buf2, 63, ":Data:Dialogues:%s.txt", buf1); - - dialoguetype[numdialogues] = dlg; - - memset(dialoguetext[numdialogues], 0, sizeof(dialoguetext[numdialogues])); - memset(dialoguename[numdialogues], 0, sizeof(dialoguename[numdialogues])); - - ifstream ipstream(ConvertFileName(buf2)); - ipstream.ignore(256, ':'); - ipstream >> numdialogueboxes[numdialogues]; - for (int i = 0; i < numdialogueboxes[numdialogues]; i++) { - ipstream.ignore(256, ':'); - ipstream.ignore(256, ':'); - ipstream.ignore(256, ' '); - ipstream >> dialogueboxlocation[numdialogues][i]; - ipstream.ignore(256, ':'); - ipstream >> dialogueboxcolor[numdialogues][i][0]; - ipstream >> dialogueboxcolor[numdialogues][i][1]; - ipstream >> dialogueboxcolor[numdialogues][i][2]; - ipstream.ignore(256, ':'); - ipstream.getline(dialoguename[numdialogues][i], 64); - ipstream.ignore(256, ':'); - ipstream.ignore(256, ' '); - ipstream.getline(dialoguetext[numdialogues][i], 128); - for (int j = 0; j < 128; j++) { - if (dialoguetext[numdialogues][i][j] == '\\') - dialoguetext[numdialogues][i][j] = '\n'; - } - ipstream.ignore(256, ':'); - ipstream >> dialogueboxsound[numdialogues][i]; - } + int type; + char buf1[32]; - for (int i = 0; i < numdialogueboxes[numdialogues]; i++) { - for (unsigned j = 0; j < Person::players.size(); j++) { - participantfacing[numdialogues][i][j] = Person::players[j]->facing; - } - } - ipstream.close(); + sscanf(args, "%d %31s", &type, buf1); + std::string filename = std::string("Dialogues/") + buf1 + ".txt"; - directing = 1; - indialogue = 0; - whichdialogue = numdialogues; + Dialog::dialogs.push_back(Dialog(type, filename)); - numdialogues++; + Dialog::directing = true; + Dialog::indialogue = 0; + Dialog::whichdialogue = Dialog::dialogs.size(); } void ch_fixdialogue(const char *args) { - char buf1[32], buf2[64]; + char buf1[32]; int whichdi; sscanf(args, "%d %31s", &whichdi, buf1); - snprintf(buf2, 63, ":Data:Dialogues:%s.txt", buf1); - - memset(dialoguetext[whichdi], 0, sizeof(dialoguetext[whichdi])); - memset(dialoguename[whichdi], 0, sizeof(dialoguename[whichdi])); - - ifstream ipstream(ConvertFileName(buf2)); - ipstream.ignore(256, ':'); - ipstream >> numdialogueboxes[whichdi]; - for (int i = 0; i < numdialogueboxes[whichdi]; i++) { - ipstream.ignore(256, ':'); - ipstream.ignore(256, ':'); - ipstream.ignore(256, ' '); - ipstream >> dialogueboxlocation[whichdi][i]; - ipstream.ignore(256, ':'); - ipstream >> dialogueboxcolor[whichdi][i][0]; - ipstream >> dialogueboxcolor[whichdi][i][1]; - ipstream >> dialogueboxcolor[whichdi][i][2]; - ipstream.ignore(256, ':'); - ipstream.getline(dialoguename[whichdi][i], 64); - ipstream.ignore(256, ':'); - ipstream.ignore(256, ' '); - ipstream.getline(dialoguetext[whichdi][i], 128); - for (int j = 0; j < 128; j++) { - if (dialoguetext[whichdi][i][j] == '\\') - dialoguetext[whichdi][i][j] = '\n'; - } - ipstream.ignore(256, ':'); - ipstream >> dialogueboxsound[whichdi][i]; - } + std::string filename = std::string("Dialogues/") + buf1 + ".txt"; - ipstream.close(); + Dialog::dialogs[whichdi] = Dialog(Dialog::dialogs[whichdi].type, filename); } void ch_fixtype(const char *args) { int dlg; sscanf(args, "%d", &dlg); - dialoguetype[0] = dlg; + Dialog::dialogs[0].type = dlg; } void ch_fixrotation(const char *args) { - participantyaw[whichdialogue][participantfocus[whichdialogue][indialogue]] = Person::players[participantfocus[whichdialogue][indialogue]]->yaw; + int playerId = Dialog::currentScene().participantfocus; + Dialog::currentDialog().participantyaw[playerId] = Person::players[playerId]->yaw; } void ch_ddialogue(const char *args) { - if (numdialogues) - numdialogues--; + if (!Dialog::dialogs.empty()) { + Dialog::dialogs.pop_back(); + } } void ch_dhs(const char *args) { - if (numhotspots) - numhotspots--; + if (!Hotspot::hotspots.empty()) { + Hotspot::hotspots.pop_back(); + } } void ch_immobile(const char *args) @@ -778,24 +653,13 @@ void ch_play(const char *args) { int dlg; sscanf(args, "%d", &dlg); - whichdialogue = dlg; + Dialog::whichdialogue = dlg; - if (whichdialogue >= numdialogues) + if (Dialog::whichdialogue >= Dialog::dialogs.size()) { return; - - for (int i = 0; i < numdialogueboxes[whichdialogue]; i++) { - Person::players[participantfocus[whichdialogue][i]]->coords = participantlocation[whichdialogue][participantfocus[whichdialogue][i]]; - Person::players[participantfocus[whichdialogue][i]]->yaw = participantyaw[whichdialogue][participantfocus[whichdialogue][i]]; - Person::players[participantfocus[whichdialogue][i]]->targetyaw = participantyaw[whichdialogue][participantfocus[whichdialogue][i]]; - Person::players[participantfocus[whichdialogue][i]]->velocity = 0; - Person::players[participantfocus[whichdialogue][i]]->animTarget = Person::players[participantfocus[whichdialogue][i]]->getIdle(); - Person::players[participantfocus[whichdialogue][i]]->frameTarget = 0; } - directing = 0; - indialogue = 0; - - playdialogueboxsound(); + Dialog::currentDialog().play(); } void ch_mapkilleveryone(const char *args)