|
@@ -167,15 +167,6 @@ int FactoryCraftServer::getUnencryptedPort() const
|
|
|
return server->getPort();
|
|
|
}
|
|
|
|
|
|
-char* randomKey(int& len)
|
|
|
-{
|
|
|
- len = 1024 + (int)(((double)rand() / RAND_MAX - 0.5) * 512);
|
|
|
- char* key = new char[len];
|
|
|
- for (int i = 0; i < len; i++)
|
|
|
- key[i] = (char)(((double)rand() / RAND_MAX) * 256);
|
|
|
- return key;
|
|
|
-}
|
|
|
-
|
|
|
// Inhalt der LSKlient aus LoginServer.h
|
|
|
// Konstruktor
|
|
|
FCKlient::FCKlient(SSLSKlient* klient, FactoryCraftServer* ls)
|
|
@@ -278,51 +269,39 @@ void FCKlient::thread()
|
|
|
{
|
|
|
case 1: // Klient identifikation
|
|
|
{
|
|
|
- int accountId = 0;
|
|
|
- klient->getNachricht((char*)&accountId, 4);
|
|
|
- unsigned char secretLength = 0;
|
|
|
- klient->getNachricht((char*)&secretLength, 1);
|
|
|
- char* secret = new char[secretLength + 1];
|
|
|
- klient->getNachricht(secret, (int)secretLength);
|
|
|
- secret[secretLength] = 0;
|
|
|
- Text data = "{\"account_id\":";
|
|
|
- data += accountId;
|
|
|
- data += ", \"secret\": \"";
|
|
|
- data += secret;
|
|
|
- data += "\"}";
|
|
|
- bool ok = false;
|
|
|
- HTTP::Answer* answer = HTTP::PostRequest("/game_client/api/verify_client.php", "koljastrohm-games.com", data, "application/json", 443, true).execute();
|
|
|
- if (answer->getStatusCode() == 200)
|
|
|
+ char len;
|
|
|
+ klient->getNachricht(&len, 1);
|
|
|
+ char* name = new char[len + 1];
|
|
|
+ klient->getNachricht(name, len);
|
|
|
+ name[(int)len] = 0;
|
|
|
+ unsigned short sLen;
|
|
|
+ klient->getNachricht((char*)&sLen, 2);
|
|
|
+ char* secret = new char[sLen + 1];
|
|
|
+ klient->getNachricht(secret, sLen);
|
|
|
+ secret[sLen] = 0;
|
|
|
+ if (!Game::INSTANCE->checkPlayer(name, secret))
|
|
|
{
|
|
|
- JSON::JSONObject obj(answer->getData());
|
|
|
- if (obj.hasValue("verified"))
|
|
|
- {
|
|
|
- JSON::JSONValue* value = obj.getValue("verified");
|
|
|
- if (value->getType() == JSON::JSONType::BOOLEAN)
|
|
|
- {
|
|
|
- if (((JSON::JSONBool*)value)->getBool())
|
|
|
- {
|
|
|
- this->accountId = accountId;
|
|
|
- if (zGameClient)
|
|
|
- {
|
|
|
- zGameClient->logout();
|
|
|
- zGameClient = (GameClient*)zGameClient->release();
|
|
|
- }
|
|
|
- klient->sende("\1", 1);
|
|
|
- klient->sende((char*)&authKeyLen, 4);
|
|
|
- klient->sende(authKey, authKeyLen);
|
|
|
- int port = ls->getUnencryptedPort();
|
|
|
- klient->sende((char*)&port, 4);
|
|
|
- ok = true;
|
|
|
- }
|
|
|
- }
|
|
|
- value->release();
|
|
|
- }
|
|
|
- }
|
|
|
- answer->release();
|
|
|
- delete[]secret;
|
|
|
- if (!ok)
|
|
|
klient->sende("\0", 1);
|
|
|
+ delete[] name;
|
|
|
+ delete[] secret;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ if (!Game::INSTANCE->existsPlayer(name))
|
|
|
+ {
|
|
|
+ Text secret = Game::INSTANCE->createPlayer(name);
|
|
|
+ klient->sende("\2", 1);
|
|
|
+ short len = (short)secret.getLength();
|
|
|
+ klient->sende((char*)&len, 2);
|
|
|
+ klient->sende(secret.getText(), len);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ klient->sende("\1", 1);
|
|
|
+ }
|
|
|
+ klient->sende((char*)&authKeyLen, 4);
|
|
|
+ klient->sende(authKey, authKeyLen);
|
|
|
+ delete[] name;
|
|
|
+ delete[] secret;
|
|
|
break;
|
|
|
}
|
|
|
case 2: // Verbindungsende
|
|
@@ -334,6 +313,30 @@ void FCKlient::thread()
|
|
|
}
|
|
|
klient->sende("\1", 1);
|
|
|
break;
|
|
|
+ case 3: // ping
|
|
|
+ klient->sende("\1", 1);
|
|
|
+ break;
|
|
|
+ case 4: // check player name valid
|
|
|
+ {
|
|
|
+ klient->sende("\1", 1);
|
|
|
+ char len;
|
|
|
+ klient->getNachricht(&len, 1);
|
|
|
+ char* name = new char[len + 1];
|
|
|
+ klient->getNachricht(name, len);
|
|
|
+ name[(int)len] = 0;
|
|
|
+ short sLen;
|
|
|
+ klient->getNachricht((char*)&sLen, 2);
|
|
|
+ char* secret = new char[sLen + 1];
|
|
|
+ klient->getNachricht(secret, sLen);
|
|
|
+ secret[sLen] = 0;
|
|
|
+ char res = 0;
|
|
|
+ if (Game::INSTANCE->checkPlayer(name, secret))
|
|
|
+ res = 1;
|
|
|
+ klient->sende(&res, 1);
|
|
|
+ delete[] name;
|
|
|
+ delete[] secret;
|
|
|
+ break;
|
|
|
+ }
|
|
|
default:
|
|
|
br = 1;
|
|
|
break;
|
|
@@ -371,4 +374,5 @@ bool FCKlient::matchAuthKey(char* key, int len) const
|
|
|
return 0;
|
|
|
}
|
|
|
return 1;
|
|
|
+ an account to play
|
|
|
}
|