mirror of
https://gitea.sffempire.ru/Kolyah35/minecraft-pe-0.6.1.git
synced 2026-03-30 12:03:30 +00:00
FEAT: Damage on server
This commit is contained in:
@@ -30,20 +30,29 @@ void signal_callback_handler(int signum) {
|
||||
int main(int numArguments, char* pszArgs[]) {
|
||||
ArgumentsSettings aSettings(numArguments, pszArgs);
|
||||
if(aSettings.getShowHelp()) {
|
||||
// TODO: Map with args and print it with std::cout and for loop
|
||||
// TODO: World size setting
|
||||
|
||||
ArgumentsSettings defaultSettings(0, NULL);
|
||||
|
||||
printf("Minecraft Pockect Edition Server %s\n", Common::getGameVersionString("").c_str());
|
||||
printf("-------------------------------------------------------\n");
|
||||
|
||||
printf("--cachepath - Path to where the server can store temp stuff (not sure if this is used) [default: \"%s\"]\n", defaultSettings.getCachePath().c_str());
|
||||
printf("--externalpath - The path to the place where the server should store the levels. [default: \"%s\"]\n", defaultSettings.getExternalPath().c_str());
|
||||
printf("--levelname - The name of the server [default: \"%s\"]\n", defaultSettings.getLevelName().c_str());
|
||||
printf("--gamemode - The name of the gamemode [default: \"%s\"]\n", defaultSettings.getGamemode().c_str());
|
||||
printf("--leveldir - The name of the server [default: \"%s\"]\n", defaultSettings.getLevelDir().c_str());
|
||||
printf("--help - Shows this message.\n");
|
||||
printf("--port - The port to run the server on. [default: %d]\n", defaultSettings.getPort());
|
||||
printf("--serverkey - The key that the server should use for API calls. [default: \"%s\"]\n", defaultSettings.getServerKey().c_str());
|
||||
|
||||
printf("-------------------------------------------------------\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
printf("Level Name: %s\n", aSettings.getLevelName().c_str());
|
||||
|
||||
AppContext appContext;
|
||||
appContext.platform = new AppPlatform();
|
||||
App* app = new MAIN_CLASS();
|
||||
|
||||
@@ -352,6 +352,7 @@ void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& source, AddItemE
|
||||
}
|
||||
|
||||
void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& source, TakeItemEntityPacket* packet) {
|
||||
printf("TakeItemEntityPacket \n");
|
||||
if (!level) return;
|
||||
|
||||
Entity* e = level->getEntity(packet->itemId);
|
||||
@@ -852,6 +853,7 @@ void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& source, SetHealt
|
||||
if (!level || !minecraft->player)
|
||||
return;
|
||||
|
||||
printf("SetHealthPacket \n");
|
||||
minecraft->player->hurtTo(packet->health);
|
||||
}
|
||||
|
||||
|
||||
@@ -415,13 +415,15 @@ void ServerSideNetworkHandler::handle(const RakNet::RakNetGUID& source, MovePlay
|
||||
(packet->z - entity->z) * (packet->z - entity->z));
|
||||
float speed = vectorDist / (minecraft->getTicks() - player->getLastMoveTicks());
|
||||
|
||||
if (speed < 2.5f) {
|
||||
// TODO: Replace with Entity::move()
|
||||
// if (speed < 2.5f) {
|
||||
entity->xd = entity->yd = entity->zd = 0;
|
||||
entity->lerpTo(packet->x, packet->y, packet->z, packet->yRot, packet->xRot, 3);
|
||||
entity->move(packet->x - entity->x, packet->y - entity->y, packet->z - entity->z);
|
||||
// entity->lerpTo(packet->x, packet->y, packet->z, packet->yRot, packet->xRot, 3);
|
||||
|
||||
// broadcast this packet to other clients
|
||||
redistributePacket(packet, source);
|
||||
}
|
||||
//}
|
||||
|
||||
player->setLastMoveTicks(minecraft->getTicks());
|
||||
}
|
||||
@@ -459,7 +461,7 @@ void ServerSideNetworkHandler::handle(const RakNet::RakNetGUID& source, RemoveBl
|
||||
}
|
||||
}
|
||||
|
||||
//oldTile->spawnResources(level, x, y, z, data, 1); //@todo
|
||||
oldTile->spawnResources(level, x, y, z, data, 1); //@todo
|
||||
oldTile->playerDestroy(level, player, x, y, z, data);
|
||||
}
|
||||
|
||||
@@ -934,19 +936,19 @@ void ServerSideNetworkHandler::handle(const RakNet::RakNetGUID& source, Containe
|
||||
|
||||
void ServerSideNetworkHandler::handle( const RakNet::RakNetGUID& source, SetHealthPacket* packet )
|
||||
{
|
||||
LOGI("SetHealthPacket\n");
|
||||
LOGI("net idi nahui\n");
|
||||
|
||||
for (unsigned int i = 0; i < level->players.size(); ++i) {
|
||||
Player* p = level->players[i];
|
||||
if (p->owner == source) {
|
||||
if (packet->health <= -32) {
|
||||
int diff = packet->health - SetHealthPacket::HEALTH_MODIFY_OFFSET;
|
||||
if (diff > 0) p->hurt(NULL, diff);
|
||||
else if (diff < 0) p->heal(-diff);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
// for (unsigned int i = 0; i < level->players.size(); ++i) {
|
||||
// Player* p = level->players[i];
|
||||
// if (p->owner == source) {
|
||||
// if (packet->health <= -32) {
|
||||
// int diff = packet->health - SetHealthPacket::HEALTH_MODIFY_OFFSET;
|
||||
// if (diff > 0) p->hurt(NULL, diff);
|
||||
// else if (diff < 0) p->heal(-diff);
|
||||
// }
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
void ServerSideNetworkHandler::handle( const RakNet::RakNetGUID& source, SignUpdatePacket* packet ) {
|
||||
|
||||
@@ -17,6 +17,11 @@ ArgumentsSettings::ArgumentsSettings(int numArguments, char** arguments)
|
||||
levelName = std::string(arguments[a+1]);
|
||||
a++; // Skip the next argument since it's part of this one.
|
||||
}
|
||||
} else if(strcmp(arguments[a], "--gamemode") == 0) {
|
||||
if(a + 1 < numArguments) {
|
||||
gamemode = std::string(arguments[a+1]);
|
||||
a++; // Skip the next argument since it's part of this one.
|
||||
}
|
||||
} else if(strcmp(arguments[a], "--leveldir") == 0) {
|
||||
if(a + 1 < numArguments) {
|
||||
levelDir = std::string(arguments[a+1]);
|
||||
@@ -51,6 +56,9 @@ std::string ArgumentsSettings::getServerKey() {
|
||||
std::string ArgumentsSettings::getCachePath() {
|
||||
return cachePath;
|
||||
}
|
||||
std::string ArgumentsSettings::getGamemode() {
|
||||
return gamemode;
|
||||
}
|
||||
std::string ArgumentsSettings::getLevelDir() {
|
||||
return levelDir;
|
||||
}
|
||||
|
||||
@@ -4,20 +4,27 @@
|
||||
class ArgumentsSettings {
|
||||
public:
|
||||
ArgumentsSettings(int numArguments, char** arguments);
|
||||
|
||||
std::string getExternalPath();
|
||||
std::string getLevelName();
|
||||
std::string getServerKey();
|
||||
std::string getCachePath();
|
||||
std::string getLevelDir();
|
||||
std::string getGamemode();
|
||||
|
||||
bool getShowHelp();
|
||||
|
||||
int getPort();
|
||||
private:
|
||||
std::string cachePath;
|
||||
std::string externalPath;
|
||||
std::string levelName;
|
||||
std::string gamemode;
|
||||
std::string levelDir;
|
||||
std::string serverKey;
|
||||
|
||||
bool showHelp;
|
||||
|
||||
int port;
|
||||
};
|
||||
|
||||
|
||||
@@ -72,6 +72,7 @@ void ServerPlayer::take( Entity* e, int orgCount ) {
|
||||
TakeItemEntityPacket packet(e->entityId, entityId);
|
||||
// SendInventoryPacket packet(this, false);
|
||||
_mc->raknetInstance->send(packet);
|
||||
printf("TakeItemEntityPacket \n");
|
||||
|
||||
LOGI("Inventory:\n");
|
||||
for (int i = 0; i < inventory->numLinkedSlots; i++) {
|
||||
|
||||
Reference in New Issue
Block a user