|
|
@@ -1,10 +1,10 @@
|
|
|
#include "FactoryClient.h"
|
|
|
|
|
|
-#include <Bild.h>
|
|
|
-#include <Datei.h>
|
|
|
-#include <DateiSystem.h>
|
|
|
-#include <M3Datei.h>
|
|
|
-#include <Textur.h>
|
|
|
+#include <File.h>
|
|
|
+#include <FileSystem.h>
|
|
|
+#include <Image.h>
|
|
|
+#include <M3File.h>
|
|
|
+#include <Texture.h>
|
|
|
|
|
|
#include "Globals.h"
|
|
|
#include "Load.h"
|
|
|
@@ -12,7 +12,7 @@
|
|
|
using namespace Network;
|
|
|
using namespace Framework;
|
|
|
|
|
|
-void createDefaultCube(Bildschirm* zScreen)
|
|
|
+void createDefaultCube(Screen* zScreen)
|
|
|
{
|
|
|
Model3DData* data = zScreen->zGraphicsApi()->createModel("cube");
|
|
|
data->setAmbientFactor(0.f);
|
|
|
@@ -163,7 +163,7 @@ void createDefaultCube(Bildschirm* zScreen)
|
|
|
data->release();
|
|
|
}
|
|
|
|
|
|
-void createGrass(Bildschirm* zScreen)
|
|
|
+void createGrass(Screen* zScreen)
|
|
|
{
|
|
|
Model3DData* data = zScreen->zGraphicsApi()->createModel("grass");
|
|
|
data->setAmbientFactor(0.f);
|
|
|
@@ -288,7 +288,7 @@ void createGrass(Bildschirm* zScreen)
|
|
|
data->release();
|
|
|
}
|
|
|
|
|
|
-void createFluidCube(Bildschirm* zScreen)
|
|
|
+void createFluidCube(Screen* zScreen)
|
|
|
{
|
|
|
Model3DData* data = zScreen->zGraphicsApi()->createModel("fluid");
|
|
|
data->setAmbientFactor(0.f);
|
|
|
@@ -440,7 +440,7 @@ void createFluidCube(Bildschirm* zScreen)
|
|
|
data->release();
|
|
|
}
|
|
|
|
|
|
-void createModels(Bildschirm* zScreen)
|
|
|
+void createModels(Screen* zScreen)
|
|
|
{
|
|
|
createDefaultCube(zScreen);
|
|
|
createGrass(zScreen);
|
|
|
@@ -480,29 +480,29 @@ void FactoryClient::loadServerInfo()
|
|
|
resourcePath.append() << client->getServerIp() << "/"
|
|
|
<< client->getServerPort() << "/";
|
|
|
Text tmp = resourcePath + "metainfo.dat";
|
|
|
- Datei metaInfo(tmp);
|
|
|
+ File metaInfo(tmp);
|
|
|
Trie<FileInfo*> metaInfos;
|
|
|
Array<FileInfo*> metaInfoList;
|
|
|
Array<FileInfo*> downloadOrder;
|
|
|
- if (metaInfo.existiert())
|
|
|
+ if (metaInfo.exists())
|
|
|
{
|
|
|
loadMenu->beginNextStage(
|
|
|
"reading resource metadata", (int)metaInfo.getSize());
|
|
|
- metaInfo.open(Datei::Style::lesen);
|
|
|
- while (!metaInfo.istEnde())
|
|
|
+ metaInfo.open(File::Style::read);
|
|
|
+ while (!metaInfo.isEnd())
|
|
|
{
|
|
|
short len = 0;
|
|
|
- metaInfo.lese((char*)&len, 2);
|
|
|
+ metaInfo.read((char*)&len, 2);
|
|
|
char* path = new char[len + 1];
|
|
|
- metaInfo.lese(path, len);
|
|
|
+ metaInfo.read(path, len);
|
|
|
path[len] = 0;
|
|
|
FileInfo* fi = new FileInfo();
|
|
|
fi->path = Text(path);
|
|
|
fi->size = 0;
|
|
|
- metaInfo.lese((char*)&fi->year, 4);
|
|
|
- metaInfo.lese((char*)&fi->month, 4);
|
|
|
- metaInfo.lese((char*)&fi->day, 4);
|
|
|
- metaInfo.lese((char*)&fi->seconds, 4);
|
|
|
+ metaInfo.read((char*)&fi->year, 4);
|
|
|
+ metaInfo.read((char*)&fi->month, 4);
|
|
|
+ metaInfo.read((char*)&fi->day, 4);
|
|
|
+ metaInfo.read((char*)&fi->seconds, 4);
|
|
|
metaInfos.set(path, len, fi);
|
|
|
delete[] path;
|
|
|
metaInfoList.add(fi);
|
|
|
@@ -511,21 +511,21 @@ void FactoryClient::loadServerInfo()
|
|
|
metaInfo.close();
|
|
|
}
|
|
|
short len = 0;
|
|
|
- foreground->getNachricht((char*)&len, 2);
|
|
|
+ foreground->getMessage((char*)&len, 2);
|
|
|
while (len)
|
|
|
{
|
|
|
char* path = new char[len + 1];
|
|
|
- foreground->getNachricht(path, len);
|
|
|
+ foreground->getMessage(path, len);
|
|
|
path[len] = 0;
|
|
|
FileInfo* fi = metaInfos.get(path, len);
|
|
|
int year;
|
|
|
int month;
|
|
|
int day;
|
|
|
int seconds;
|
|
|
- foreground->getNachricht((char*)&year, 4);
|
|
|
- foreground->getNachricht((char*)&month, 4);
|
|
|
- foreground->getNachricht((char*)&day, 4);
|
|
|
- foreground->getNachricht((char*)&seconds, 4);
|
|
|
+ foreground->getMessage((char*)&year, 4);
|
|
|
+ foreground->getMessage((char*)&month, 4);
|
|
|
+ foreground->getMessage((char*)&day, 4);
|
|
|
+ foreground->getMessage((char*)&seconds, 4);
|
|
|
if (!fi || fi->year != year || fi->month != month || fi->day != day
|
|
|
|| fi->seconds != seconds)
|
|
|
{
|
|
|
@@ -540,37 +540,37 @@ void FactoryClient::loadServerInfo()
|
|
|
fi->month = month;
|
|
|
fi->day = day;
|
|
|
fi->seconds = seconds;
|
|
|
- foreground->sende("\1", 1);
|
|
|
- foreground->getNachricht((char*)&fi->size, 8);
|
|
|
+ foreground->send("\1", 1);
|
|
|
+ foreground->getMessage((char*)&fi->size, 8);
|
|
|
downloadOrder.add(fi);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- foreground->sende("\0", 1);
|
|
|
+ foreground->send("\0", 1);
|
|
|
}
|
|
|
delete[] path;
|
|
|
- foreground->getNachricht((char*)&len, 2);
|
|
|
+ foreground->getMessage((char*)&len, 2);
|
|
|
}
|
|
|
loadMenu->allProgress(1);
|
|
|
char* buffer = new char[4096];
|
|
|
loadMenu->beginNextStage(
|
|
|
- "download updated resouces", downloadOrder.getEintragAnzahl());
|
|
|
+ "download updated resouces", downloadOrder.getEntryCount());
|
|
|
for (FileInfo* info : downloadOrder)
|
|
|
{
|
|
|
loadMenu->beginNextStep(info->path, (int)info->size);
|
|
|
tmp = resourcePath + info->path;
|
|
|
- Datei file(tmp);
|
|
|
- if (!file.existiert())
|
|
|
+ File file(tmp);
|
|
|
+ if (!file.exists())
|
|
|
{
|
|
|
- file.erstellen();
|
|
|
+ file.create();
|
|
|
}
|
|
|
- file.open(Datei::Style::schreiben);
|
|
|
+ file.open(File::Style::write);
|
|
|
__int64 remaining = info->size;
|
|
|
while (remaining > 0)
|
|
|
{
|
|
|
int toRead = remaining > 4096 ? 4096 : (int)remaining;
|
|
|
- foreground->getNachricht(buffer, toRead);
|
|
|
- file.schreibe(buffer, toRead);
|
|
|
+ foreground->getMessage(buffer, toRead);
|
|
|
+ file.write(buffer, toRead);
|
|
|
remaining -= toRead;
|
|
|
loadMenu->stepProgress(toRead);
|
|
|
}
|
|
|
@@ -580,52 +580,51 @@ void FactoryClient::loadServerInfo()
|
|
|
delete[] buffer;
|
|
|
loadMenu->allProgress(1);
|
|
|
loadMenu->beginNextStage(
|
|
|
- "writing resource metadata", metaInfoList.getEintragAnzahl());
|
|
|
- if (!metaInfo.existiert())
|
|
|
+ "writing resource metadata", metaInfoList.getEntryCount());
|
|
|
+ if (!metaInfo.exists())
|
|
|
{
|
|
|
- metaInfo.erstellen();
|
|
|
+ metaInfo.create();
|
|
|
}
|
|
|
- metaInfo.open(Datei::Style::schreiben);
|
|
|
+ metaInfo.open(File::Style::write);
|
|
|
for (FileInfo* info : metaInfoList)
|
|
|
{
|
|
|
short len = (short)info->path.getLength();
|
|
|
- metaInfo.schreibe((char*)&len, 2);
|
|
|
- metaInfo.schreibe(info->path.getText(), len);
|
|
|
- metaInfo.schreibe((char*)&info->year, 4);
|
|
|
- metaInfo.schreibe((char*)&info->month, 4);
|
|
|
- metaInfo.schreibe((char*)&info->day, 4);
|
|
|
- metaInfo.schreibe((char*)&info->seconds, 4);
|
|
|
+ metaInfo.write((char*)&len, 2);
|
|
|
+ metaInfo.write(info->path.getText(), len);
|
|
|
+ metaInfo.write((char*)&info->year, 4);
|
|
|
+ metaInfo.write((char*)&info->month, 4);
|
|
|
+ metaInfo.write((char*)&info->day, 4);
|
|
|
+ metaInfo.write((char*)&info->seconds, 4);
|
|
|
loadMenu->stageProgress(1);
|
|
|
}
|
|
|
metaInfo.close();
|
|
|
loadMenu->allProgress(1);
|
|
|
- loadMenu->beginNextStage(
|
|
|
- "loading resources", metaInfoList.getEintragAnzahl());
|
|
|
+ loadMenu->beginNextStage("loading resources", metaInfoList.getEntryCount());
|
|
|
for (FileInfo* info : metaInfoList)
|
|
|
{
|
|
|
if (info->path.endsWith(".ltdb"))
|
|
|
{
|
|
|
- LTDBDatei dat;
|
|
|
- dat.setDatei(new Text(resourcePath + info->path));
|
|
|
- dat.leseDaten(0);
|
|
|
- loadMenu->beginNextStep(info->path, dat.getBildAnzahl());
|
|
|
- for (Text* name : *dat.zBildListe())
|
|
|
+ LTDBFile dat;
|
|
|
+ dat.setFile(new Text(resourcePath + info->path));
|
|
|
+ dat.readData(0);
|
|
|
+ loadMenu->beginNextStep(info->path, dat.getImageCount());
|
|
|
+ for (Text* name : *dat.zImageListe())
|
|
|
{
|
|
|
- Bild* b = dat.laden(0, new Text(*name));
|
|
|
+ Image* b = dat.load(0, new Text(*name));
|
|
|
uiFactory.initParam.bildschirm->zGraphicsApi()
|
|
|
- ->createOrGetTextur(info->path + "/" + *name, b)
|
|
|
+ ->createOrGetTexture(info->path + "/" + *name, b)
|
|
|
->release();
|
|
|
loadMenu->stepProgress(1);
|
|
|
}
|
|
|
}
|
|
|
else if (info->path.endsWith(".m3"))
|
|
|
{
|
|
|
- M3Datei dat(resourcePath + info->path);
|
|
|
- dat.leseDaten();
|
|
|
- loadMenu->beginNextStep(info->path, dat.getModelAnzahl());
|
|
|
- for (int i = 0; i < dat.getModelAnzahl(); i++)
|
|
|
+ M3File dat(resourcePath + info->path);
|
|
|
+ dat.readData();
|
|
|
+ loadMenu->beginNextStep(info->path, dat.getModelCount());
|
|
|
+ for (int i = 0; i < dat.getModelCount(); i++)
|
|
|
{
|
|
|
- Model3DData* d = dat.ladeModel(dat.zModelName(i)->getText(),
|
|
|
+ Model3DData* d = dat.loadModel(dat.zModelName(i)->getText(),
|
|
|
uiFactory.initParam.bildschirm->zGraphicsApi(),
|
|
|
info->path + "/" + *dat.zModelName(i));
|
|
|
d->release();
|
|
|
@@ -648,22 +647,22 @@ void FactoryClient::loadServerInfo()
|
|
|
for (int i = 0; i < entityTypeCount; i++)
|
|
|
entityTypes[i]->release();
|
|
|
delete[] entityTypes;
|
|
|
- foregroundReader->lese((char*)&blockTypeCount, 4);
|
|
|
+ foregroundReader->read((char*)&blockTypeCount, 4);
|
|
|
blockTypes = new BlockType*[blockTypeCount];
|
|
|
for (int i = 0; i < blockTypeCount; i++)
|
|
|
{
|
|
|
int id;
|
|
|
- foregroundReader->lese((char*)&id, 4);
|
|
|
+ foregroundReader->read((char*)&id, 4);
|
|
|
bool needsInstance;
|
|
|
- foregroundReader->lese((char*)&needsInstance, 1);
|
|
|
+ foregroundReader->read((char*)&needsInstance, 1);
|
|
|
bool needsSubscription;
|
|
|
- foregroundReader->lese((char*)&needsSubscription, 1);
|
|
|
+ foregroundReader->read((char*)&needsSubscription, 1);
|
|
|
bool fluid;
|
|
|
- foregroundReader->lese((char*)&fluid, 1);
|
|
|
+ foregroundReader->read((char*)&fluid, 1);
|
|
|
char maxFlowDistance = 0;
|
|
|
- if (fluid) foregroundReader->lese((char*)&maxFlowDistance, 1);
|
|
|
+ if (fluid) foregroundReader->read((char*)&maxFlowDistance, 1);
|
|
|
int maxHp;
|
|
|
- foregroundReader->lese((char*)&maxHp, 4);
|
|
|
+ foregroundReader->read((char*)&maxHp, 4);
|
|
|
blockTypes[i] = new BlockType(id,
|
|
|
needsInstance,
|
|
|
ModelInfo(foregroundReader),
|
|
|
@@ -673,21 +672,21 @@ void FactoryClient::loadServerInfo()
|
|
|
maxFlowDistance);
|
|
|
}
|
|
|
loadMenu->allProgress(1);
|
|
|
- foregroundReader->lese((char*)&itemTypeCount, 4);
|
|
|
+ foregroundReader->read((char*)&itemTypeCount, 4);
|
|
|
itemTypes = new ItemType*[itemTypeCount];
|
|
|
for (int i = 0; i < itemTypeCount; i++)
|
|
|
{
|
|
|
int id;
|
|
|
- foregroundReader->lese((char*)&id, 4);
|
|
|
+ foregroundReader->read((char*)&id, 4);
|
|
|
char len;
|
|
|
- foregroundReader->lese((char*)&len, 1);
|
|
|
+ foregroundReader->read((char*)&len, 1);
|
|
|
char* name = new char[len + 1];
|
|
|
- foregroundReader->lese(name, len);
|
|
|
+ foregroundReader->read(name, len);
|
|
|
name[len] = 0;
|
|
|
short tlen;
|
|
|
- foregroundReader->lese((char*)&tlen, 2);
|
|
|
+ foregroundReader->read((char*)&tlen, 2);
|
|
|
char* tooltipUIML = new char[tlen + 1];
|
|
|
- foregroundReader->lese(tooltipUIML, tlen);
|
|
|
+ foregroundReader->read(tooltipUIML, tlen);
|
|
|
tooltipUIML[tlen] = 0;
|
|
|
itemTypes[i] = new ItemType(
|
|
|
id, ModelInfo(foregroundReader), Text(name), Text(tooltipUIML));
|
|
|
@@ -695,28 +694,28 @@ void FactoryClient::loadServerInfo()
|
|
|
delete[] tooltipUIML;
|
|
|
}
|
|
|
loadMenu->allProgress(1);
|
|
|
- foregroundReader->lese((char*)&entityTypeCount, 4);
|
|
|
+ foregroundReader->read((char*)&entityTypeCount, 4);
|
|
|
entityTypes = new EntityType*[entityTypeCount];
|
|
|
for (int i = 0; i < entityTypeCount; i++)
|
|
|
{
|
|
|
int id;
|
|
|
- foregroundReader->lese((char*)&id, 4);
|
|
|
+ foregroundReader->read((char*)&id, 4);
|
|
|
entityTypes[i] = new EntityType(id, ModelInfo(foregroundReader));
|
|
|
}
|
|
|
loadMenu->allProgress(1);
|
|
|
loadMenu->beginNextStage("rendering item icons", itemTypeCount);
|
|
|
- Kam3D* kam = new Kam3D();
|
|
|
- Welt3D* w = new Welt3D();
|
|
|
+ Cam3D* kam = new Cam3D();
|
|
|
+ World3D* w = new World3D();
|
|
|
w->addDiffuseLight(DiffuseLight{
|
|
|
Vec3<float>(0.5f, 0.5f, -1.f), Vec3<float>(1.f, 1.f, 1.f)});
|
|
|
- kam->setWelt(w);
|
|
|
- kam->setBildschirmPosition(0, 0);
|
|
|
- kam->setBildschirmSize(50, 50);
|
|
|
+ kam->setWorld(w);
|
|
|
+ kam->setScreenPosition(0, 0);
|
|
|
+ kam->setScreenSize(50, 50);
|
|
|
kam->setPosition(Vec3<float>(0, 0, 0));
|
|
|
kam->setRotation(
|
|
|
{(float)PI / 2.f, 0.f, std::atan2(0.f, -1.f) + (float)PI / 2});
|
|
|
- Bild* b = new Bild();
|
|
|
- b->neuBild(50, 50, 0);
|
|
|
+ Image* b = new Image();
|
|
|
+ b->newImage(50, 50, 0);
|
|
|
for (int i = 0; i < itemTypeCount; i++)
|
|
|
{
|
|
|
Model3D* mdl = new Model3D();
|
|
|
@@ -730,29 +729,29 @@ void FactoryClient::loadServerInfo()
|
|
|
MAX(abs(min.z), abs(max.z)));
|
|
|
kam->setPosition(Vec3<float>(maxX * 3.5f, 0.f, 0.f));
|
|
|
}
|
|
|
- mdl->setModelDaten(data);
|
|
|
+ mdl->setModelData(data);
|
|
|
mdl->setModelTextur(itemTypes[i]->getItemTextur());
|
|
|
mdl->setPosition(Vec3<float>(0.f, 0.f, 0.f));
|
|
|
- mdl->setDrehung(0.25f, 0.25f, 0.55f);
|
|
|
+ mdl->setRotation(0.25f, 0.25f, 0.55f);
|
|
|
mdl->setAmbientFactor(0.8f);
|
|
|
mdl->setDiffusFactor(0.1f);
|
|
|
mdl->setSpecularFactor(0.1f);
|
|
|
mdl->setSize(itemTypes[i]->getSize());
|
|
|
- w->addZeichnung(mdl);
|
|
|
+ w->addDrawable(mdl);
|
|
|
w->tick(0);
|
|
|
- window->zBildschirm()->lock();
|
|
|
- DX11Textur* t = (DX11Textur*)window->zBildschirm()
|
|
|
- ->zGraphicsApi()
|
|
|
- ->createOrGetTextur(
|
|
|
- Text("rendered/items/") + itemTypes[i]->getId(),
|
|
|
- dynamic_cast<Bild*>(b->getThis()));
|
|
|
- window->zBildschirm()->zGraphicsApi()->renderKamera(kam, t);
|
|
|
- Bild* result = new Bild();
|
|
|
+ window->zScreen()->lock();
|
|
|
+ DX11Texture* t = (DX11Texture*)window->zScreen()
|
|
|
+ ->zGraphicsApi()
|
|
|
+ ->createOrGetTexture(Text("rendered/items/")
|
|
|
+ + itemTypes[i]->getId(),
|
|
|
+ dynamic_cast<Image*>(b->getThis()));
|
|
|
+ window->zScreen()->zGraphicsApi()->renderKamera(kam, t);
|
|
|
+ Image* result = new Image();
|
|
|
t->copyToImage(result);
|
|
|
itemTypes[i]->setBild(result);
|
|
|
t->release();
|
|
|
- window->zBildschirm()->unlock();
|
|
|
- w->removeZeichnung(mdl);
|
|
|
+ window->zScreen()->unlock();
|
|
|
+ w->removeDrawable(mdl);
|
|
|
loadMenu->stageProgress(1);
|
|
|
}
|
|
|
b->release();
|
|
|
@@ -763,41 +762,41 @@ void FactoryClient::loadServerInfo()
|
|
|
bool FactoryClient::connect(Text ip, unsigned short sslPort)
|
|
|
{
|
|
|
if (client) disconnect();
|
|
|
- client = new SSLKlient();
|
|
|
- if (!client->verbinde(sslPort, ip)) return false;
|
|
|
+ client = new SSLClient();
|
|
|
+ if (!client->connect(sslPort, ip)) return false;
|
|
|
char c;
|
|
|
- while (client->hatNachricht(1))
|
|
|
- client->getNachricht(&c, 1);
|
|
|
+ while (client->hasMessage(1))
|
|
|
+ client->getMessage(&c, 1);
|
|
|
this->ip = ip;
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
|
int FactoryClient::ping()
|
|
|
{
|
|
|
- ZeitMesser zm;
|
|
|
- zm.messungStart();
|
|
|
- if (!client->sende("\3", 1)) return -1;
|
|
|
+ Timer zm;
|
|
|
+ zm.measureStart();
|
|
|
+ if (!client->send("\3", 1)) return -1;
|
|
|
char c;
|
|
|
- client->getNachricht(&c, 1);
|
|
|
- zm.messungEnde();
|
|
|
+ client->getMessage(&c, 1);
|
|
|
+ zm.measureEnd();
|
|
|
return (int)(zm.getSekunden() * 1000);
|
|
|
}
|
|
|
|
|
|
int FactoryClient::status(Framework::Text name, Framework::Text secret)
|
|
|
{
|
|
|
- if (!client->sende("\4", 1)) return 404;
|
|
|
+ if (!client->send("\4", 1)) return 404;
|
|
|
char c;
|
|
|
- client->getNachricht(&c, 1);
|
|
|
+ client->getMessage(&c, 1);
|
|
|
if (c == 1)
|
|
|
{
|
|
|
char len = (char)name.getLength();
|
|
|
- client->sende(&len, 1);
|
|
|
- client->sende(name, len);
|
|
|
+ client->send(&len, 1);
|
|
|
+ client->send(name, len);
|
|
|
short sLen = (short)secret.getLength();
|
|
|
- client->sende((char*)&sLen, 2);
|
|
|
- client->sende(secret, sLen);
|
|
|
+ client->send((char*)&sLen, 2);
|
|
|
+ client->send(secret, sLen);
|
|
|
char res;
|
|
|
- client->getNachricht(&res, 1);
|
|
|
+ client->getMessage(&res, 1);
|
|
|
if (res == 1) return 200;
|
|
|
if (res == 0) return 403;
|
|
|
}
|
|
|
@@ -807,48 +806,48 @@ int FactoryClient::status(Framework::Text name, Framework::Text secret)
|
|
|
int FactoryClient::join(
|
|
|
Framework::Text name, Framework::Text& secret, unsigned short port)
|
|
|
{
|
|
|
- client->sende("\1", 1);
|
|
|
+ client->send("\1", 1);
|
|
|
char len = (char)name.getLength();
|
|
|
- client->sende(&len, 1);
|
|
|
- client->sende(name, len);
|
|
|
+ client->send(&len, 1);
|
|
|
+ client->send(name, len);
|
|
|
short sLen = (short)secret.getLength();
|
|
|
- client->sende((char*)&sLen, 2);
|
|
|
- client->sende(secret, sLen);
|
|
|
+ client->send((char*)&sLen, 2);
|
|
|
+ client->send(secret, sLen);
|
|
|
char res;
|
|
|
- client->getNachricht(&res, 1);
|
|
|
+ client->getMessage(&res, 1);
|
|
|
if (res == 1 || res == 2)
|
|
|
{
|
|
|
if (res == 2)
|
|
|
{
|
|
|
- client->getNachricht((char*)&sLen, 2);
|
|
|
+ client->getMessage((char*)&sLen, 2);
|
|
|
char* buffer = new char[sLen + 1];
|
|
|
- client->getNachricht(buffer, sLen);
|
|
|
+ client->getMessage(buffer, sLen);
|
|
|
buffer[sLen] = 0;
|
|
|
secret = buffer;
|
|
|
delete[] buffer;
|
|
|
}
|
|
|
short keyLen;
|
|
|
- client->getNachricht((char*)&keyLen, 2);
|
|
|
+ client->getMessage((char*)&keyLen, 2);
|
|
|
char* key = new char[keyLen];
|
|
|
- client->getNachricht(key, keyLen);
|
|
|
- foreground = new Klient();
|
|
|
- if (!foreground->verbinde(port, ip))
|
|
|
+ client->getMessage(key, keyLen);
|
|
|
+ foreground = new Client();
|
|
|
+ if (!foreground->connect(port, ip))
|
|
|
{
|
|
|
delete[] key;
|
|
|
return false;
|
|
|
}
|
|
|
- if (!foreground->sende((char*)&keyLen, 2))
|
|
|
+ if (!foreground->send((char*)&keyLen, 2))
|
|
|
{
|
|
|
delete[] key;
|
|
|
return false;
|
|
|
}
|
|
|
- if (!foreground->sende(key, keyLen))
|
|
|
+ if (!foreground->send(key, keyLen))
|
|
|
{
|
|
|
delete[] key;
|
|
|
return false;
|
|
|
}
|
|
|
- background = new Klient();
|
|
|
- if (!background->verbinde(port, ip))
|
|
|
+ background = new Client();
|
|
|
+ if (!background->connect(port, ip))
|
|
|
{
|
|
|
delete[] key;
|
|
|
foreground->release();
|
|
|
@@ -857,7 +856,7 @@ int FactoryClient::join(
|
|
|
background = 0;
|
|
|
return false;
|
|
|
}
|
|
|
- if (!background->sende((char*)&keyLen, 2))
|
|
|
+ if (!background->send((char*)&keyLen, 2))
|
|
|
{
|
|
|
delete[] key;
|
|
|
foreground->release();
|
|
|
@@ -866,7 +865,7 @@ int FactoryClient::join(
|
|
|
background = 0;
|
|
|
return false;
|
|
|
}
|
|
|
- if (!background->sende(key, keyLen))
|
|
|
+ if (!background->send(key, keyLen))
|
|
|
{
|
|
|
delete[] key;
|
|
|
foreground->release();
|
|
|
@@ -877,21 +876,21 @@ int FactoryClient::join(
|
|
|
}
|
|
|
delete[] key;
|
|
|
bool bg = 0;
|
|
|
- if (!foreground->sende((char*)&bg, 1))
|
|
|
+ if (!foreground->send((char*)&bg, 1))
|
|
|
{
|
|
|
delete[] key;
|
|
|
return 201;
|
|
|
}
|
|
|
foregroundReader = new NetworkReader(foreground);
|
|
|
bg = 1;
|
|
|
- if (!background->sende((char*)&bg, 1)) return 201;
|
|
|
+ if (!background->send((char*)&bg, 1)) return 201;
|
|
|
backgroundReader = new NetworkReader(background);
|
|
|
char res;
|
|
|
- foregroundReader->lese(&res, 1);
|
|
|
+ foregroundReader->read(&res, 1);
|
|
|
if (res != 1) return 403;
|
|
|
- backgroundReader->lese(&res, 1);
|
|
|
+ backgroundReader->read(&res, 1);
|
|
|
if (res != 1) return 403;
|
|
|
- client->trenne();
|
|
|
+ client->disconnect();
|
|
|
loadServerInfo();
|
|
|
return 200;
|
|
|
}
|
|
|
@@ -907,8 +906,8 @@ void FactoryClient::disconnect()
|
|
|
NetworkReader* bgReader = backgroundReader;
|
|
|
backgroundReader = 0;
|
|
|
foregroundReader = 0;
|
|
|
- if (foreground) foreground->trenne();
|
|
|
- if (background) background->trenne();
|
|
|
+ if (foreground) foreground->disconnect();
|
|
|
+ if (background) background->disconnect();
|
|
|
while (fgReaderUsage > 0 || bgReaderUsage > 0)
|
|
|
Sleep(100);
|
|
|
delete fgReader;
|
|
|
@@ -927,7 +926,7 @@ NetworkReader* FactoryClient::getNextForegroundMessage()
|
|
|
fgReaderUsage++;
|
|
|
if (!foreground) return 0;
|
|
|
if (!foreground->isConnected()) return 0;
|
|
|
- if (!foreground->hatNachricht(0)) return 0;
|
|
|
+ if (!foreground->hasMessage(0)) return 0;
|
|
|
return foregroundReader;
|
|
|
}
|
|
|
|
|
|
@@ -936,7 +935,7 @@ NetworkReader* FactoryClient::getNextBackgroundMessage()
|
|
|
bgReaderUsage++;
|
|
|
if (!background) return 0;
|
|
|
if (!background->isConnected()) return 0;
|
|
|
- if (!background->hatNachricht(0)) return 0;
|
|
|
+ if (!background->hasMessage(0)) return 0;
|
|
|
return backgroundReader;
|
|
|
}
|
|
|
|
|
|
@@ -953,10 +952,10 @@ void FactoryClient::sendPlayerAction(const char* data, unsigned short length)
|
|
|
if (!foreground) return;
|
|
|
cs.lock();
|
|
|
length += 1;
|
|
|
- foreground->sende((char*)&length, 2);
|
|
|
+ foreground->send((char*)&length, 2);
|
|
|
char msgId = 2;
|
|
|
- foreground->sende(&msgId, 1);
|
|
|
- foreground->sende((char*)data, length - 1);
|
|
|
+ foreground->send(&msgId, 1);
|
|
|
+ foreground->send((char*)data, length - 1);
|
|
|
cs.unlock();
|
|
|
}
|
|
|
|
|
|
@@ -965,13 +964,13 @@ void FactoryClient::sendPlayerFaceDirection(Vec3<float> dir)
|
|
|
if (!foreground) return;
|
|
|
cs.lock();
|
|
|
short length = 14;
|
|
|
- foreground->sende((char*)&length, 2);
|
|
|
+ foreground->send((char*)&length, 2);
|
|
|
char msgId = 2; // player message
|
|
|
- foreground->sende(&msgId, 1);
|
|
|
- foreground->sende(&msgId, 1); // set face direction
|
|
|
- foreground->sende((char*)&dir.x, 4);
|
|
|
- foreground->sende((char*)&dir.y, 4);
|
|
|
- foreground->sende((char*)&dir.z, 4);
|
|
|
+ foreground->send(&msgId, 1);
|
|
|
+ foreground->send(&msgId, 1); // set face direction
|
|
|
+ foreground->send((char*)&dir.x, 4);
|
|
|
+ foreground->send((char*)&dir.y, 4);
|
|
|
+ foreground->send((char*)&dir.z, 4);
|
|
|
cs.unlock();
|
|
|
}
|
|
|
|
|
|
@@ -980,12 +979,12 @@ void FactoryClient::sendPlayerMovement(int flags)
|
|
|
if (!foreground) return;
|
|
|
cs.lock();
|
|
|
short length = 6;
|
|
|
- foreground->sende((char*)&length, 2);
|
|
|
+ foreground->send((char*)&length, 2);
|
|
|
char msgId = 2; // player message
|
|
|
- foreground->sende(&msgId, 1);
|
|
|
+ foreground->send(&msgId, 1);
|
|
|
msgId = 10; // set movement
|
|
|
- foreground->sende(&msgId, 1);
|
|
|
- foreground->sende((char*)&flags, 4);
|
|
|
+ foreground->send(&msgId, 1);
|
|
|
+ foreground->send((char*)&flags, 4);
|
|
|
cs.unlock();
|
|
|
}
|
|
|
|
|
|
@@ -995,11 +994,11 @@ void FactoryClient::entityAPIRequest(
|
|
|
if (!foreground) return;
|
|
|
cs.lock();
|
|
|
length += 5;
|
|
|
- foreground->sende((char*)&length, 2);
|
|
|
+ foreground->send((char*)&length, 2);
|
|
|
char msgId = 3;
|
|
|
- foreground->sende(&msgId, 1);
|
|
|
- foreground->sende((char*)&entityId, 4);
|
|
|
- foreground->sende(message, length - 5);
|
|
|
+ foreground->send(&msgId, 1);
|
|
|
+ foreground->send((char*)&entityId, 4);
|
|
|
+ foreground->send(message, length - 5);
|
|
|
cs.unlock();
|
|
|
}
|
|
|
|
|
|
@@ -1009,14 +1008,14 @@ void FactoryClient::blockAPIRequest(
|
|
|
if (!foreground) return;
|
|
|
cs.lock();
|
|
|
length += 14;
|
|
|
- foreground->sende((char*)&length, 2);
|
|
|
+ foreground->send((char*)&length, 2);
|
|
|
char msgId = 1;
|
|
|
- foreground->sende(&msgId, 1);
|
|
|
- foreground->sende(&msgId, 1);
|
|
|
- foreground->sende((char*)&pos.x, 4);
|
|
|
- foreground->sende((char*)&pos.y, 4);
|
|
|
- foreground->sende((char*)&pos.z, 4);
|
|
|
- foreground->sende(message, length - 14);
|
|
|
+ foreground->send(&msgId, 1);
|
|
|
+ foreground->send(&msgId, 1);
|
|
|
+ foreground->send((char*)&pos.x, 4);
|
|
|
+ foreground->send((char*)&pos.y, 4);
|
|
|
+ foreground->send((char*)&pos.z, 4);
|
|
|
+ foreground->send(message, length - 14);
|
|
|
cs.unlock();
|
|
|
}
|
|
|
|
|
|
@@ -1026,31 +1025,31 @@ void FactoryClient::componentAPIRequest(
|
|
|
if (!foreground) return;
|
|
|
cs.lock();
|
|
|
short sum = length + addrLen * 4 + (addrLen > 2 ? 3 : 2);
|
|
|
- foreground->sende((char*)&sum, 2);
|
|
|
+ foreground->send((char*)&sum, 2);
|
|
|
if (addrLen > 2)
|
|
|
{
|
|
|
char msgId = 7; // dimension request
|
|
|
- foreground->sende(&msgId, 1);
|
|
|
- foreground->sende((char*)&address[0], 4); // dimension id
|
|
|
- msgId = 1; // block request
|
|
|
- foreground->sende(&msgId, 1);
|
|
|
- foreground->sende((char*)&address[1], 4); // position x
|
|
|
- foreground->sende((char*)&address[2], 4); // position y
|
|
|
- foreground->sende((char*)&address[3], 4); // position z
|
|
|
- msgId = 2; // component request
|
|
|
- foreground->sende(&msgId, 1);
|
|
|
- foreground->sende((char*)&address[4], 4); // component index
|
|
|
+ foreground->send(&msgId, 1);
|
|
|
+ foreground->send((char*)&address[0], 4); // dimension id
|
|
|
+ msgId = 1; // block request
|
|
|
+ foreground->send(&msgId, 1);
|
|
|
+ foreground->send((char*)&address[1], 4); // position x
|
|
|
+ foreground->send((char*)&address[2], 4); // position y
|
|
|
+ foreground->send((char*)&address[3], 4); // position z
|
|
|
+ msgId = 2; // component request
|
|
|
+ foreground->send(&msgId, 1);
|
|
|
+ foreground->send((char*)&address[4], 4); // component index
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
char msgId = 3; // entity request
|
|
|
- foreground->sende(&msgId, 1);
|
|
|
- foreground->sende((char*)&address[0], 4); // entity id
|
|
|
- msgId = 2; // component request
|
|
|
- foreground->sende(&msgId, 1);
|
|
|
- foreground->sende((char*)&address[1], 4); // component index
|
|
|
+ foreground->send(&msgId, 1);
|
|
|
+ foreground->send((char*)&address[0], 4); // entity id
|
|
|
+ msgId = 2; // component request
|
|
|
+ foreground->send(&msgId, 1);
|
|
|
+ foreground->send((char*)&address[1], 4); // component index
|
|
|
}
|
|
|
- foreground->sende(message, length);
|
|
|
+ foreground->send(message, length);
|
|
|
cs.unlock();
|
|
|
}
|
|
|
|
|
|
@@ -1060,33 +1059,33 @@ void FactoryClient::blockAPIRequest(
|
|
|
if (!foreground) return;
|
|
|
cs.lock();
|
|
|
length += 18;
|
|
|
- foreground->sende((char*)&length, 2);
|
|
|
+ foreground->send((char*)&length, 2);
|
|
|
char msgId = 7;
|
|
|
- foreground->sende(&msgId, 1);
|
|
|
- foreground->sende((char*)&dimensionId, 4);
|
|
|
+ foreground->send(&msgId, 1);
|
|
|
+ foreground->send((char*)&dimensionId, 4);
|
|
|
msgId = 1;
|
|
|
- foreground->sende(&msgId, 1);
|
|
|
- foreground->sende((char*)&pos.x, 4);
|
|
|
- foreground->sende((char*)&pos.y, 4);
|
|
|
- foreground->sende((char*)&pos.z, 4);
|
|
|
- foreground->sende(message, length - 18);
|
|
|
+ foreground->send(&msgId, 1);
|
|
|
+ foreground->send((char*)&pos.x, 4);
|
|
|
+ foreground->send((char*)&pos.y, 4);
|
|
|
+ foreground->send((char*)&pos.z, 4);
|
|
|
+ foreground->send(message, length - 18);
|
|
|
cs.unlock();
|
|
|
}
|
|
|
|
|
|
void FactoryClient::chunkAPIRequest(
|
|
|
- Punkt center, const char* message, unsigned short length)
|
|
|
+ Point center, const char* message, unsigned short length)
|
|
|
{
|
|
|
if (!foreground) return;
|
|
|
length += 10;
|
|
|
cs.lock();
|
|
|
- foreground->sende((char*)&length, 2);
|
|
|
+ foreground->send((char*)&length, 2);
|
|
|
char type = 1;
|
|
|
- foreground->sende(&type, 1);
|
|
|
+ foreground->send(&type, 1);
|
|
|
type = 0;
|
|
|
- foreground->sende(&type, 1);
|
|
|
- foreground->sende((char*)¢er.x, 4);
|
|
|
- foreground->sende((char*)¢er.y, 4);
|
|
|
- foreground->sende(message, length - 10);
|
|
|
+ foreground->send(&type, 1);
|
|
|
+ foreground->send((char*)¢er.x, 4);
|
|
|
+ foreground->send((char*)¢er.y, 4);
|
|
|
+ foreground->send(message, length - 10);
|
|
|
cs.unlock();
|
|
|
}
|
|
|
|
|
|
@@ -1096,10 +1095,10 @@ void FactoryClient::dimensionAPIRequest(
|
|
|
if (!foreground) return;
|
|
|
length += 1;
|
|
|
cs.lock();
|
|
|
- foreground->sende((char*)&length, 2);
|
|
|
+ foreground->send((char*)&length, 2);
|
|
|
char type = 1;
|
|
|
- foreground->sende(&type, 1);
|
|
|
- foreground->sende(message, length - 1);
|
|
|
+ foreground->send(&type, 1);
|
|
|
+ foreground->send(message, length - 1);
|
|
|
cs.unlock();
|
|
|
}
|
|
|
|
|
|
@@ -1111,25 +1110,25 @@ void FactoryClient::inventoryAPIRequest(
|
|
|
if (!foreground) return;
|
|
|
cs.lock();
|
|
|
length += target.isA() ? 6 : 18;
|
|
|
- foreground->sende((char*)&length, 2);
|
|
|
+ foreground->send((char*)&length, 2);
|
|
|
char msgId = 4;
|
|
|
- foreground->sende(&msgId, 1);
|
|
|
+ foreground->send(&msgId, 1);
|
|
|
bool isEntity = target.isA();
|
|
|
- foreground->sende((char*)&isEntity, 1);
|
|
|
+ foreground->send((char*)&isEntity, 1);
|
|
|
if (target.isA())
|
|
|
{
|
|
|
int id = target.getA();
|
|
|
- foreground->sende((char*)&id, 4);
|
|
|
+ foreground->send((char*)&id, 4);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
for (int i = 0; i < 4; i++)
|
|
|
{
|
|
|
int v = target.getB()[i];
|
|
|
- foreground->sende((char*)&v, 4);
|
|
|
+ foreground->send((char*)&v, 4);
|
|
|
}
|
|
|
}
|
|
|
- foreground->sende(message, length - (target.isA() ? 6 : 18));
|
|
|
+ foreground->send(message, length - (target.isA() ? 6 : 18));
|
|
|
cs.unlock();
|
|
|
}
|
|
|
|
|
|
@@ -1139,13 +1138,13 @@ void FactoryClient::uiRequest(
|
|
|
if (!foreground) return;
|
|
|
short nameLen = (short)dialogId.getLength();
|
|
|
length += nameLen + 3;
|
|
|
- foreground->sende((char*)&length, 2);
|
|
|
+ foreground->send((char*)&length, 2);
|
|
|
cs.lock();
|
|
|
char msgId = 8;
|
|
|
- foreground->sende(&msgId, 1);
|
|
|
- foreground->sende((char*)&nameLen, 2);
|
|
|
- foreground->sende(dialogId, nameLen);
|
|
|
- foreground->sende(message, length - nameLen - 3);
|
|
|
+ foreground->send(&msgId, 1);
|
|
|
+ foreground->send((char*)&nameLen, 2);
|
|
|
+ foreground->send(dialogId, nameLen);
|
|
|
+ foreground->send(message, length - nameLen - 3);
|
|
|
cs.unlock();
|
|
|
}
|
|
|
|
|
|
@@ -1154,10 +1153,10 @@ void FactoryClient::craftingUIMLRequest(int itemTypeId)
|
|
|
if (!foreground) return;
|
|
|
cs.lock();
|
|
|
short length = 5;
|
|
|
- foreground->sende((char*)&length, 2);
|
|
|
+ foreground->send((char*)&length, 2);
|
|
|
char msgId = 5;
|
|
|
- foreground->sende(&msgId, 1);
|
|
|
- foreground->sende((char*)&itemTypeId, 4);
|
|
|
+ foreground->send(&msgId, 1);
|
|
|
+ foreground->send((char*)&itemTypeId, 4);
|
|
|
cs.unlock();
|
|
|
}
|
|
|
|
|
|
@@ -1166,14 +1165,14 @@ void FactoryClient::sendChatMessage(Framework::Text message)
|
|
|
if (!background) return;
|
|
|
cs.lock();
|
|
|
short length = message.getLength() + 4;
|
|
|
- background->sende((char*)&length, 2);
|
|
|
+ background->send((char*)&length, 2);
|
|
|
char msgId = 6;
|
|
|
- background->sende(&msgId, 1);
|
|
|
+ background->send(&msgId, 1);
|
|
|
msgId = 0;
|
|
|
- background->sende(&msgId, 1);
|
|
|
+ background->send(&msgId, 1);
|
|
|
length = message.getLength();
|
|
|
- background->sende((char*)&length, 2);
|
|
|
- background->sende(message.getText(), message.getLength());
|
|
|
+ background->send((char*)&length, 2);
|
|
|
+ background->send(message.getText(), message.getLength());
|
|
|
cs.unlock();
|
|
|
}
|
|
|
|
|
|
@@ -1182,10 +1181,10 @@ void FactoryClient::chatAPIRequest(const char* data, unsigned short length)
|
|
|
if (!background) return;
|
|
|
cs.lock();
|
|
|
short totalLength = length + 1;
|
|
|
- background->sende((char*)&totalLength, 2);
|
|
|
+ background->send((char*)&totalLength, 2);
|
|
|
char msgId = 6;
|
|
|
- background->sende(&msgId, 1);
|
|
|
- background->sende(data, length);
|
|
|
+ background->send(&msgId, 1);
|
|
|
+ background->send(data, length);
|
|
|
cs.unlock();
|
|
|
}
|
|
|
|