forked from oerkki/voxelands
use hard tabs
This commit is contained in:
parent
5334cabad8
commit
0b25fee660
|
@ -42,10 +42,8 @@ const uint64_t PRIV_BUILD = 1; // Can build - i.e. modify the world
|
|||
const uint64_t PRIV_TELEPORT = 2; // Can teleport
|
||||
const uint64_t PRIV_SETTIME = 4; // Can set the time
|
||||
const uint64_t PRIV_PRIVS = 8; // Can grant and revoke privileges
|
||||
const uint64_t PRIV_SERVER = 16; // Can manage the server (e.g. shutodwn
|
||||
// ,settings)
|
||||
const uint64_t PRIV_SHOUT = 32; // Can broadcast chat messages to all
|
||||
// players
|
||||
const uint64_t PRIV_SERVER = 16; // Can manage the server (e.g. shutodwn, settings)
|
||||
const uint64_t PRIV_SHOUT = 32; // Can broadcast chat messages to all players
|
||||
const uint64_t PRIV_BAN = 64; // Can ban players
|
||||
|
||||
// Default privileges - these can be overriden for new players using the
|
||||
|
|
166
src/base64.cpp
166
src/base64.cpp
|
@ -1,41 +1,40 @@
|
|||
/*
|
||||
base64.cpp and base64.h
|
||||
base64.cpp and base64.h
|
||||
|
||||
Copyright (C) 2004-2008 René Nyffenegger
|
||||
Copyright (C) 2004-2008 René Nyffenegger
|
||||
|
||||
This source code is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the author be held liable for any damages
|
||||
arising from the use of this software.
|
||||
This source code is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the author be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this source code must not be misrepresented; you must not
|
||||
claim that you wrote the original source code. If you use this source code
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
1. The origin of this source code must not be misrepresented; you must not
|
||||
claim that you wrote the original source code. If you use this source code
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original source code.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original source code.
|
||||
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
René Nyffenegger rene.nyffenegger@adp-gmbh.ch
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
René Nyffenegger rene.nyffenegger@adp-gmbh.ch
|
||||
*/
|
||||
|
||||
#include "base64.h"
|
||||
#include <iostream>
|
||||
|
||||
static const std::string base64_chars =
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
"abcdefghijklmnopqrstuvwxyz"
|
||||
"0123456789+/";
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
"abcdefghijklmnopqrstuvwxyz"
|
||||
"0123456789+/";
|
||||
|
||||
|
||||
static inline bool is_base64(unsigned char c) {
|
||||
return (isalnum(c) || (c == '+') || (c == '/'));
|
||||
return (isalnum(c) || (c == '+') || (c == '/'));
|
||||
}
|
||||
|
||||
bool base64_is_valid(std::string const& s)
|
||||
|
@ -48,86 +47,81 @@ bool base64_is_valid(std::string const& s)
|
|||
}
|
||||
|
||||
std::string base64_encode(unsigned char const* bytes_to_encode, unsigned int in_len) {
|
||||
std::string ret;
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
unsigned char char_array_3[3];
|
||||
unsigned char char_array_4[4];
|
||||
std::string ret;
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
unsigned char char_array_3[3];
|
||||
unsigned char char_array_4[4];
|
||||
|
||||
while (in_len--) {
|
||||
char_array_3[i++] = *(bytes_to_encode++);
|
||||
if (i == 3) {
|
||||
char_array_4[0] = (char_array_3[0] & 0xfc) >> 2;
|
||||
char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4);
|
||||
char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6);
|
||||
char_array_4[3] = char_array_3[2] & 0x3f;
|
||||
while (in_len--) {
|
||||
char_array_3[i++] = *(bytes_to_encode++);
|
||||
if (i == 3) {
|
||||
char_array_4[0] = (char_array_3[0] & 0xfc) >> 2;
|
||||
char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4);
|
||||
char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6);
|
||||
char_array_4[3] = char_array_3[2] & 0x3f;
|
||||
|
||||
for(i = 0; (i <4) ; i++)
|
||||
ret += base64_chars[char_array_4[i]];
|
||||
i = 0;
|
||||
}
|
||||
}
|
||||
for(i = 0; (i <4) ; i++)
|
||||
ret += base64_chars[char_array_4[i]];
|
||||
i = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (i)
|
||||
{
|
||||
for(j = i; j < 3; j++)
|
||||
char_array_3[j] = '\0';
|
||||
if (i)
|
||||
{
|
||||
for(j = i; j < 3; j++)
|
||||
char_array_3[j] = '\0';
|
||||
|
||||
char_array_4[0] = (char_array_3[0] & 0xfc) >> 2;
|
||||
char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4);
|
||||
char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6);
|
||||
char_array_4[3] = char_array_3[2] & 0x3f;
|
||||
char_array_4[0] = (char_array_3[0] & 0xfc) >> 2;
|
||||
char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4);
|
||||
char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6);
|
||||
char_array_4[3] = char_array_3[2] & 0x3f;
|
||||
|
||||
for (j = 0; (j < i + 1); j++)
|
||||
ret += base64_chars[char_array_4[j]];
|
||||
|
||||
// Don't pad it with =
|
||||
/*while((i++ < 3))
|
||||
ret += '=';*/
|
||||
|
||||
}
|
||||
|
||||
return ret;
|
||||
for (j = 0; (j < i + 1); j++)
|
||||
ret += base64_chars[char_array_4[j]];
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::string base64_decode(std::string const& encoded_string) {
|
||||
int in_len = encoded_string.size();
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
int in_ = 0;
|
||||
unsigned char char_array_4[4], char_array_3[3];
|
||||
std::string ret;
|
||||
int in_len = encoded_string.size();
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
int in_ = 0;
|
||||
unsigned char char_array_4[4], char_array_3[3];
|
||||
std::string ret;
|
||||
|
||||
while (in_len-- && ( encoded_string[in_] != '=') && is_base64(encoded_string[in_])) {
|
||||
char_array_4[i++] = encoded_string[in_]; in_++;
|
||||
if (i ==4) {
|
||||
for (i = 0; i <4; i++)
|
||||
char_array_4[i] = base64_chars.find(char_array_4[i]);
|
||||
while (in_len-- && ( encoded_string[in_] != '=') && is_base64(encoded_string[in_])) {
|
||||
char_array_4[i++] = encoded_string[in_]; in_++;
|
||||
if (i ==4) {
|
||||
for (i = 0; i <4; i++)
|
||||
char_array_4[i] = base64_chars.find(char_array_4[i]);
|
||||
|
||||
char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
|
||||
char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
|
||||
char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
|
||||
char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
|
||||
char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
|
||||
char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
|
||||
|
||||
for (i = 0; (i < 3); i++)
|
||||
ret += char_array_3[i];
|
||||
i = 0;
|
||||
}
|
||||
}
|
||||
for (i = 0; (i < 3); i++)
|
||||
ret += char_array_3[i];
|
||||
i = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (i) {
|
||||
for (j = i; j <4; j++)
|
||||
char_array_4[j] = 0;
|
||||
if (i) {
|
||||
for (j = i; j <4; j++)
|
||||
char_array_4[j] = 0;
|
||||
|
||||
for (j = 0; j <4; j++)
|
||||
char_array_4[j] = base64_chars.find(char_array_4[j]);
|
||||
for (j = 0; j <4; j++)
|
||||
char_array_4[j] = base64_chars.find(char_array_4[j]);
|
||||
|
||||
char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
|
||||
char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
|
||||
char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
|
||||
char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
|
||||
char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
|
||||
char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
|
||||
|
||||
for (j = 0; (j < i - 1); j++) ret += char_array_3[j];
|
||||
}
|
||||
for (j = 0; (j < i - 1); j++) ret += char_array_3[j];
|
||||
}
|
||||
|
||||
return ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,15 +31,13 @@
|
|||
#include "mapnode.h"
|
||||
|
||||
/*
|
||||
|
||||
Some planning
|
||||
-------------
|
||||
|
||||
* Some planning
|
||||
*
|
||||
* Client receives a network packet with information of added objects
|
||||
in it
|
||||
* in it
|
||||
*
|
||||
* Client supplies the information to its ClientEnvironment
|
||||
* The environment adds the specified objects to itself
|
||||
|
||||
*/
|
||||
|
||||
class ClientEnvironment;
|
||||
|
|
|
@ -38,8 +38,7 @@
|
|||
|
||||
#define PROTOCOL_ID 0x4f457403
|
||||
|
||||
#define PASSWORD_SIZE 28 // Maximum password length. Allows for
|
||||
// base64-encoded SHA-1 (27+\0).
|
||||
#define PASSWORD_SIZE 28 // Maximum password length. Allows for base64-encoded SHA-1 (27+\0).
|
||||
|
||||
enum ToClientCommand
|
||||
{
|
||||
|
|
|
@ -238,31 +238,35 @@ checking at all.
|
|||
#define TYPE_ORIGINAL 1
|
||||
#define ORIGINAL_HEADER_SIZE 1
|
||||
/*
|
||||
SPLIT: These are sequences of packets forming one bigger piece of
|
||||
data.
|
||||
- When processed and all the packet_nums 0...packet_count-1 are
|
||||
present (this should be buffered), the resulting data shall be
|
||||
directly handed to the user.
|
||||
- If the data fails to come up in a reasonable time, the buffer shall
|
||||
be silently discarded.
|
||||
- These can be sent as-is or atop of a RELIABLE packet stream.
|
||||
Header (7 bytes):
|
||||
[0] u8 type
|
||||
[1] u16 seqnum
|
||||
[3] u16 chunk_count
|
||||
[5] u16 chunk_num
|
||||
* SPLIT: These are sequences of packets forming one bigger piece of
|
||||
* data.
|
||||
*
|
||||
* When processed and all the packet_nums 0...packet_count-1 are
|
||||
* present (this should be buffered), the resulting data shall be
|
||||
* directly handed to the user.
|
||||
*
|
||||
* If the data fails to come up in a reasonable time, the buffer shall
|
||||
* be silently discarded.
|
||||
*
|
||||
* These can be sent as-is or atop of a RELIABLE packet stream.
|
||||
* Header (7 bytes):
|
||||
* [0] u8 type
|
||||
* [1] u16 seqnum
|
||||
* [3] u16 chunk_count
|
||||
* [5] u16 chunk_num
|
||||
*/
|
||||
#define TYPE_SPLIT 2
|
||||
/*
|
||||
RELIABLE: Delivery of all RELIABLE packets shall be forced by ACKs,
|
||||
and they shall be delivered in the same order as sent. This is done
|
||||
with a buffer in the receiving and transmitting end.
|
||||
- When this is processed, the contents of each packet is recursively
|
||||
processed as packets.
|
||||
Header (3 bytes):
|
||||
[0] u8 type
|
||||
[1] u16 seqnum
|
||||
|
||||
* RELIABLE: Delivery of all RELIABLE packets shall be forced by ACKs,
|
||||
* and they shall be delivered in the same order as sent. This is done
|
||||
* with a buffer in the receiving and transmitting end.
|
||||
*
|
||||
* When this is processed, the contents of each packet is recursively
|
||||
* processed as packets.
|
||||
*
|
||||
* Header (3 bytes):
|
||||
* [0] u8 type
|
||||
* [1] u16 seqnum
|
||||
*/
|
||||
#define TYPE_RELIABLE 3
|
||||
#define RELIABLE_HEADER_SIZE 3
|
||||
|
|
|
@ -156,8 +156,8 @@ struct MobFeatures {
|
|||
/*
|
||||
Gets list of node boxes
|
||||
*/
|
||||
std::vector<NodeBox> getNodeBoxes()
|
||||
{
|
||||
std::vector<NodeBox> getNodeBoxes()
|
||||
{
|
||||
return nodeboxes;
|
||||
}
|
||||
|
||||
|
|
|
@ -184,14 +184,14 @@ std::vector<DirListNode> GetDirListing(std::string pathstring)
|
|||
{
|
||||
std::vector<DirListNode> listing;
|
||||
|
||||
DIR *dp;
|
||||
struct dirent *dirp;
|
||||
if((dp = opendir(pathstring.c_str())) == NULL) {
|
||||
DIR *dp;
|
||||
struct dirent *dirp;
|
||||
if((dp = opendir(pathstring.c_str())) == NULL) {
|
||||
//std::cout<<"Error("<<errno<<") opening "<<pathstring<<std::endl;
|
||||
return listing;
|
||||
}
|
||||
return listing;
|
||||
}
|
||||
|
||||
while ((dirp = readdir(dp)) != NULL) {
|
||||
while ((dirp = readdir(dp)) != NULL) {
|
||||
// NOTE:
|
||||
// Be very sure to not include '..' in the results, it will
|
||||
// result in an epic failure when deleting stuff.
|
||||
|
@ -203,8 +203,8 @@ std::vector<DirListNode> GetDirListing(std::string pathstring)
|
|||
if(node.name != "." && node.name != "..")
|
||||
listing.push_back(node);
|
||||
}
|
||||
}
|
||||
closedir(dp);
|
||||
}
|
||||
closedir(dp);
|
||||
|
||||
return listing;
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ static inline std::string hex_encode(const char *data, unsigned int data_size)
|
|||
|
||||
static inline std::string hex_encode(const std::string &data)
|
||||
{
|
||||
return hex_encode(data.c_str(), data.size());
|
||||
return hex_encode(data.c_str(), data.size());
|
||||
}
|
||||
|
||||
static inline bool hex_digit_decode(char hexdigit, unsigned char &value)
|
||||
|
|
|
@ -191,11 +191,11 @@ void intlGUIEditBox::setWordWrap(bool enable)
|
|||
|
||||
void intlGUIEditBox::updateAbsolutePosition()
|
||||
{
|
||||
core::rect<s32> oldAbsoluteRect(AbsoluteRect);
|
||||
core::rect<s32> oldAbsoluteRect(AbsoluteRect);
|
||||
IGUIElement::updateAbsolutePosition();
|
||||
if ( oldAbsoluteRect != AbsoluteRect )
|
||||
{
|
||||
breakText();
|
||||
breakText();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -270,20 +270,20 @@ bool intlGUIEditBox::OnEvent(const SEvent& event)
|
|||
}
|
||||
break;
|
||||
case EET_KEY_INPUT_EVENT:
|
||||
{
|
||||
{
|
||||
#if (defined(linux) || defined(__linux) || defined(__FreeBSD__))
|
||||
// ################################################################
|
||||
// ################################################################
|
||||
// ValkaTR:
|
||||
// This part is the difference from the original intlGUIEditBox
|
||||
// It converts UTF-8 character into a UCS-2 (wchar_t)
|
||||
wchar_t wc = L'_';
|
||||
mbtowc( &wc, (char *) &event.KeyInput.Char, sizeof(event.KeyInput.Char) );
|
||||
// This part is the difference from the original intlGUIEditBox
|
||||
// It converts UTF-8 character into a UCS-2 (wchar_t)
|
||||
wchar_t wc = L'_';
|
||||
mbtowc( &wc, (char *) &event.KeyInput.Char, sizeof(event.KeyInput.Char) );
|
||||
|
||||
//printf( "char: %lc (%u) \r\n", wc, wc );
|
||||
//printf( "char: %lc (%u) \r\n", wc, wc );
|
||||
|
||||
SEvent irrevent(event);
|
||||
irrevent.KeyInput.Char = wc;
|
||||
// ################################################################
|
||||
SEvent irrevent(event);
|
||||
irrevent.KeyInput.Char = wc;
|
||||
// ################################################################
|
||||
|
||||
if (processKey(irrevent))
|
||||
return true;
|
||||
|
@ -293,7 +293,7 @@ bool intlGUIEditBox::OnEvent(const SEvent& event)
|
|||
#endif // defined(linux)
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
case EET_MOUSE_INPUT_EVENT:
|
||||
if (processMouse(event))
|
||||
return true;
|
||||
|
@ -531,7 +531,7 @@ bool intlGUIEditBox::processKey(const SEvent& event)
|
|||
}
|
||||
else
|
||||
{
|
||||
sendGuiEvent( EGET_EDITBOX_ENTER );
|
||||
sendGuiEvent( EGET_EDITBOX_ENTER );
|
||||
}
|
||||
break;
|
||||
case KEY_LEFT:
|
||||
|
@ -779,8 +779,8 @@ bool intlGUIEditBox::processKey(const SEvent& event)
|
|||
return true;
|
||||
}
|
||||
|
||||
// Set new text markers
|
||||
setTextMarkers( newMarkBegin, newMarkEnd );
|
||||
// Set new text markers
|
||||
setTextMarkers( newMarkBegin, newMarkEnd );
|
||||
|
||||
// break the text if it has changed
|
||||
if (textChanged)
|
||||
|
@ -1062,7 +1062,7 @@ bool intlGUIEditBox::processMouse(const SEvent& event)
|
|||
CursorPos = getCursorPos(event.MouseInput.X, event.MouseInput.Y);
|
||||
if (MouseMarking)
|
||||
{
|
||||
setTextMarkers( MarkBegin, CursorPos );
|
||||
setTextMarkers( MarkBegin, CursorPos );
|
||||
}
|
||||
MouseMarking = false;
|
||||
calculateScrollPos();
|
||||
|
@ -1102,7 +1102,7 @@ bool intlGUIEditBox::processMouse(const SEvent& event)
|
|||
// move cursor
|
||||
CursorPos = getCursorPos(event.MouseInput.X, event.MouseInput.Y);
|
||||
|
||||
s32 newMarkBegin = MarkBegin;
|
||||
s32 newMarkBegin = MarkBegin;
|
||||
if (!MouseMarking)
|
||||
newMarkBegin = CursorPos;
|
||||
|
||||
|
@ -1465,12 +1465,12 @@ void intlGUIEditBox::calculateScrollPos()
|
|||
//! set text markers
|
||||
void intlGUIEditBox::setTextMarkers(s32 begin, s32 end)
|
||||
{
|
||||
if ( begin != MarkBegin || end != MarkEnd )
|
||||
{
|
||||
MarkBegin = begin;
|
||||
MarkEnd = end;
|
||||
sendGuiEvent(EGET_EDITBOX_MARKING_CHANGED);
|
||||
}
|
||||
if ( begin != MarkBegin || end != MarkEnd )
|
||||
{
|
||||
MarkBegin = begin;
|
||||
MarkEnd = end;
|
||||
sendGuiEvent(EGET_EDITBOX_MARKING_CHANGED);
|
||||
}
|
||||
}
|
||||
|
||||
//! send some gui event to parent
|
||||
|
@ -1478,13 +1478,13 @@ void intlGUIEditBox::sendGuiEvent(EGUI_EVENT_TYPE type)
|
|||
{
|
||||
if ( Parent )
|
||||
{
|
||||
SEvent e;
|
||||
e.EventType = EET_GUI_EVENT;
|
||||
e.GUIEvent.Caller = this;
|
||||
e.GUIEvent.Element = 0;
|
||||
e.GUIEvent.EventType = type;
|
||||
SEvent e;
|
||||
e.EventType = EET_GUI_EVENT;
|
||||
e.GUIEvent.Caller = this;
|
||||
e.GUIEvent.Element = 0;
|
||||
e.GUIEvent.EventType = type;
|
||||
|
||||
Parent->OnEvent(e);
|
||||
Parent->OnEvent(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -974,30 +974,30 @@ std::string InventoryLocation::dump() const
|
|||
|
||||
void InventoryLocation::serialize(std::ostream &os) const
|
||||
{
|
||||
switch (type) {
|
||||
case InventoryLocation::UNDEFINED:
|
||||
{
|
||||
switch (type) {
|
||||
case InventoryLocation::UNDEFINED:
|
||||
{
|
||||
os<<"undefined";
|
||||
}
|
||||
break;
|
||||
case InventoryLocation::CURRENT_PLAYER:
|
||||
{
|
||||
break;
|
||||
case InventoryLocation::CURRENT_PLAYER:
|
||||
{
|
||||
os<<"current_player";
|
||||
}
|
||||
break;
|
||||
case InventoryLocation::PLAYER:
|
||||
{
|
||||
break;
|
||||
case InventoryLocation::PLAYER:
|
||||
{
|
||||
os<<"player:"<<name;
|
||||
}
|
||||
break;
|
||||
case InventoryLocation::NODEMETA:
|
||||
{
|
||||
}
|
||||
break;
|
||||
case InventoryLocation::NODEMETA:
|
||||
{
|
||||
os<<"nodemeta:"<<p.X<<","<<p.Y<<","<<p.Z;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
}
|
||||
|
||||
void InventoryLocation::deSerialize(std::istream &is)
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include <string>
|
||||
|
||||
/* A key press, consisting of either an Irrlicht keycode
|
||||
or an actual char */
|
||||
or an actual char */
|
||||
|
||||
class KeyPress
|
||||
{
|
||||
|
|
|
@ -87,7 +87,7 @@ std::vector<NodeBox> transformNodeBox(MapNode &n,
|
|||
|
||||
std::vector<NodeBox> ContentFeatures::getNodeBoxes(MapNode &n) const
|
||||
{
|
||||
return transformNodeBox(n, nodeboxes);
|
||||
return transformNodeBox(n, nodeboxes);
|
||||
}
|
||||
|
||||
std::vector<NodeBox> ContentFeatures::getWieldNodeBoxes() const
|
||||
|
|
|
@ -514,7 +514,7 @@ struct ContentFeatures
|
|||
/*
|
||||
Gets list of node boxes (used for collision)
|
||||
*/
|
||||
std::vector<NodeBox> getNodeBoxes(MapNode &n) const;
|
||||
std::vector<NodeBox> getNodeBoxes(MapNode &n) const;
|
||||
|
||||
void setNodeBox(NodeBox nb)
|
||||
{
|
||||
|
@ -527,7 +527,7 @@ struct ContentFeatures
|
|||
nodeboxes.push_back(nb);
|
||||
}
|
||||
|
||||
std::vector<NodeBox> getWieldNodeBoxes() const;
|
||||
std::vector<NodeBox> getWieldNodeBoxes() const;
|
||||
|
||||
void setWieldNodeBox(NodeBox nb)
|
||||
{
|
||||
|
@ -761,7 +761,7 @@ enum LightBank
|
|||
|
||||
/*
|
||||
Masks for MapNode.param2 of flowing liquids
|
||||
*/
|
||||
*/
|
||||
#define LIQUID_LEVEL_MASK 0x07
|
||||
#define LIQUID_FLOW_DOWN_MASK 0x08
|
||||
|
||||
|
|
|
@ -39,21 +39,21 @@ double cos_lookup[16] = {
|
|||
};
|
||||
|
||||
inline double dotProduct(double vx, double vy, double wx, double wy){
|
||||
return vx*wx+vy*wy;
|
||||
return vx*wx+vy*wy;
|
||||
}
|
||||
|
||||
inline double linearInterpolation(double x0, double x1, double t){
|
||||
return x0+(x1-x0)*t;
|
||||
return x0+(x1-x0)*t;
|
||||
}
|
||||
|
||||
double biLinearInterpolation(double x0y0, double x1y0, double x0y1, double x1y1, double x, double y){
|
||||
double tx = easeCurve(x);
|
||||
double ty = easeCurve(y);
|
||||
double tx = easeCurve(x);
|
||||
double ty = easeCurve(y);
|
||||
/*double tx = x;
|
||||
double ty = y;*/
|
||||
double u = linearInterpolation(x0y0,x1y0,tx);
|
||||
double v = linearInterpolation(x0y1,x1y1,tx);
|
||||
return linearInterpolation(u,v,ty);
|
||||
double u = linearInterpolation(x0y0,x1y0,tx);
|
||||
double v = linearInterpolation(x0y1,x1y1,tx);
|
||||
return linearInterpolation(u,v,ty);
|
||||
}
|
||||
|
||||
double triLinearInterpolation(
|
||||
|
@ -61,12 +61,12 @@ double triLinearInterpolation(
|
|||
double v001, double v101, double v011, double v111,
|
||||
double x, double y, double z)
|
||||
{
|
||||
/*double tx = easeCurve(x);
|
||||
double ty = easeCurve(y);
|
||||
double tz = easeCurve(z);*/
|
||||
double tx = x;
|
||||
double ty = y;
|
||||
double tz = z;
|
||||
/*double tx = easeCurve(x);
|
||||
double ty = easeCurve(y);
|
||||
double tz = easeCurve(z);*/
|
||||
double tx = x;
|
||||
double ty = y;
|
||||
double tz = z;
|
||||
return(
|
||||
v000*(1-tx)*(1-ty)*(1-tz) +
|
||||
v100*tx*(1-ty)*(1-tz) +
|
||||
|
|
|
@ -679,7 +679,7 @@ LocalPlayer::~LocalPlayer()
|
|||
}
|
||||
|
||||
void LocalPlayer::move(f32 dtime, Map &map, f32 pos_max_d,
|
||||
core::list<CollisionInfo> *collision_info)
|
||||
core::list<CollisionInfo> *collision_info)
|
||||
{
|
||||
v3f position = getPosition();
|
||||
v3f oldpos = position;
|
||||
|
|
|
@ -271,23 +271,23 @@ void initializePaths()
|
|||
#elif defined(__APPLE__)
|
||||
#include <unistd.h>
|
||||
|
||||
// Code based on
|
||||
// http://stackoverflow.com/questions/516200/relative-paths-not-working-in-xcode-c
|
||||
CFBundleRef main_bundle = CFBundleGetMainBundle();
|
||||
CFURLRef resources_url = CFBundleCopyResourcesDirectoryURL(main_bundle);
|
||||
char path[PATH_MAX];
|
||||
if(CFURLGetFileSystemRepresentation(resources_url, TRUE, (UInt8 *)path, PATH_MAX))
|
||||
// Code based on
|
||||
// http://stackoverflow.com/questions/516200/relative-paths-not-working-in-xcode-c
|
||||
CFBundleRef main_bundle = CFBundleGetMainBundle();
|
||||
CFURLRef resources_url = CFBundleCopyResourcesDirectoryURL(main_bundle);
|
||||
char path[PATH_MAX];
|
||||
if(CFURLGetFileSystemRepresentation(resources_url, TRUE, (UInt8 *)path, PATH_MAX))
|
||||
{
|
||||
dstream<<"Bundle resource path: "<<path<<std::endl;
|
||||
//chdir(path);
|
||||
path_data = std::string(path) + "/share/" + PROJECT_NAME;
|
||||
}
|
||||
else
|
||||
{
|
||||
// error!
|
||||
{
|
||||
// error!
|
||||
dstream<<"WARNING: Could not determine bundle resource path"<<std::endl;
|
||||
}
|
||||
CFRelease(resources_url);
|
||||
}
|
||||
CFRelease(resources_url);
|
||||
|
||||
path_userdata = std::string(getenv("HOME")) + "/Library/Application Support/" + PROJECT_NAME;
|
||||
|
||||
|
|
|
@ -33,29 +33,29 @@
|
|||
/* report a zlib or i/o error */
|
||||
void zerr(int ret)
|
||||
{
|
||||
dstream<<"zerr: ";
|
||||
switch (ret) {
|
||||
case Z_ERRNO:
|
||||
if (ferror(stdin))
|
||||
dstream<<"error reading stdin"<<std::endl;
|
||||
if (ferror(stdout))
|
||||
dstream<<"error writing stdout"<<std::endl;
|
||||
break;
|
||||
case Z_STREAM_ERROR:
|
||||
dstream<<"invalid compression level"<<std::endl;
|
||||
break;
|
||||
case Z_DATA_ERROR:
|
||||
dstream<<"invalid or incomplete deflate data"<<std::endl;
|
||||
break;
|
||||
case Z_MEM_ERROR:
|
||||
dstream<<"out of memory"<<std::endl;
|
||||
break;
|
||||
case Z_VERSION_ERROR:
|
||||
dstream<<"zlib version mismatch!"<<std::endl;
|
||||
dstream<<"zerr: ";
|
||||
switch (ret) {
|
||||
case Z_ERRNO:
|
||||
if (ferror(stdin))
|
||||
dstream<<"error reading stdin"<<std::endl;
|
||||
if (ferror(stdout))
|
||||
dstream<<"error writing stdout"<<std::endl;
|
||||
break;
|
||||
case Z_STREAM_ERROR:
|
||||
dstream<<"invalid compression level"<<std::endl;
|
||||
break;
|
||||
case Z_DATA_ERROR:
|
||||
dstream<<"invalid or incomplete deflate data"<<std::endl;
|
||||
break;
|
||||
case Z_MEM_ERROR:
|
||||
dstream<<"out of memory"<<std::endl;
|
||||
break;
|
||||
case Z_VERSION_ERROR:
|
||||
dstream<<"zlib version mismatch!"<<std::endl;
|
||||
break;
|
||||
default:
|
||||
dstream<<"return value = "<<ret<<std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void compressZlib(SharedBuffer<u8> data, std::ostream &os)
|
||||
|
|
|
@ -42,14 +42,15 @@ Some planning
|
|||
-------------
|
||||
|
||||
* Server environment adds an active object, which gets the id 1
|
||||
*
|
||||
* The active object list is scanned for each client once in a while,
|
||||
and it finds out what objects have been added that are not known
|
||||
by the client yet. This scan is initiated by the Server class and
|
||||
the result ends up directly to the server.
|
||||
* and it finds out what objects have been added that are not known
|
||||
* by the client yet. This scan is initiated by the Server class and
|
||||
* the result ends up directly to the server.
|
||||
*
|
||||
* A network packet is created with the info and sent to the client.
|
||||
* Environment converts objects to static data and static data to
|
||||
objects, based on how close players are to them.
|
||||
|
||||
* objects, based on how close players are to them.
|
||||
*/
|
||||
|
||||
class ServerEnvironment;
|
||||
|
|
140
src/strfnd.h
140
src/strfnd.h
|
@ -80,91 +80,91 @@ public:
|
|||
};
|
||||
|
||||
class WStrfnd{
|
||||
std::wstring tek;
|
||||
unsigned int p;
|
||||
std::wstring tek;
|
||||
unsigned int p;
|
||||
public:
|
||||
void start(std::wstring niinq){
|
||||
tek = niinq;
|
||||
p=0;
|
||||
}
|
||||
unsigned int where(){
|
||||
return p;
|
||||
}
|
||||
void to(unsigned int i){
|
||||
p = i;
|
||||
}
|
||||
std::wstring what(){
|
||||
return tek;
|
||||
}
|
||||
std::wstring next(std::wstring plop){
|
||||
//std::cout<<"tek=\""<<tek<<"\" plop=\""<<plop<<"\""<<std::endl;
|
||||
size_t n;
|
||||
std::wstring palautus;
|
||||
if (p < tek.size())
|
||||
{
|
||||
//std::cout<<"\tp<tek.size()"<<std::endl;
|
||||
if ((n = tek.find(plop, p)) == std::wstring::npos || plop == L"")
|
||||
{
|
||||
//std::cout<<"\t\tn == string::npos || plop == \"\""<<std::endl;
|
||||
n = tek.size();
|
||||
}
|
||||
else
|
||||
{
|
||||
//std::cout<<"\t\tn != string::npos"<<std::endl;
|
||||
}
|
||||
palautus = tek.substr(p, n-p);
|
||||
p = n + plop.length();
|
||||
}
|
||||
//else
|
||||
//std::cout<<"\tp>=tek.size()"<<std::endl;
|
||||
void start(std::wstring niinq){
|
||||
tek = niinq;
|
||||
p=0;
|
||||
}
|
||||
unsigned int where(){
|
||||
return p;
|
||||
}
|
||||
void to(unsigned int i){
|
||||
p = i;
|
||||
}
|
||||
std::wstring what(){
|
||||
return tek;
|
||||
}
|
||||
std::wstring next(std::wstring plop){
|
||||
//std::cout<<"tek=\""<<tek<<"\" plop=\""<<plop<<"\""<<std::endl;
|
||||
size_t n;
|
||||
std::wstring palautus;
|
||||
if (p < tek.size())
|
||||
{
|
||||
//std::cout<<"\tp<tek.size()"<<std::endl;
|
||||
if ((n = tek.find(plop, p)) == std::wstring::npos || plop == L"")
|
||||
{
|
||||
//std::cout<<"\t\tn == string::npos || plop == \"\""<<std::endl;
|
||||
n = tek.size();
|
||||
}
|
||||
else
|
||||
{
|
||||
//std::cout<<"\t\tn != string::npos"<<std::endl;
|
||||
}
|
||||
palautus = tek.substr(p, n-p);
|
||||
p = n + plop.length();
|
||||
}
|
||||
//else
|
||||
//std::cout<<"\tp>=tek.size()"<<std::endl;
|
||||
//std::cout<<"palautus=\""<<palautus<<"\""<<std::endl;
|
||||
return palautus;
|
||||
}
|
||||
bool atend(){
|
||||
if(p>=tek.size()) return true;
|
||||
return false;
|
||||
}
|
||||
WStrfnd(std::wstring s){
|
||||
start(s);
|
||||
}
|
||||
return palautus;
|
||||
}
|
||||
bool atend(){
|
||||
if(p>=tek.size()) return true;
|
||||
return false;
|
||||
}
|
||||
WStrfnd(std::wstring s){
|
||||
start(s);
|
||||
}
|
||||
};
|
||||
|
||||
inline std::string trim(const std::string &s)
|
||||
{
|
||||
std::string str = s;
|
||||
while(
|
||||
str.length()>0
|
||||
&&
|
||||
(
|
||||
str.substr(0, 1)==" " ||
|
||||
str.substr(0, 1)=="\t" ||
|
||||
str.substr(0, 1)=="\r" ||
|
||||
str.substr(0, 1)=="\n" ||
|
||||
str.substr(str.length()-1, 1)==" " ||
|
||||
str.substr(str.length()-1, 1)=="\t" ||
|
||||
str.substr(str.length()-1, 1)=="\r" ||
|
||||
str.substr(str.length()-1, 1)=="\n"
|
||||
)
|
||||
)
|
||||
{
|
||||
if (str.substr(0, 1)==" ")
|
||||
while(
|
||||
str.length()>0
|
||||
&&
|
||||
(
|
||||
str.substr(0, 1)==" " ||
|
||||
str.substr(0, 1)=="\t" ||
|
||||
str.substr(0, 1)=="\r" ||
|
||||
str.substr(0, 1)=="\n" ||
|
||||
str.substr(str.length()-1, 1)==" " ||
|
||||
str.substr(str.length()-1, 1)=="\t" ||
|
||||
str.substr(str.length()-1, 1)=="\r" ||
|
||||
str.substr(str.length()-1, 1)=="\n"
|
||||
)
|
||||
)
|
||||
{
|
||||
if (str.substr(0, 1)==" ")
|
||||
str = str.substr(1,str.length()-1);
|
||||
else if (str.substr(0, 1)=="\t")
|
||||
else if (str.substr(0, 1)=="\t")
|
||||
str = str.substr(1,str.length()-1);
|
||||
else if (str.substr(0, 1)=="\r")
|
||||
else if (str.substr(0, 1)=="\r")
|
||||
str = str.substr(1,str.length()-1);
|
||||
else if (str.substr(0, 1)=="\n")
|
||||
else if (str.substr(0, 1)=="\n")
|
||||
str = str.substr(1,str.length()-1);
|
||||
else if (str.substr(str.length()-1, 1)==" ")
|
||||
else if (str.substr(str.length()-1, 1)==" ")
|
||||
str = str.substr(0,str.length()-1);
|
||||
else if (str.substr(str.length()-1, 1)=="\t")
|
||||
else if (str.substr(str.length()-1, 1)=="\t")
|
||||
str = str.substr(0,str.length()-1);
|
||||
else if (str.substr(str.length()-1, 1)=="\r")
|
||||
else if (str.substr(str.length()-1, 1)=="\r")
|
||||
str = str.substr(0,str.length()-1);
|
||||
else if (str.substr(str.length()-1, 1)=="\n")
|
||||
else if (str.substr(str.length()-1, 1)=="\n")
|
||||
str = str.substr(0,str.length()-1);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
14
src/tile.cpp
14
src/tile.cpp
|
@ -241,7 +241,7 @@ u32 TextureSource::getTextureIdDirect(const std::string &name)
|
|||
base_image_name = name.substr(0, last_separator_position);
|
||||
/*infostream<<"getTextureIdDirect(): Calling itself recursively"
|
||||
" to get base image of \""<<name<<"\" = \""
|
||||
<<base_image_name<<"\""<<std::endl;*/
|
||||
<<base_image_name<<"\""<<std::endl;*/
|
||||
base_image_id = getTextureIdDirect(base_image_name);
|
||||
}
|
||||
|
||||
|
@ -498,8 +498,8 @@ void TextureSource::buildMainAtlas()
|
|||
pos_in_atlas.X += column_width + column_padding*2;
|
||||
}
|
||||
|
||||
infostream<<"TextureSource::buildMainAtlas(): Adding \""<<name
|
||||
<<"\" to texture atlas"<<std::endl;
|
||||
infostream<<"TextureSource::buildMainAtlas(): Adding \""<<name
|
||||
<<"\" to texture atlas"<<std::endl;
|
||||
|
||||
// Tile it a few times in the X direction
|
||||
u16 xwise_tiling = column_width / dim.Width;
|
||||
|
@ -688,7 +688,7 @@ ColorContainer::ColorContainer()
|
|||
colors["azure"] = 0xf0ffff;
|
||||
colors["beige"] = 0xf5f5dc;
|
||||
colors["bisque"] = 0xffe4c4;
|
||||
colors["black"] = 00000000;
|
||||
colors["black"] = 0x000000;
|
||||
colors["blanchedalmond"] = 0xffebcd;
|
||||
colors["blue"] = 0x0000ff;
|
||||
colors["blueviolet"] = 0x8a2be2;
|
||||
|
@ -936,7 +936,7 @@ video::IImage* generate_image_from_scratch(std::string name,
|
|||
base_image_name = name.substr(0, last_separator_position);
|
||||
/*infostream<<"generate_image_from_scratch(): Calling itself recursively"
|
||||
" to get base image of \""<<name<<"\" = \""
|
||||
<<base_image_name<<"\""<<std::endl;*/
|
||||
<<base_image_name<<"\""<<std::endl;*/
|
||||
baseimg = generate_image_from_scratch(base_image_name, device);
|
||||
}
|
||||
|
||||
|
@ -980,11 +980,11 @@ bool generate_image(std::string part_of_name, video::IImage *& baseimg,
|
|||
{
|
||||
if (part_of_name != "") {
|
||||
infostream<<"generate_image(): Could not load image \""
|
||||
<<part_of_name<<"\" from path \""<<path<<"\""
|
||||
<<part_of_name<<"\" from path \""<<path<<"\""
|
||||
<<" while building texture"<<std::endl;
|
||||
|
||||
infostream<<"generate_image(): Creating a dummy"
|
||||
<<" image for \""<<part_of_name<<"\""<<std::endl;
|
||||
<<" image for \""<<part_of_name<<"\""<<std::endl;
|
||||
}
|
||||
|
||||
// Just create a dummy image
|
||||
|
|
|
@ -150,13 +150,13 @@ static unsigned long next = 1;
|
|||
/* RAND_MAX assumed to be 32767 */
|
||||
int myrand(void)
|
||||
{
|
||||
next = next * 1103515245 + 12345;
|
||||
return((unsigned)(next/65536) % 32768);
|
||||
next = next * 1103515245 + 12345;
|
||||
return((unsigned)(next/65536) % 32768);
|
||||
}
|
||||
|
||||
void mysrand(unsigned seed)
|
||||
{
|
||||
next = seed;
|
||||
next = seed;
|
||||
}
|
||||
|
||||
int myrand_range(int min, int max)
|
||||
|
|
Loading…
Reference in New Issue