Bugfix: spaces in teleport names.
Changed client-side teleport info presentation
This commit is contained in:
parent
060888c0cc
commit
38e6a39f59
@ -391,7 +391,7 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
|
|||||||
video::SColor c = MapBlock_LightColor(255, l);*/
|
video::SColor c = MapBlock_LightColor(255, l);*/
|
||||||
video::SColor c(0xFFFFFFFF);
|
video::SColor c(0xFFFFFFFF);
|
||||||
|
|
||||||
float d = (float)BS/16;
|
float d = BS/8;
|
||||||
// Wall at X+ of node
|
// Wall at X+ of node
|
||||||
/*video::S3DVertex vertices[4] =
|
/*video::S3DVertex vertices[4] =
|
||||||
{
|
{
|
||||||
|
41
src/game.cpp
41
src/game.cpp
@ -50,6 +50,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
*/
|
*/
|
||||||
#include "content_mapnode.h"
|
#include "content_mapnode.h"
|
||||||
#include "content_nodemeta.h"
|
#include "content_nodemeta.h"
|
||||||
|
#include "teleports.h"
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Setting this to 1 enables a special camera mode that forces
|
Setting this to 1 enables a special camera mode that forces
|
||||||
@ -457,8 +459,8 @@ void getPointedNode(Client *client, v3f player_position,
|
|||||||
};*/
|
};*/
|
||||||
v3f vertices[4] =
|
v3f vertices[4] =
|
||||||
{
|
{
|
||||||
v3f(BS*0.42,-BS*0.8,-BS*0.8),
|
v3f(BS*0.37,-BS*0.8,-BS*0.8),
|
||||||
v3f(BS*0.49, BS*0.8, BS*0.8),
|
v3f(BS*0.42, BS*0.8, BS*0.8),
|
||||||
};
|
};
|
||||||
|
|
||||||
for(s32 i=0; i<2; i++)
|
for(s32 i=0; i<2; i++)
|
||||||
@ -469,12 +471,12 @@ void getPointedNode(Client *client, v3f player_position,
|
|||||||
vertices[i].rotateXYBy(90);
|
vertices[i].rotateXYBy(90);
|
||||||
else{
|
else{
|
||||||
if(dir == v3s16(1,0,0))
|
if(dir == v3s16(1,0,0))
|
||||||
vertices[i].rotateXZBy(0);
|
;//vertices[i].rotateXZBy(0);
|
||||||
if(dir == v3s16(-1,0,0))
|
else if(dir == v3s16(-1,0,0))
|
||||||
vertices[i].rotateXZBy(180);
|
vertices[i].rotateXZBy(180);
|
||||||
if(dir == v3s16(0,0,1))
|
else if(dir == v3s16(0,0,1))
|
||||||
vertices[i].rotateXZBy(90);
|
vertices[i].rotateXZBy(90);
|
||||||
if(dir == v3s16(0,0,-1))
|
else if(dir == v3s16(0,0,-1))
|
||||||
vertices[i].rotateXZBy(-90);
|
vertices[i].rotateXZBy(-90);
|
||||||
vertices[i].Y += BS/2;
|
vertices[i].Y += BS/2;
|
||||||
}
|
}
|
||||||
@ -1807,6 +1809,33 @@ void the_game(
|
|||||||
content_t content = map->getNodeNoEx(nodepos).getContent();
|
content_t content = map->getNodeNoEx(nodepos).getContent();
|
||||||
if(content == CONTENT_TELEPORT)
|
if(content == CONTENT_TELEPORT)
|
||||||
{
|
{
|
||||||
|
try{
|
||||||
|
SignNodeMetadata& smeta = dynamic_cast<SignNodeMetadata&>(*meta);
|
||||||
|
std::string txt = smeta.getText();
|
||||||
|
TeleportInfo ti;
|
||||||
|
if(getTeleportInfo(ti,txt,true,true,false)){
|
||||||
|
if(!ti.description.empty())
|
||||||
|
txt = ti.description;
|
||||||
|
else if(ti.targetLocation.X!=TELEPORT_IGNORE){
|
||||||
|
std::ostringstream oss;
|
||||||
|
oss << "Destination: "
|
||||||
|
<< ti.targetLocation.X << ", "
|
||||||
|
<< ti.targetLocation.Y << ", "
|
||||||
|
<< ti.targetLocation.Z;
|
||||||
|
txt = oss.str();
|
||||||
|
} else {
|
||||||
|
txt.clear();
|
||||||
|
if(!ti.thisName.empty())
|
||||||
|
txt = "Portal name: " + ti.thisName;
|
||||||
|
if(!ti.targetName.empty()){
|
||||||
|
if(!ti.thisName.empty())
|
||||||
|
txt += " | ";
|
||||||
|
txt += "Target portal: " + ti.targetName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
infotext = narrow_to_wide(txt);
|
||||||
|
}else infotext.clear();
|
||||||
|
}catch(std::bad_cast&){} //bad meta data for a teleport
|
||||||
// meta/infotext contains text inside "" quotes.
|
// meta/infotext contains text inside "" quotes.
|
||||||
// find 3rd comma
|
// find 3rd comma
|
||||||
/*int icomma=infotext.find(L',');
|
/*int icomma=infotext.find(L',');
|
||||||
|
@ -1832,9 +1832,8 @@ bool getTeleportTarget(/*const*/ ServerEnvironment& env,/*in+out*/ v3s16 &where,
|
|||||||
else {
|
else {
|
||||||
// check player "head block"
|
// check player "head block"
|
||||||
where.Y++;
|
where.Y++;
|
||||||
if(where.Y<MAP_GENERATION_LIMIT-1)
|
if(map.getNode(where).getContent() == CONTENT_TELEPORT)
|
||||||
if(map.getNode(where).getContent() == CONTENT_TELEPORT)
|
meta = (SignNodeMetadata*)map.getNodeMetadata(where);
|
||||||
meta = (SignNodeMetadata*)map.getNodeMetadata(where);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(meta){
|
if(meta){
|
||||||
|
@ -103,7 +103,9 @@ void TeleportsManager::save(Settings& args) const
|
|||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
for(links_t::const_iterator it=m_links.begin(); it!=m_links.end(); it++){
|
for(links_t::const_iterator it=m_links.begin(); it!=m_links.end(); it++){
|
||||||
const TeleportLink& t = it->second;
|
const TeleportLink& t = it->second;
|
||||||
os << it->first << ' '; //name
|
std::string name = it->first;
|
||||||
|
str_replace_char(name,' ','\xFF');
|
||||||
|
os << name << ' '; //name
|
||||||
for(int i=0; i<2; i++) //coords
|
for(int i=0; i<2; i++) //coords
|
||||||
if(t.coords[i].X == TELEPORT_IGNORE) //if coord ignored - don't save Y and Z
|
if(t.coords[i].X == TELEPORT_IGNORE) //if coord ignored - don't save Y and Z
|
||||||
os << TELEPORT_IGNORE << ' ';
|
os << TELEPORT_IGNORE << ' ';
|
||||||
@ -120,8 +122,9 @@ void TeleportsManager::load(Settings& args)
|
|||||||
while(is.good() && !is.eof()){
|
while(is.good() && !is.eof()){
|
||||||
std::string name;
|
std::string name;
|
||||||
is >> name;
|
is >> name;
|
||||||
if(name.length() == 0) continue;
|
|
||||||
if(is.bad() || is.eof()) break;
|
if(is.bad() || is.eof()) break;
|
||||||
|
if(name.length() == 0) continue;
|
||||||
|
str_replace_char(name,'\xFF',' ');
|
||||||
for(int i=0; i<2; i++){
|
for(int i=0; i<2; i++){
|
||||||
v3s16 v;
|
v3s16 v;
|
||||||
is >> v.X;
|
is >> v.X;
|
||||||
@ -196,7 +199,7 @@ bool getTeleportInfo(TeleportInfo& ti, const std::string& text, bool allowCoords
|
|||||||
//find if parts[0] has target name
|
//find if parts[0] has target name
|
||||||
int pos = parts[0].find("->");
|
int pos = parts[0].find("->");
|
||||||
|
|
||||||
if(!allowUnnamed && pos==0) JLOGAND("no 'thisname'", return false;) //no 'thisname' specified
|
if(!allowUnnamed && pos==0) JLOGAND("missing 'thisname'", return false;) //no 'thisname' specified
|
||||||
|
|
||||||
if(pos != std::string::npos){ //yes, split it to 'thisname' and 'targetname'
|
if(pos != std::string::npos){ //yes, split it to 'thisname' and 'targetname'
|
||||||
if(pos>0) ti.thisName = trim(parts[0].substr(0,pos));
|
if(pos>0) ti.thisName = trim(parts[0].substr(0,pos));
|
||||||
|
@ -77,7 +77,7 @@ private:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if 1
|
#ifndef NDEBUG
|
||||||
#define JLOG(x) std::cout << x << std::endl
|
#define JLOG(x) std::cout << x << std::endl
|
||||||
#define JV3(x) '[' << x.X << ',' << x.Y << ',' << x.Z << ']'
|
#define JV3(x) '[' << x.X << ',' << x.Y << ',' << x.Z << ']'
|
||||||
#define JLOGAND(x,y) { JLOG(x); y }
|
#define JLOGAND(x,y) { JLOG(x); y }
|
||||||
|
@ -907,7 +907,7 @@ inline float stof(std::string s)
|
|||||||
|
|
||||||
//throws if error
|
//throws if error
|
||||||
template<class T, class Str>
|
template<class T, class Str>
|
||||||
inline T stonum_ex(const typename Str& s)
|
inline T stonum_ex(const Str& s)
|
||||||
{
|
{
|
||||||
typedef typename Str::value_type char_t;
|
typedef typename Str::value_type char_t;
|
||||||
T f;
|
T f;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user