Skip to content

Commit

Permalink
Fixed default admin password behavior, crouching animation
Browse files Browse the repository at this point in the history
  • Loading branch information
fador committed Mar 10, 2013
1 parent ede3f23 commit ee0f06c
Show file tree
Hide file tree
Showing 10 changed files with 107 additions and 31 deletions.
7 changes: 4 additions & 3 deletions files/config.cfg
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ net.port = 25565;


# Server administrator authentication password # Server administrator authentication password
# Used for core commands like shutdown and loadplugin # Used for core commands like shutdown and loadplugin
# NOTE: This is not yet used for anything. Work in progress. # using "/auth password" will make you an admin
system.admin.password = "password"; # NOTE: default "CHANGEME" is ignored, so change this only if you want to use it.
system.admin.password = "CHANGEME";


# 0 = Normal Map # 0 = Normal Map
# 1 = Nether Map # 1 = Nether Map
Expand All @@ -71,7 +72,7 @@ strings.server_full = "Server is currently full";
# Physics options (water/lava) # Physics options (water/lava)
system.physics.enabled = false; system.physics.enabled = false;


# Redstone options # Redstone options (EXPERIMENTAL)
system.redstone.enabled = true; system.redstone.enabled = true;


# Enable PvP ? # Enable PvP ?
Expand Down
29 changes: 28 additions & 1 deletion include/metadata.h
Original file line number Original file line Diff line number Diff line change
@@ -1,5 +1,32 @@
/*
Copyright (c) 2013, The Mineserver Project
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the The Mineserver Project nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef _METAINFO_H #ifndef _METAINFO_H
#define _MATAINFO_H #define _METAINFO_H


#include <vector> #include <vector>
#include "packets.h" #include "packets.h"
Expand Down
4 changes: 2 additions & 2 deletions include/protocol.h
Original file line number Original file line Diff line number Diff line change
@@ -1,5 +1,5 @@
/* /*
Copyright (c) 2012, The Mineserver Project Copyright (c) 2013, The Mineserver Project
All rights reserved. All rights reserved.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -306,7 +306,7 @@ class Protocol
return ret; return ret;
} }


static Packet updateHealth(int health, int food=20) static Packet updateHealth(int health, int food=15)
{ {
Packet ret; Packet ret;
ret << (int8_t)PACKET_UPDATE_HEALTH << (int16_t)health << (int16_t)food << (float)5.0; ret << (int8_t)PACKET_UPDATE_HEALTH << (int16_t)health << (int16_t)food << (float)5.0;
Expand Down
2 changes: 1 addition & 1 deletion plugins/commands/commands.cpp
Original file line number Original file line Diff line number Diff line change
@@ -1,5 +1,5 @@
/* /*
Copyright (c) 2011, The Mineserver Project Copyright (c) 2013, The Mineserver Project
All rights reserved. All rights reserved.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
Expand Down
31 changes: 20 additions & 11 deletions plugins/flatpermissions/flatpermissions.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ g++ -shared flatpermissions.o -o flatpermissions.so
*/ */
/* /*
Copyright (c) 2010, The Mineserver Project Copyright (c) 2013, The Mineserver Project
All rights reserved. All rights reserved.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -56,26 +56,35 @@ void loginPost(const char* userIn){
std::ifstream file; std::ifstream file;
file.open("permissions.txt", std::ios::in); file.open("permissions.txt", std::ios::in);
std::string line; std::string line;
mineserver->logger.log(6, "plugin.flatpermissions", "opening permissions.txt!"); if(file.is_open())
if(file.is_open()){ {
mineserver->logger.log(6, "plugin.flatpermissions", "opened permissions.txt!"); while(file.good())
while(file.good()){ {
std::string msg; std::string msg;
std::getline(file, msg); std::getline(file, msg);
if(msg.size()>1){ if(msg.size()>1)
{
std::string name, rank; std::string name, rank;
std::istringstream line(msg); std::istringstream line(msg);
std::getline(line,name,':'); std::getline(line,name,':');
std::getline(line,rank); std::getline(line,rank);
if(name.compare(std::string(userIn))==0){ if(name.compare(std::string(userIn))==0)
{
std::transform(rank.begin(), rank.end(), rank.begin(), ::tolower); std::transform(rank.begin(), rank.end(), rank.begin(), ::tolower);
if(rank.compare("admin")==0 || rank.compare("admins")==0){ if(rank.compare("admin")==0 || rank.compare("admins")==0)
{
mineserver->permissions.setAdmin(userIn); mineserver->permissions.setAdmin(userIn);
}else if(rank.compare("op")==0 || rank.compare("ops")==0){ }
else if(rank.compare("op")==0 || rank.compare("ops")==0)
{
mineserver->permissions.setOp(userIn); mineserver->permissions.setOp(userIn);
}else if(rank.compare("member")==0 || rank.compare("members")==0){ }
else if(rank.compare("member")==0 || rank.compare("members")==0)
{
mineserver->permissions.setMember(userIn); mineserver->permissions.setMember(userIn);
}else{ }
else
{
mineserver->permissions.setGuest(userIn); mineserver->permissions.setGuest(userIn);
} }
break; break;
Expand Down
8 changes: 4 additions & 4 deletions src/chat.cpp
Original file line number Original file line Diff line number Diff line change
@@ -1,5 +1,5 @@
/* /*
Copyright (c) 2012, The Mineserver Project Copyright (c) 2013, The Mineserver Project
All rights reserved. All rights reserved.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -173,15 +173,15 @@ void Chat::handleCommand(User* user, std::string msg, const std::string& timeSta
std::string command = cmd[0]; std::string command = cmd[0];
cmd.pop_front(); cmd.pop_front();


//Converting to char* array for plugins
char** param = new char *[cmd.size()]; char** param = new char *[cmd.size()];

for (uint32_t i = 0; i < cmd.size(); i++) for (uint32_t i = 0; i < cmd.size(); i++)
{ {
param[i] = (char*)cmd[i].c_str(); param[i] = (char*)cmd[i].c_str();
} }


// If hardcoded auth command! // If hardcoded auth command, ignore default password "CHANGEME"
if (command == "auth" && param[0] == ServerInstance->config()->sData("system.admin.password")) if (command == "auth" && cmd[0] != "CHANGEME" && cmd[0] == ServerInstance->config()->sData("system.admin.password"))
{ {
user->serverAdmin = true; user->serverAdmin = true;
SET_ADMIN(user->permissions); SET_ADMIN(user->permissions);
Expand Down
15 changes: 10 additions & 5 deletions src/items/food.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "packets.h" #include "packets.h"
#include "protocol.h" #include "protocol.h"
#include "map.h" #include "map.h"
#include "metadata.h"


bool ItemFood::affectedItem(int item) const bool ItemFood::affectedItem(int item) const
{ {
Expand Down Expand Up @@ -50,21 +51,25 @@ void ItemFood::onRightClick(User* user, Item* item)
healammount = 4; healammount = 4;
break; break;
} }

int newhealth = user->health + healammount; int newhealth = user->health + healammount;
if (newhealth > 20) if (newhealth > 20)
{ {
newhealth = 20; newhealth = 20;
} }

user->sethealth(newhealth); user->sethealth(newhealth);


//ToDo: fix animation

//Accept eating //Accept eating
user->buffer << Protocol::entityStatus(user->UID, 9); user->buffer << Protocol::entityStatus(user->UID, 9);


//Eating animation (should work but doesn't) //Eating animation
Packet pkt = Protocol::animation(user->UID, 5); MetaData meta;
MetaDataElemByte *element = new MetaDataElemByte(0,0x10);
meta.set(element);
Packet pkt = Protocol::animation(user->UID,5);
//pkt << Protocol::entityMetadata(user->UID, meta);
//ToDo: add timer stop animation


sChunk* chunk = ServerInstance->map(user->pos.map)->getChunk(blockToChunk((int32_t)user->pos.x), blockToChunk((int32_t)user->pos.z)); sChunk* chunk = ServerInstance->map(user->pos.map)->getChunk(blockToChunk((int32_t)user->pos.x), blockToChunk((int32_t)user->pos.z));
if (chunk != NULL) if (chunk != NULL)
Expand Down
27 changes: 27 additions & 0 deletions src/metadata.cpp
Original file line number Original file line Diff line number Diff line change
@@ -1,3 +1,30 @@
/*
Copyright (c) 2013, The Mineserver Project
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the The Mineserver Project nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#include "metadata.h" #include "metadata.h"


void MetaDataElemByte::output(Packet& p) const void MetaDataElemByte::output(Packet& p) const
Expand Down
12 changes: 9 additions & 3 deletions src/packets.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -368,6 +368,8 @@ int PacketHandler::entity_crouch(User* user)
{ {
int32_t EID; int32_t EID;
int8_t action; int8_t action;
MetaData meta;
MetaDataElemByte *element;


user->buffer >> EID >> action; user->buffer >> EID >> action;
Packet pkt; Packet pkt;
Expand All @@ -377,13 +379,17 @@ int PacketHandler::entity_crouch(User* user)
switch(action) switch(action)
{ {
//Crouch //Crouch
case 1: case 1:
pkt << Protocol::animation(user->UID, 104); element = new MetaDataElemByte(0,0x02);
meta.set(element);
pkt << Protocol::animation(user->UID, 104) << Protocol::entityMetadata(user->UID,meta);
packetData = true; packetData = true;
break; break;
//Uncrouch //Uncrouch
case 2: case 2:
pkt << Protocol::animation(user->UID, 105); element = new MetaDataElemByte(0,0x00);
meta.set(element);
pkt << Protocol::animation(user->UID, 105) << Protocol::entityMetadata(user->UID,meta);
packetData = true; packetData = true;
break; break;
default: default:
Expand Down
3 changes: 2 additions & 1 deletion src/user.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -1148,11 +1148,12 @@ void User::checkEnvironmentDamage()
uint8_t type = 0, meta = 0; uint8_t type = 0, meta = 0;


int16_t d = 0; int16_t d = 0;

/*
if (type == BLOCK_CACTUS && LOADBLOCK(pos.x, yVal, pos.z)) if (type == BLOCK_CACTUS && LOADBLOCK(pos.x, yVal, pos.z))
{ {
d = 1; d = 1;
} }
*/


const double xbit = pos.x - std::floor(pos.x); const double xbit = pos.x - std::floor(pos.x);
const double zbit = pos.z - std::floor(pos.z); const double zbit = pos.z - std::floor(pos.z);
Expand Down

0 comments on commit ee0f06c

Please sign in to comment.