Bugfix: spaces in teleport names.

Changed client-side teleport info presentation
master
jachoo 2011-11-19 05:15:35 +01:00
parent 060888c0cc
commit 38e6a39f59
6 changed files with 46 additions and 15 deletions

View File

@ -391,7 +391,7 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
video::SColor c = MapBlock_LightColor(255, l);*/
video::SColor c(0xFFFFFFFF);
float d = (float)BS/16;
float d = BS/8;
// Wall at X+ of node
/*video::S3DVertex vertices[4] =
{

View File

@ -50,6 +50,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
*/
#include "content_mapnode.h"
#include "content_nodemeta.h"
#include "teleports.h"
/*
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(BS*0.42,-BS*0.8,-BS*0.8),
v3f(BS*0.49, BS*0.8, BS*0.8),
v3f(BS*0.37,-BS*0.8,-BS*0.8),
v3f(BS*0.42, BS*0.8, BS*0.8),
};
for(s32 i=0; i<2; i++)
@ -469,12 +471,12 @@ void getPointedNode(Client *client, v3f player_position,
vertices[i].rotateXYBy(90);
else{
if(dir == v3s16(1,0,0))
vertices[i].rotateXZBy(0);
if(dir == v3s16(-1,0,0))
;//vertices[i].rotateXZBy(0);
else if(dir == v3s16(-1,0,0))
vertices[i].rotateXZBy(180);
if(dir == v3s16(0,0,1))
else if(dir == v3s16(0,0,1))
vertices[i].rotateXZBy(90);
if(dir == v3s16(0,0,-1))
else if(dir == v3s16(0,0,-1))
vertices[i].rotateXZBy(-90);
vertices[i].Y += BS/2;
}
@ -1807,6 +1809,33 @@ void the_game(
content_t content = map->getNodeNoEx(nodepos).getContent();
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.
// find 3rd comma
/*int icomma=infotext.find(L',');

View File

@ -1832,9 +1832,8 @@ bool getTeleportTarget(/*const*/ ServerEnvironment& env,/*in+out*/ v3s16 &where,
else {
// check player "head block"
where.Y++;
if(where.Y<MAP_GENERATION_LIMIT-1)
if(map.getNode(where).getContent() == CONTENT_TELEPORT)
meta = (SignNodeMetadata*)map.getNodeMetadata(where);
if(map.getNode(where).getContent() == CONTENT_TELEPORT)
meta = (SignNodeMetadata*)map.getNodeMetadata(where);
}
if(meta){

View File

@ -103,7 +103,9 @@ void TeleportsManager::save(Settings& args) const
std::ostringstream os;
for(links_t::const_iterator it=m_links.begin(); it!=m_links.end(); it++){
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
if(t.coords[i].X == TELEPORT_IGNORE) //if coord ignored - don't save Y and Z
os << TELEPORT_IGNORE << ' ';
@ -120,8 +122,9 @@ void TeleportsManager::load(Settings& args)
while(is.good() && !is.eof()){
std::string name;
is >> name;
if(name.length() == 0) continue;
if(is.bad() || is.eof()) break;
if(name.length() == 0) continue;
str_replace_char(name,'\xFF',' ');
for(int i=0; i<2; i++){
v3s16 v;
is >> v.X;
@ -196,7 +199,7 @@ bool getTeleportInfo(TeleportInfo& ti, const std::string& text, bool allowCoords
//find if parts[0] has target name
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>0) ti.thisName = trim(parts[0].substr(0,pos));

View File

@ -77,7 +77,7 @@ private:
#if 1
#ifndef NDEBUG
#define JLOG(x) std::cout << x << std::endl
#define JV3(x) '[' << x.X << ',' << x.Y << ',' << x.Z << ']'
#define JLOGAND(x,y) { JLOG(x); y }

View File

@ -907,7 +907,7 @@ inline float stof(std::string s)
//throws if error
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;
T f;