MUSH2021/src/mush2021.cpp
2021-06-23 23:59:55 -07:00

97 lines
2.9 KiB
C++

/*
__ _____ _______ __ _____ ____ ___ ___
/ |/ / / / / ___// / / /__ \ / __ \__ \< /
/ /|_/ / / / /\__ \/ /_/ /__/ // / / /_/ // /
/ / / / /_/ /___/ / __ // __// /_/ / __// /
/_/ /_/\____//____/_/ /_//____/\____/____/_/
Copyright (C) 2021 MatCat
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include <cstdio>
#include <string>
#include <cstring>
#include <vector>
#include <cstdint>
#include <uv.h>
#include <algorithm>
#include "classes.hpp"
#include "socketserver.hpp"
using namespace std;
uint64_t AllocatedIndex;
vector<ObjectVector> ObjectMap;
uint64_t addObject(BaseObject *obj) {
ObjectVector v_Obj;
v_Obj.ID = AllocatedIndex;
v_Obj.Object = obj;
ObjectMap.push_back(v_Obj);
AllocatedIndex++;
return v_Obj.ID;
}
BaseObject* findObjectByID(uint64_t id) {
for (auto i = ObjectMap.begin() ; i != ObjectMap.end(); i++) {
if (i->ID == id) {
return i->Object;
}
}
return (BaseObject *)NULL;
}
int main() {
AllocatedIndex = 0;
BaseObject Universe;
UserObject God;
BaseObject Canik;
BaseObject Magazine;
Universe.ID = addObject(&Universe);
Universe.Name = "MUSH2021";
God.ID = addObject(&God);
God.Container = &Universe;
Canik.ID = addObject(&Canik);
Magazine.ID = addObject(&Magazine);
God.Name = "MatCat";
God.Password="myPass69";
Canik.Name = "Canik TP9SF Elite";
Canik.Container = &God;
Magazine.Name = "Canik TP9SF Elite 9mm 15rd Magazine";
Magazine.Container = &Canik;
Magazine.SetVariable("Loaded","15");
God.printUserInfo();
BaseObject *TestObj = findObjectByID(2);
BaseObject *TestObj2 = findObjectByID(3);
if (TestObj != NULL) printf("Object #2 is: %s which is contained in %s\n",TestObj->Name.c_str(),TestObj->Container->Name.c_str());
if (TestObj2 != NULL) printf("Object #3 is: %s which is contained in %s, it is loaded with %s rounds\n",TestObj2->Name.c_str(),TestObj2->Container->Name.c_str(),TestObj2->getVariable("Loaded").c_str());
printf("There are %u objects in existance\n",ObjectMap.size());
setupSocketServer();
}