use hard tabs

This commit is contained in:
Menche 2015-02-06 16:05:12 -08:00 committed by darkrose
parent 5334cabad8
commit 0b25fee660
21 changed files with 307 additions and 313 deletions

View File

@ -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_TELEPORT = 2; // Can teleport
const uint64_t PRIV_SETTIME = 4; // Can set the time 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_PRIVS = 8; // Can grant and revoke privileges
const uint64_t PRIV_SERVER = 16; // Can manage the server (e.g. shutodwn const uint64_t PRIV_SERVER = 16; // Can manage the server (e.g. shutodwn, settings)
// ,settings) const uint64_t PRIV_SHOUT = 32; // Can broadcast chat messages to all players
const uint64_t PRIV_SHOUT = 32; // Can broadcast chat messages to all
// players
const uint64_t PRIV_BAN = 64; // Can ban players const uint64_t PRIV_BAN = 64; // Can ban players
// Default privileges - these can be overriden for new players using the // Default privileges - these can be overriden for new players using the

View File

@ -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 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 warranty. In no event will the author be held liable for any damages
arising from the use of this software. arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions: freely, subject to the following restrictions:
1. The origin of this source code must not be misrepresented; you must not 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 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 in a product, an acknowledgment in the product documentation would be
appreciated but is not required. appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original source code. misrepresented as being the original source code.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
René Nyffenegger rene.nyffenegger@adp-gmbh.ch
René Nyffenegger rene.nyffenegger@adp-gmbh.ch
*/ */
#include "base64.h" #include "base64.h"
#include <iostream> #include <iostream>
static const std::string base64_chars = static const std::string base64_chars =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ" "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz" "abcdefghijklmnopqrstuvwxyz"
"0123456789+/"; "0123456789+/";
static inline bool is_base64(unsigned char c) { 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) 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 base64_encode(unsigned char const* bytes_to_encode, unsigned int in_len) {
std::string ret; std::string ret;
int i = 0; int i = 0;
int j = 0; int j = 0;
unsigned char char_array_3[3]; unsigned char char_array_3[3];
unsigned char char_array_4[4]; unsigned char char_array_4[4];
while (in_len--) { while (in_len--) {
char_array_3[i++] = *(bytes_to_encode++); char_array_3[i++] = *(bytes_to_encode++);
if (i == 3) { if (i == 3) {
char_array_4[0] = (char_array_3[0] & 0xfc) >> 2; 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[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[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[3] = char_array_3[2] & 0x3f;
for(i = 0; (i <4) ; i++) for(i = 0; (i <4) ; i++)
ret += base64_chars[char_array_4[i]]; ret += base64_chars[char_array_4[i]];
i = 0; i = 0;
} }
} }
if (i) if (i)
{ {
for(j = i; j < 3; j++) for(j = i; j < 3; j++)
char_array_3[j] = '\0'; char_array_3[j] = '\0';
char_array_4[0] = (char_array_3[0] & 0xfc) >> 2; 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[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[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[3] = char_array_3[2] & 0x3f;
for (j = 0; (j < i + 1); j++) for (j = 0; (j < i + 1); j++)
ret += base64_chars[char_array_4[j]]; ret += base64_chars[char_array_4[j]];
}
// Don't pad it with =
/*while((i++ < 3))
ret += '=';*/
}
return ret;
return ret;
} }
std::string base64_decode(std::string const& encoded_string) { std::string base64_decode(std::string const& encoded_string) {
int in_len = encoded_string.size(); int in_len = encoded_string.size();
int i = 0; int i = 0;
int j = 0; int j = 0;
int in_ = 0; int in_ = 0;
unsigned char char_array_4[4], char_array_3[3]; unsigned char char_array_4[4], char_array_3[3];
std::string ret; std::string ret;
while (in_len-- && ( encoded_string[in_] != '=') && is_base64(encoded_string[in_])) { while (in_len-- && ( encoded_string[in_] != '=') && is_base64(encoded_string[in_])) {
char_array_4[i++] = encoded_string[in_]; in_++; char_array_4[i++] = encoded_string[in_]; in_++;
if (i ==4) { if (i ==4) {
for (i = 0; i <4; i++) for (i = 0; i <4; i++)
char_array_4[i] = base64_chars.find(char_array_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[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[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[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
for (i = 0; (i < 3); i++) for (i = 0; (i < 3); i++)
ret += char_array_3[i]; ret += char_array_3[i];
i = 0; i = 0;
} }
} }
if (i) { if (i) {
for (j = i; j <4; j++) for (j = i; j <4; j++)
char_array_4[j] = 0; char_array_4[j] = 0;
for (j = 0; j <4; j++) for (j = 0; j <4; j++)
char_array_4[j] = base64_chars.find(char_array_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[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[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[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;
} }

View File

@ -31,15 +31,13 @@
#include "mapnode.h" #include "mapnode.h"
/* /*
* Some planning
Some planning *
-------------
* Client receives a network packet with information of added objects * Client receives a network packet with information of added objects
in it * in it
*
* Client supplies the information to its ClientEnvironment * Client supplies the information to its ClientEnvironment
* The environment adds the specified objects to itself * The environment adds the specified objects to itself
*/ */
class ClientEnvironment; class ClientEnvironment;

View File

@ -38,8 +38,7 @@
#define PROTOCOL_ID 0x4f457403 #define PROTOCOL_ID 0x4f457403
#define PASSWORD_SIZE 28 // Maximum password length. Allows for #define PASSWORD_SIZE 28 // Maximum password length. Allows for base64-encoded SHA-1 (27+\0).
// base64-encoded SHA-1 (27+\0).
enum ToClientCommand enum ToClientCommand
{ {

View File

@ -238,31 +238,35 @@ checking at all.
#define TYPE_ORIGINAL 1 #define TYPE_ORIGINAL 1
#define ORIGINAL_HEADER_SIZE 1 #define ORIGINAL_HEADER_SIZE 1
/* /*
SPLIT: These are sequences of packets forming one bigger piece of * SPLIT: These are sequences of packets forming one bigger piece of
data. * data.
- When processed and all the packet_nums 0...packet_count-1 are *
present (this should be buffered), the resulting data shall be * When processed and all the packet_nums 0...packet_count-1 are
directly handed to the user. * present (this should be buffered), the resulting data shall be
- If the data fails to come up in a reasonable time, the buffer shall * directly handed to the user.
be silently discarded. *
- These can be sent as-is or atop of a RELIABLE packet stream. * If the data fails to come up in a reasonable time, the buffer shall
Header (7 bytes): * be silently discarded.
[0] u8 type *
[1] u16 seqnum * These can be sent as-is or atop of a RELIABLE packet stream.
[3] u16 chunk_count * Header (7 bytes):
[5] u16 chunk_num * [0] u8 type
* [1] u16 seqnum
* [3] u16 chunk_count
* [5] u16 chunk_num
*/ */
#define TYPE_SPLIT 2 #define TYPE_SPLIT 2
/* /*
RELIABLE: Delivery of all RELIABLE packets shall be forced by ACKs, * 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 * and they shall be delivered in the same order as sent. This is done
with a buffer in the receiving and transmitting end. * with a buffer in the receiving and transmitting end.
- When this is processed, the contents of each packet is recursively *
processed as packets. * When this is processed, the contents of each packet is recursively
Header (3 bytes): * processed as packets.
[0] u8 type *
[1] u16 seqnum * Header (3 bytes):
* [0] u8 type
* [1] u16 seqnum
*/ */
#define TYPE_RELIABLE 3 #define TYPE_RELIABLE 3
#define RELIABLE_HEADER_SIZE 3 #define RELIABLE_HEADER_SIZE 3

View File

@ -156,8 +156,8 @@ struct MobFeatures {
/* /*
Gets list of node boxes Gets list of node boxes
*/ */
std::vector<NodeBox> getNodeBoxes() std::vector<NodeBox> getNodeBoxes()
{ {
return nodeboxes; return nodeboxes;
} }

View File

@ -184,14 +184,14 @@ std::vector<DirListNode> GetDirListing(std::string pathstring)
{ {
std::vector<DirListNode> listing; std::vector<DirListNode> listing;
DIR *dp; DIR *dp;
struct dirent *dirp; struct dirent *dirp;
if((dp = opendir(pathstring.c_str())) == NULL) { if((dp = opendir(pathstring.c_str())) == NULL) {
//std::cout<<"Error("<<errno<<") opening "<<pathstring<<std::endl; //std::cout<<"Error("<<errno<<") opening "<<pathstring<<std::endl;
return listing; return listing;
} }
while ((dirp = readdir(dp)) != NULL) { while ((dirp = readdir(dp)) != NULL) {
// NOTE: // NOTE:
// Be very sure to not include '..' in the results, it will // Be very sure to not include '..' in the results, it will
// result in an epic failure when deleting stuff. // result in an epic failure when deleting stuff.
@ -203,8 +203,8 @@ std::vector<DirListNode> GetDirListing(std::string pathstring)
if(node.name != "." && node.name != "..") if(node.name != "." && node.name != "..")
listing.push_back(node); listing.push_back(node);
} }
} }
closedir(dp); closedir(dp);
return listing; return listing;
} }

View File

@ -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) 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) static inline bool hex_digit_decode(char hexdigit, unsigned char &value)

View File

@ -191,11 +191,11 @@ void intlGUIEditBox::setWordWrap(bool enable)
void intlGUIEditBox::updateAbsolutePosition() void intlGUIEditBox::updateAbsolutePosition()
{ {
core::rect<s32> oldAbsoluteRect(AbsoluteRect); core::rect<s32> oldAbsoluteRect(AbsoluteRect);
IGUIElement::updateAbsolutePosition(); IGUIElement::updateAbsolutePosition();
if ( oldAbsoluteRect != AbsoluteRect ) if ( oldAbsoluteRect != AbsoluteRect )
{ {
breakText(); breakText();
} }
} }
@ -270,20 +270,20 @@ bool intlGUIEditBox::OnEvent(const SEvent& event)
} }
break; break;
case EET_KEY_INPUT_EVENT: case EET_KEY_INPUT_EVENT:
{ {
#if (defined(linux) || defined(__linux) || defined(__FreeBSD__)) #if (defined(linux) || defined(__linux) || defined(__FreeBSD__))
// ################################################################ // ################################################################
// ValkaTR: // ValkaTR:
// This part is the difference from the original intlGUIEditBox // This part is the difference from the original intlGUIEditBox
// It converts UTF-8 character into a UCS-2 (wchar_t) // It converts UTF-8 character into a UCS-2 (wchar_t)
wchar_t wc = L'_'; wchar_t wc = L'_';
mbtowc( &wc, (char *) &event.KeyInput.Char, sizeof(event.KeyInput.Char) ); 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); SEvent irrevent(event);
irrevent.KeyInput.Char = wc; irrevent.KeyInput.Char = wc;
// ################################################################ // ################################################################
if (processKey(irrevent)) if (processKey(irrevent))
return true; return true;
@ -293,7 +293,7 @@ bool intlGUIEditBox::OnEvent(const SEvent& event)
#endif // defined(linux) #endif // defined(linux)
break; break;
} }
case EET_MOUSE_INPUT_EVENT: case EET_MOUSE_INPUT_EVENT:
if (processMouse(event)) if (processMouse(event))
return true; return true;
@ -531,7 +531,7 @@ bool intlGUIEditBox::processKey(const SEvent& event)
} }
else else
{ {
sendGuiEvent( EGET_EDITBOX_ENTER ); sendGuiEvent( EGET_EDITBOX_ENTER );
} }
break; break;
case KEY_LEFT: case KEY_LEFT:
@ -779,8 +779,8 @@ bool intlGUIEditBox::processKey(const SEvent& event)
return true; return true;
} }
// Set new text markers // Set new text markers
setTextMarkers( newMarkBegin, newMarkEnd ); setTextMarkers( newMarkBegin, newMarkEnd );
// break the text if it has changed // break the text if it has changed
if (textChanged) if (textChanged)
@ -1062,7 +1062,7 @@ bool intlGUIEditBox::processMouse(const SEvent& event)
CursorPos = getCursorPos(event.MouseInput.X, event.MouseInput.Y); CursorPos = getCursorPos(event.MouseInput.X, event.MouseInput.Y);
if (MouseMarking) if (MouseMarking)
{ {
setTextMarkers( MarkBegin, CursorPos ); setTextMarkers( MarkBegin, CursorPos );
} }
MouseMarking = false; MouseMarking = false;
calculateScrollPos(); calculateScrollPos();
@ -1102,7 +1102,7 @@ bool intlGUIEditBox::processMouse(const SEvent& event)
// move cursor // move cursor
CursorPos = getCursorPos(event.MouseInput.X, event.MouseInput.Y); CursorPos = getCursorPos(event.MouseInput.X, event.MouseInput.Y);
s32 newMarkBegin = MarkBegin; s32 newMarkBegin = MarkBegin;
if (!MouseMarking) if (!MouseMarking)
newMarkBegin = CursorPos; newMarkBegin = CursorPos;
@ -1465,12 +1465,12 @@ void intlGUIEditBox::calculateScrollPos()
//! set text markers //! set text markers
void intlGUIEditBox::setTextMarkers(s32 begin, s32 end) void intlGUIEditBox::setTextMarkers(s32 begin, s32 end)
{ {
if ( begin != MarkBegin || end != MarkEnd ) if ( begin != MarkBegin || end != MarkEnd )
{ {
MarkBegin = begin; MarkBegin = begin;
MarkEnd = end; MarkEnd = end;
sendGuiEvent(EGET_EDITBOX_MARKING_CHANGED); sendGuiEvent(EGET_EDITBOX_MARKING_CHANGED);
} }
} }
//! send some gui event to parent //! send some gui event to parent
@ -1478,13 +1478,13 @@ void intlGUIEditBox::sendGuiEvent(EGUI_EVENT_TYPE type)
{ {
if ( Parent ) if ( Parent )
{ {
SEvent e; SEvent e;
e.EventType = EET_GUI_EVENT; e.EventType = EET_GUI_EVENT;
e.GUIEvent.Caller = this; e.GUIEvent.Caller = this;
e.GUIEvent.Element = 0; e.GUIEvent.Element = 0;
e.GUIEvent.EventType = type; e.GUIEvent.EventType = type;
Parent->OnEvent(e); Parent->OnEvent(e);
} }
} }

View File

@ -974,30 +974,30 @@ std::string InventoryLocation::dump() const
void InventoryLocation::serialize(std::ostream &os) const void InventoryLocation::serialize(std::ostream &os) const
{ {
switch (type) { switch (type) {
case InventoryLocation::UNDEFINED: case InventoryLocation::UNDEFINED:
{ {
os<<"undefined"; os<<"undefined";
} }
break; break;
case InventoryLocation::CURRENT_PLAYER: case InventoryLocation::CURRENT_PLAYER:
{ {
os<<"current_player"; os<<"current_player";
} }
break; break;
case InventoryLocation::PLAYER: case InventoryLocation::PLAYER:
{ {
os<<"player:"<<name; os<<"player:"<<name;
} }
break; break;
case InventoryLocation::NODEMETA: case InventoryLocation::NODEMETA:
{ {
os<<"nodemeta:"<<p.X<<","<<p.Y<<","<<p.Z; os<<"nodemeta:"<<p.X<<","<<p.Y<<","<<p.Z;
} }
break; break;
default: default:
assert(0); assert(0);
} }
} }
void InventoryLocation::deSerialize(std::istream &is) void InventoryLocation::deSerialize(std::istream &is)

View File

@ -30,7 +30,7 @@
#include <string> #include <string>
/* A key press, consisting of either an Irrlicht keycode /* A key press, consisting of either an Irrlicht keycode
or an actual char */ or an actual char */
class KeyPress class KeyPress
{ {

View File

@ -87,7 +87,7 @@ std::vector<NodeBox> transformNodeBox(MapNode &n,
std::vector<NodeBox> ContentFeatures::getNodeBoxes(MapNode &n) const std::vector<NodeBox> ContentFeatures::getNodeBoxes(MapNode &n) const
{ {
return transformNodeBox(n, nodeboxes); return transformNodeBox(n, nodeboxes);
} }
std::vector<NodeBox> ContentFeatures::getWieldNodeBoxes() const std::vector<NodeBox> ContentFeatures::getWieldNodeBoxes() const

View File

@ -514,7 +514,7 @@ struct ContentFeatures
/* /*
Gets list of node boxes (used for collision) 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) void setNodeBox(NodeBox nb)
{ {
@ -527,7 +527,7 @@ struct ContentFeatures
nodeboxes.push_back(nb); nodeboxes.push_back(nb);
} }
std::vector<NodeBox> getWieldNodeBoxes() const; std::vector<NodeBox> getWieldNodeBoxes() const;
void setWieldNodeBox(NodeBox nb) void setWieldNodeBox(NodeBox nb)
{ {
@ -761,7 +761,7 @@ enum LightBank
/* /*
Masks for MapNode.param2 of flowing liquids Masks for MapNode.param2 of flowing liquids
*/ */
#define LIQUID_LEVEL_MASK 0x07 #define LIQUID_LEVEL_MASK 0x07
#define LIQUID_FLOW_DOWN_MASK 0x08 #define LIQUID_FLOW_DOWN_MASK 0x08

View File

@ -39,21 +39,21 @@ double cos_lookup[16] = {
}; };
inline double dotProduct(double vx, double vy, double wx, double wy){ 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){ 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 biLinearInterpolation(double x0y0, double x1y0, double x0y1, double x1y1, double x, double y){
double tx = easeCurve(x); double tx = easeCurve(x);
double ty = easeCurve(y); double ty = easeCurve(y);
/*double tx = x; /*double tx = x;
double ty = y;*/ double ty = y;*/
double u = linearInterpolation(x0y0,x1y0,tx); double u = linearInterpolation(x0y0,x1y0,tx);
double v = linearInterpolation(x0y1,x1y1,tx); double v = linearInterpolation(x0y1,x1y1,tx);
return linearInterpolation(u,v,ty); return linearInterpolation(u,v,ty);
} }
double triLinearInterpolation( double triLinearInterpolation(
@ -61,12 +61,12 @@ double triLinearInterpolation(
double v001, double v101, double v011, double v111, double v001, double v101, double v011, double v111,
double x, double y, double z) double x, double y, double z)
{ {
/*double tx = easeCurve(x); /*double tx = easeCurve(x);
double ty = easeCurve(y); double ty = easeCurve(y);
double tz = easeCurve(z);*/ double tz = easeCurve(z);*/
double tx = x; double tx = x;
double ty = y; double ty = y;
double tz = z; double tz = z;
return( return(
v000*(1-tx)*(1-ty)*(1-tz) + v000*(1-tx)*(1-ty)*(1-tz) +
v100*tx*(1-ty)*(1-tz) + v100*tx*(1-ty)*(1-tz) +

View File

@ -679,7 +679,7 @@ LocalPlayer::~LocalPlayer()
} }
void LocalPlayer::move(f32 dtime, Map &map, f32 pos_max_d, 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 position = getPosition();
v3f oldpos = position; v3f oldpos = position;

View File

@ -271,23 +271,23 @@ void initializePaths()
#elif defined(__APPLE__) #elif defined(__APPLE__)
#include <unistd.h> #include <unistd.h>
// Code based on // Code based on
// http://stackoverflow.com/questions/516200/relative-paths-not-working-in-xcode-c // http://stackoverflow.com/questions/516200/relative-paths-not-working-in-xcode-c
CFBundleRef main_bundle = CFBundleGetMainBundle(); CFBundleRef main_bundle = CFBundleGetMainBundle();
CFURLRef resources_url = CFBundleCopyResourcesDirectoryURL(main_bundle); CFURLRef resources_url = CFBundleCopyResourcesDirectoryURL(main_bundle);
char path[PATH_MAX]; char path[PATH_MAX];
if(CFURLGetFileSystemRepresentation(resources_url, TRUE, (UInt8 *)path, PATH_MAX)) if(CFURLGetFileSystemRepresentation(resources_url, TRUE, (UInt8 *)path, PATH_MAX))
{ {
dstream<<"Bundle resource path: "<<path<<std::endl; dstream<<"Bundle resource path: "<<path<<std::endl;
//chdir(path); //chdir(path);
path_data = std::string(path) + "/share/" + PROJECT_NAME; path_data = std::string(path) + "/share/" + PROJECT_NAME;
} }
else else
{ {
// error! // error!
dstream<<"WARNING: Could not determine bundle resource path"<<std::endl; 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; path_userdata = std::string(getenv("HOME")) + "/Library/Application Support/" + PROJECT_NAME;

View File

@ -33,29 +33,29 @@
/* report a zlib or i/o error */ /* report a zlib or i/o error */
void zerr(int ret) void zerr(int ret)
{ {
dstream<<"zerr: "; dstream<<"zerr: ";
switch (ret) { switch (ret) {
case Z_ERRNO: case Z_ERRNO:
if (ferror(stdin)) if (ferror(stdin))
dstream<<"error reading stdin"<<std::endl; dstream<<"error reading stdin"<<std::endl;
if (ferror(stdout)) if (ferror(stdout))
dstream<<"error writing stdout"<<std::endl; dstream<<"error writing stdout"<<std::endl;
break; break;
case Z_STREAM_ERROR: case Z_STREAM_ERROR:
dstream<<"invalid compression level"<<std::endl; dstream<<"invalid compression level"<<std::endl;
break; break;
case Z_DATA_ERROR: case Z_DATA_ERROR:
dstream<<"invalid or incomplete deflate data"<<std::endl; dstream<<"invalid or incomplete deflate data"<<std::endl;
break; break;
case Z_MEM_ERROR: case Z_MEM_ERROR:
dstream<<"out of memory"<<std::endl; dstream<<"out of memory"<<std::endl;
break; break;
case Z_VERSION_ERROR: case Z_VERSION_ERROR:
dstream<<"zlib version mismatch!"<<std::endl; dstream<<"zlib version mismatch!"<<std::endl;
break; break;
default: default:
dstream<<"return value = "<<ret<<std::endl; dstream<<"return value = "<<ret<<std::endl;
} }
} }
void compressZlib(SharedBuffer<u8> data, std::ostream &os) void compressZlib(SharedBuffer<u8> data, std::ostream &os)

View File

@ -42,14 +42,15 @@ Some planning
------------- -------------
* Server environment adds an active object, which gets the id 1 * Server environment adds an active object, which gets the id 1
*
* The active object list is scanned for each client once in a while, * 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 * 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 * by the client yet. This scan is initiated by the Server class and
the result ends up directly to the server. * the result ends up directly to the server.
*
* A network packet is created with the info and sent to the client. * A network packet is created with the info and sent to the client.
* Environment converts objects to static data and static data to * 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; class ServerEnvironment;

View File

@ -80,91 +80,91 @@ public:
}; };
class WStrfnd{ class WStrfnd{
std::wstring tek; std::wstring tek;
unsigned int p; unsigned int p;
public: public:
void start(std::wstring niinq){ void start(std::wstring niinq){
tek = niinq; tek = niinq;
p=0; p=0;
} }
unsigned int where(){ unsigned int where(){
return p; return p;
} }
void to(unsigned int i){ void to(unsigned int i){
p = i; p = i;
} }
std::wstring what(){ std::wstring what(){
return tek; return tek;
} }
std::wstring next(std::wstring plop){ std::wstring next(std::wstring plop){
//std::cout<<"tek=\""<<tek<<"\" plop=\""<<plop<<"\""<<std::endl; //std::cout<<"tek=\""<<tek<<"\" plop=\""<<plop<<"\""<<std::endl;
size_t n; size_t n;
std::wstring palautus; std::wstring palautus;
if (p < tek.size()) if (p < tek.size())
{ {
//std::cout<<"\tp<tek.size()"<<std::endl; //std::cout<<"\tp<tek.size()"<<std::endl;
if ((n = tek.find(plop, p)) == std::wstring::npos || plop == L"") if ((n = tek.find(plop, p)) == std::wstring::npos || plop == L"")
{ {
//std::cout<<"\t\tn == string::npos || plop == \"\""<<std::endl; //std::cout<<"\t\tn == string::npos || plop == \"\""<<std::endl;
n = tek.size(); n = tek.size();
} }
else else
{ {
//std::cout<<"\t\tn != string::npos"<<std::endl; //std::cout<<"\t\tn != string::npos"<<std::endl;
} }
palautus = tek.substr(p, n-p); palautus = tek.substr(p, n-p);
p = n + plop.length(); p = n + plop.length();
} }
//else //else
//std::cout<<"\tp>=tek.size()"<<std::endl; //std::cout<<"\tp>=tek.size()"<<std::endl;
//std::cout<<"palautus=\""<<palautus<<"\""<<std::endl; //std::cout<<"palautus=\""<<palautus<<"\""<<std::endl;
return palautus; return palautus;
} }
bool atend(){ bool atend(){
if(p>=tek.size()) return true; if(p>=tek.size()) return true;
return false; return false;
} }
WStrfnd(std::wstring s){ WStrfnd(std::wstring s){
start(s); start(s);
} }
}; };
inline std::string trim(const std::string &s) inline std::string trim(const std::string &s)
{ {
std::string str = s; std::string str = s;
while( while(
str.length()>0 str.length()>0
&& &&
( (
str.substr(0, 1)==" " || str.substr(0, 1)==" " ||
str.substr(0, 1)=="\t" || str.substr(0, 1)=="\t" ||
str.substr(0, 1)=="\r" || str.substr(0, 1)=="\r" ||
str.substr(0, 1)=="\n" || str.substr(0, 1)=="\n" ||
str.substr(str.length()-1, 1)==" " || str.substr(str.length()-1, 1)==" " ||
str.substr(str.length()-1, 1)=="\t" || str.substr(str.length()-1, 1)=="\t" ||
str.substr(str.length()-1, 1)=="\r" || str.substr(str.length()-1, 1)=="\r" ||
str.substr(str.length()-1, 1)=="\n" str.substr(str.length()-1, 1)=="\n"
) )
) )
{ {
if (str.substr(0, 1)==" ") if (str.substr(0, 1)==" ")
str = str.substr(1,str.length()-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); 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); 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); 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); 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); 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); 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); str = str.substr(0,str.length()-1);
} }
return str; return str;
} }
#endif #endif

View File

@ -241,7 +241,7 @@ u32 TextureSource::getTextureIdDirect(const std::string &name)
base_image_name = name.substr(0, last_separator_position); base_image_name = name.substr(0, last_separator_position);
/*infostream<<"getTextureIdDirect(): Calling itself recursively" /*infostream<<"getTextureIdDirect(): Calling itself recursively"
" to get base image of \""<<name<<"\" = \"" " to get base image of \""<<name<<"\" = \""
<<base_image_name<<"\""<<std::endl;*/ <<base_image_name<<"\""<<std::endl;*/
base_image_id = getTextureIdDirect(base_image_name); base_image_id = getTextureIdDirect(base_image_name);
} }
@ -498,8 +498,8 @@ void TextureSource::buildMainAtlas()
pos_in_atlas.X += column_width + column_padding*2; pos_in_atlas.X += column_width + column_padding*2;
} }
infostream<<"TextureSource::buildMainAtlas(): Adding \""<<name infostream<<"TextureSource::buildMainAtlas(): Adding \""<<name
<<"\" to texture atlas"<<std::endl; <<"\" to texture atlas"<<std::endl;
// Tile it a few times in the X direction // Tile it a few times in the X direction
u16 xwise_tiling = column_width / dim.Width; u16 xwise_tiling = column_width / dim.Width;
@ -688,7 +688,7 @@ ColorContainer::ColorContainer()
colors["azure"] = 0xf0ffff; colors["azure"] = 0xf0ffff;
colors["beige"] = 0xf5f5dc; colors["beige"] = 0xf5f5dc;
colors["bisque"] = 0xffe4c4; colors["bisque"] = 0xffe4c4;
colors["black"] = 00000000; colors["black"] = 0x000000;
colors["blanchedalmond"] = 0xffebcd; colors["blanchedalmond"] = 0xffebcd;
colors["blue"] = 0x0000ff; colors["blue"] = 0x0000ff;
colors["blueviolet"] = 0x8a2be2; 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); base_image_name = name.substr(0, last_separator_position);
/*infostream<<"generate_image_from_scratch(): Calling itself recursively" /*infostream<<"generate_image_from_scratch(): Calling itself recursively"
" to get base image of \""<<name<<"\" = \"" " 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); 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 != "") { if (part_of_name != "") {
infostream<<"generate_image(): Could not load image \"" infostream<<"generate_image(): Could not load image \""
<<part_of_name<<"\" from path \""<<path<<"\"" <<part_of_name<<"\" from path \""<<path<<"\""
<<" while building texture"<<std::endl; <<" while building texture"<<std::endl;
infostream<<"generate_image(): Creating a dummy" 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 // Just create a dummy image

View File

@ -150,13 +150,13 @@ static unsigned long next = 1;
/* RAND_MAX assumed to be 32767 */ /* RAND_MAX assumed to be 32767 */
int myrand(void) int myrand(void)
{ {
next = next * 1103515245 + 12345; next = next * 1103515245 + 12345;
return((unsigned)(next/65536) % 32768); return((unsigned)(next/65536) % 32768);
} }
void mysrand(unsigned seed) void mysrand(unsigned seed)
{ {
next = seed; next = seed;
} }
int myrand_range(int min, int max) int myrand_range(int min, int max)