本文整理汇总了C++中Town::setName方法的典型用法代码示例。如果您正苦于以下问题:C++ Town::setName方法的具体用法?C++ Town::setName怎么用?C++ Town::setName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Town
的用法示例。
在下文中一共展示了Town::setName方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseTowns
bool IOMap::parseTowns(OTB::Loader& loader, const OTB::Node& townsNode, Map& map)
{
for (auto& townNode : townsNode.children) {
PropStream propStream;
if (townNode.type != OTBM_TOWN) {
setLastErrorString("Unknown town node.");
return false;
}
if (!loader.getProps(townNode, propStream)) {
setLastErrorString("Could not read town data.");
return false;
}
uint32_t townId;
if (!propStream.read<uint32_t>(townId)) {
setLastErrorString("Could not read town id.");
return false;
}
Town* town = map.towns.getTown(townId);
if (!town) {
town = new Town(townId);
map.towns.addTown(townId, town);
}
std::string townName;
if (!propStream.readString(townName)) {
setLastErrorString("Could not read town name.");
return false;
}
town->setName(townName);
OTBM_Destination_coords town_coords;
if (!propStream.read(town_coords)) {
setLastErrorString("Could not read town coordinates.");
return false;
}
town->setTemplePos(Position(town_coords.x, town_coords.y, town_coords.z));
}
return true;
}
示例2: loadMap
//.........这里部分代码省略.........
{
NODE nodeTown = f.getChildNode(nodeMapData, type);
while(nodeTown != NO_NODE)
{
if(type == OTBM_TOWN)
{
if(!f.getProps(nodeTown, propStream))
{
setLastErrorString("Could not read town data.");
return false;
}
uint32_t townId = 0;
if(!propStream.GET_ULONG(townId))
{
setLastErrorString("Could not read town id.");
return false;
}
Town* town = Towns::getInstance().getTown(townId);
if(!town)
{
town = new Town(townId);
Towns::getInstance().addTown(townId, town);
}
std::string townName = "";
if(!propStream.GET_STRING(townName))
{
setLastErrorString("Could not read town name.");
return false;
}
town->setName(townName);
OTBM_Destination_coords *town_coords;
if(!propStream.GET_STRUCT(town_coords))
{
setLastErrorString("Could not read town coordinates.");
return false;
}
town->setTemplePos(Position(town_coords->_x, town_coords->_y, town_coords->_z));
}
else
{
setLastErrorString("Unknown town node.");
return false;
}
nodeTown = f.getNextNode(nodeTown, type);
}
}
else if(type == OTBM_WAYPOINTS && headerVersion > 1)
{
NODE nodeWaypoint = f.getChildNode(nodeMapData, type);
while(nodeWaypoint != NO_NODE)
{
if(type == OTBM_WAYPOINT)
{
if(!f.getProps(nodeWaypoint, propStream))
{
setLastErrorString("Could not read waypoint data.");
return false;
}
std::string name;
示例3: loadMap
//.........这里部分代码省略.........
item->setLoadedFromMap(true);
}
}
nodeItem = f.getNextNode(nodeItem, type);
}
if (!tile) {
tile = createTile(ground_item, nullptr, px, py, pz);
}
tile->setFlag(static_cast<tileflags_t>(tileflags));
map->setTile(px, py, pz, tile);
nodeTile = f.getNextNode(nodeTile, type);
}
} else if (type == OTBM_TOWNS) {
NODE nodeTown = f.getChildNode(nodeMapData, type);
while (nodeTown != NO_NODE) {
if (type != OTBM_TOWN) {
setLastErrorString("Unknown town node.");
return false;
}
if (!f.getProps(nodeTown, propStream)) {
setLastErrorString("Could not read town data.");
return false;
}
uint32_t townId;
if (!propStream.read<uint32_t>(townId)) {
setLastErrorString("Could not read town id.");
return false;
}
Town* town = map->towns.getTown(townId);
if (!town) {
town = new Town(townId);
map->towns.addTown(townId, town);
}
std::string townName;
if (!propStream.readString(townName)) {
setLastErrorString("Could not read town name.");
return false;
}
town->setName(townName);
const OTBM_Destination_coords* town_coords;
if (!propStream.readStruct(town_coords)) {
setLastErrorString("Could not read town coordinates.");
return false;
}
town->setTemplePos(Position(town_coords->x, town_coords->y, town_coords->z));
nodeTown = f.getNextNode(nodeTown, type);
}
} else if (type == OTBM_WAYPOINTS && headerVersion > 1) {
NODE nodeWaypoint = f.getChildNode(nodeMapData, type);
while (nodeWaypoint != NO_NODE) {
if (type != OTBM_WAYPOINT) {
setLastErrorString("Unknown waypoint node.");
return false;
}
if (!f.getProps(nodeWaypoint, propStream)) {
setLastErrorString("Could not read waypoint data.");
return false;
}
std::string name;
if (!propStream.readString(name)) {
setLastErrorString("Could not read waypoint name.");
return false;
}
const OTBM_Destination_coords* waypoint_coords;
if (!propStream.readStruct(waypoint_coords)) {
setLastErrorString("Could not read waypoint coordinates.");
return false;
}
map->waypoints[name] = Position(waypoint_coords->x, waypoint_coords->y, waypoint_coords->z);
nodeWaypoint = f.getNextNode(nodeWaypoint, type);
}
} else {
setLastErrorString("Unknown map node.");
return false;
}
nodeMapData = f.getNextNode(nodeMapData, type);
}
std::cout << "> Map loading time: " << (OTSYS_TIME() - start) / (1000.) << " seconds." << std::endl;
return true;
}
示例4: loadMap
//.........这里部分代码省略.........
return false;
}
nodeTile = f.getNextNode(nodeTile, type);
}
}
else if(type == OTBM_TOWNS){
NODE nodeTown = f.getChildNode(nodeMapData, type);
while(nodeTown != NO_NODE){
if(type == OTBM_TOWN){
if(!f.getProps(nodeTown, propStream)){
setLastErrorString("Could not read town data.");
return false;
}
uint32_t townid = 0;
if(!propStream.GET_UINT32(townid)){
setLastErrorString("Could not read town id.");
return false;
}
Town* town = Towns::getInstance().getTown(townid);
if(!town){
town = new Town(townid);
Towns::getInstance().addTown(townid, town);
}
std::string townName = "";
if(!propStream.GET_STRING(townName)){
setLastErrorString("Could not read town name.");
return false;
}
town->setName(townName);
OTBM_TownTemple_coords town_coords;
if( !propStream.GET_UINT16(town_coords._x) ||
!propStream.GET_UINT16(town_coords._y) ||
!propStream.GET_UINT8(town_coords._z))
{
setLastErrorString("Could not read town coordinates.");
return false;
}
Position pos;
pos.x = town_coords._x;
pos.y = town_coords._y;
pos.z = town_coords._z;
town->setTemplePos(pos);
}
else{
setLastErrorString("Unknown town node.");
return false;
}
nodeTown = f.getNextNode(nodeTown, type);
}
}
else if(type == OTBM_WAYPOINTS && header_version >= 2){
NODE nodeWaypoint = f.getChildNode(nodeMapData, type);
while(nodeWaypoint != NO_NODE){
if(type == OTBM_WAYPOINT){
if(!f.getProps(nodeWaypoint, propStream)){
setLastErrorString("Could not read waypoint data.");
return false;
}
示例5: loadMap
//.........这里部分代码省略.........
BinaryNode* townNode = mapNode->getChild();
if(townNode) do {
uint8_t town_type;
if(!townNode->getByte(town_type)) {
warning(wxT("Could not read town type"));
continue;
}
if(town_type != OTMM_TOWN) {
warning(wxT("Unknown town type"));
continue;
}
uint32_t town_id;
if(!townNode->getU32(town_id)) {
warning(wxT("Invalid town id"));
continue;
}
Town* town = map.towns.getTown(town_id);
if(town) {
warning(wxT("Duplicate town id %d, discarding duplicate"), town_id);
continue;
} else {
town = newd Town(town_id);
if(!map.towns.addTown(town)) {
delete town;
continue;
}
}
std::string town_name;
if(!townNode->getString(town_name)) {
warning(wxT("Invalid town name"));
continue;
}
town->setName(town_name);
Position pos;
uint16_t x;
uint16_t y;
uint8_t z;
if(!townNode->getU16(x) ||
!townNode->getU16(y) ||
!townNode->getU8(z))
{
warning(wxT("Invalid town temple position"));
continue;
}
pos.x = x;
pos.y = y;
pos.z = z;
town->setTemplePosition(pos);
} while(townNode->advance());
} break;
case OTMM_HOUSE_DATA: {
BinaryNode* houseNode = mapNode->getChild();
if(houseNode) do {
uint8_t house_type;
if(!houseNode->getByte(house_type)) {
warning(wxT("Could not read house type"));
continue;
}
if(house_type != OTMM_HOUSE) {
warning(wxT("Unknown house type."));
continue;
}
uint32_t house_id;
if(!houseNode->getU32(house_id)) {
warning(wxT("Could not read house id."));