Ejemplo n.º 1
0
string TgTypeParser::parseMessage(const Message::Ptr& object) const {
	if (!object) {
		return "";
	}
	string result;
	result += '{';
	appendToJson(result, "message_id", object->messageId);
	appendToJson(result, "from", parseUser(object->from));
	appendToJson(result, "date", object->date);
	appendToJson(result, "chat", parseChat(object->chat));
	appendToJson(result, "forward_from", parseUser(object->forwardFrom));
	appendToJson(result, "forward_date", object->forwardDate);
	appendToJson(result, "reply_to_message", parseMessage(object->replyToMessage));
	appendToJson(result, "text", object->text);
	appendToJson(result, "audio", parseAudio(object->audio));
	appendToJson(result, "document", parseDocument(object->document));
	appendToJson(result, "photo", parseArray(&TgTypeParser::parsePhotoSize, object->photo));
	appendToJson(result, "sticker", parseSticker(object->sticker));
	appendToJson(result, "video", parseVideo(object->video));
	appendToJson(result, "contact", parseContact(object->contact));
	appendToJson(result, "location", parseLocation(object->location));
	appendToJson(result, "new_chat_participant", parseUser(object->newChatParticipant));
	appendToJson(result, "left_chat_participant", parseUser(object->leftChatParticipant));
	appendToJson(result, "new_chat_title", object->newChatTitle);
	appendToJson(result, "new_chat_photo", parseArray(&TgTypeParser::parsePhotoSize, object->newChatPhoto));
	appendToJson(result, "delete_chat_photo", object->deleteChatPhoto);
	appendToJson(result, "group_chat_created", object->groupChatCreated);
	appendToJson(result, "caption", object->caption);
	result.erase(result.length() - 1);
	result += '}';
	return result;
}
Ejemplo n.º 2
0
void InspectorDebuggerAgent::setBreakpoint(ErrorString* errorString, const RefPtr<InspectorObject>& location, const RefPtr<InspectorObject>* options, TypeBuilder::Debugger::BreakpointId* outBreakpointId, RefPtr<TypeBuilder::Debugger::Location>& actualLocation)
{
    String scriptId;
    int lineNumber;
    int columnNumber;

    if (!parseLocation(errorString, location, &scriptId, &lineNumber, &columnNumber))
        return;

    String condition = emptyString();
    bool autoContinue = false;
    RefPtr<InspectorArray> actions;
    if (options) {
        (*options)->getString("condition", &condition);
        (*options)->getBoolean("autoContinue", &autoContinue);
        actions = (*options)->getArray("actions");
    }

    Vector<ScriptBreakpointAction> breakpointActions;
    if (!breakpointActionsFromProtocol(errorString, actions, &breakpointActions))
        return;

    String breakpointId = scriptId + ':' + String::number(lineNumber) + ':' + String::number(columnNumber);
    if (m_breakpointIdToDebugServerBreakpointIds.find(breakpointId) != m_breakpointIdToDebugServerBreakpointIds.end()) {
        *errorString = "Breakpoint at specified location already exists.";
        return;
    }
    ScriptBreakpoint breakpoint(lineNumber, columnNumber, condition, breakpointActions, autoContinue);
    actualLocation = resolveBreakpoint(breakpointId, scriptId, breakpoint);
    if (actualLocation)
        *outBreakpointId = breakpointId;
    else
        *errorString = "Could not resolve breakpoint";
}
Ejemplo n.º 3
0
/**
	@return 0 on success
*/
int datareader_tmy3_header(DataReader *d){
	Tmy3Location loc;
	d->data = ASC_NEW(Tmy3Data);
	DATA(d)->p = parseCreateFile(d->f);
	parse *p = DATA(d)->p;
	char rubbish[2049];

	if(!(
		parseLocation(p,&loc)
		&& parseStrExcept(p,"\r\n",rubbish,2048)
		&& parseEOL(p)
	)){
		ERROR_REPORTER_HERE(ASC_PROG_ERROR,"Parser error in header part of file");
	}

	CONSOLE_DEBUG("TMY3 file for '%s' at (%.2fN,%.2fE)",loc.stationname,loc.latitude,loc.longitude);

    // set the value of some of the Data Reader parameters
    d->i = 0;
    d->ninputs = 1;
    d->ndata = 8760; // FIXME -- is a variable length file possible?
    d->nmaxoutputs = 7; // FIXME

    DATA(d)->rows = ASC_NEW_ARRAY(Tmy3Point,d->ndata);

	/* set the number of inputs and outputs */
	d->ninputs = 1;
	d->noutputs = 7;
	return 0;
}
Ejemplo n.º 4
0
		void getAddress(float lat, float lon,std::string &address){

			bool placeIDExist(false);
			mapValue.clear();

			pqxx::nontransaction nType((*ptrConn));

	        for (int i=0; i < 10; ++i){

	        	sql="select place_id,parent_place_id,rank_search from placex WHERE ST_DWithin(ST_SetSRID(ST_Point("+std::to_string(lon)+","+std::to_string(lat)+"),4326), "
	   		         "geometry, "+std::to_string(radius)+") and rank_search != 28 and rank_search >= 26 and (name is not null or housenumber is not null) and"
	   		         " class not in ('waterway','railway','tunnel','bridge') and indexed_status = 0 and "
	   		         "(ST_GeometryType(geometry) not in ('ST_Polygon','ST_MultiPolygon') "
	   		         "OR ST_DWithin(ST_SetSRID(ST_Point("+std::to_string(lon)+","+std::to_string(lat)+"),4326), centroid, "+std::to_string(radius)+")) "
	   		         "ORDER BY ST_distance(ST_SetSRID(ST_Point("+std::to_string(lon)+","+std::to_string(lat)+"),4326), geometry) ASC limit 1";

	        	//std::cout << sql << std::endl;

	        	resultSet = nType.exec(sql);

				if (!resultSet.empty()) {
					for (pqxx::result::const_iterator c = resultSet.begin(); c != resultSet.end(); ++c){
						//cout << '\t' << c[0].as(string()) << '\t' << c[1].as(string()) <<'\t' << c[2].as(string()) <<endl;
						place_id = c[0].as(std::string());
					}
					placeIDExist=true;
					break;
				}

				radius*=2;

	        }// end of for loop

	        if(placeIDExist){

	        	resultSet = nType.exec("select name,class,type from get_addressdata(" + place_id + ") where isaddress order by rank_address asc");

	            if (!resultSet.empty()) {
	            	for (pqxx::result::const_iterator c = resultSet.begin(); c != resultSet.end(); ++c){
	            		parseLocation( c[0].as(std::string()), c[1].as(std::string()), c[2].as(std::string()));
	            	}
	            }

	        }

	        printAddress(address);

		} // end of func getAddress
Ejemplo n.º 5
0
    void Sector::loadData(const std::string& filePath) {
        std::ifstream fileStream;
        std::vector<short int> texData;
        short int height;

        std::cerr << "Loading sector " << Util::File::getFilenameExtensionless(filePath) << "... ";

        fileStream.open(filePath, std::ifstream::binary | std::ifstream::in);

        if(fileStream == false)
            throw new Util::Exception::FatalError(std::string("Unable to load heightmap from file: ") + filePath);

        for(int y = _mapSize - 1; y >= 0; y--) {
            for(int x = 0; x < _mapSize; ++x) {
                fileStream.read(reinterpret_cast<char*>(&height), sizeof(height));

                _heightMap[y][x] = swapEndiannes(height);
                texData.push_back(_heightMap[y][x]);
            }
        }
        
        fileStream.close();
        
        parseLocation(Util::File::getFilenameExtensionless(filePath));

        /**
         * Texture
         */
        glPixelStorei(GL_UNPACK_ALIGNMENT, 2);

        std::list<std::pair<GLenum, GLint>> parameters;
        parameters.push_back(std::make_pair<GLenum, GLint>(GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE));
        parameters.push_back(std::make_pair<GLenum, GLint>(GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE));

        _texture.setTarget(GL::Texture::Target::Tex2D);
        _texture.setFormat(GL::Texture::Format::RED);
        _texture.setInternalFromat(GL::Texture::InternalFormat::R16);
        _texture.bind();
            _texture.setData2D(1201, 1201, GL_SHORT, &texData[0]);
            _texture.setParameters();
            _texture.setParametersI(parameters);
            _texture.generateMipmap();
        _texture.unbind();

        std::cout << "done." << std::endl;
    }
Ejemplo n.º 6
0
void InspectorDebuggerAgent::continueToLocation(ErrorString& errorString, const InspectorObject& location)
{
    if (m_continueToLocationBreakpointID != JSC::noBreakpointID) {
        scriptDebugServer().removeBreakpoint(m_continueToLocationBreakpointID);
        m_continueToLocationBreakpointID = JSC::noBreakpointID;
    }

    JSC::SourceID sourceID;
    unsigned lineNumber;
    unsigned columnNumber;
    if (!parseLocation(errorString, location, sourceID, lineNumber, columnNumber))
        return;

    ScriptBreakpoint breakpoint(lineNumber, columnNumber, "", false);
    m_continueToLocationBreakpointID = scriptDebugServer().setBreakpoint(sourceID, breakpoint, &lineNumber, &columnNumber);
    resume(errorString);
}
Ejemplo n.º 7
0
void InspectorDebuggerAgent::continueToLocation(ErrorString* errorString, const RefPtr<InspectorObject>& location)
{
    if (!m_continueToLocationBreakpointId.isEmpty()) {
        scriptDebugServer().removeBreakpoint(m_continueToLocationBreakpointId);
        m_continueToLocationBreakpointId = "";
    }

    String scriptId;
    int lineNumber;
    int columnNumber;

    if (!parseLocation(errorString, location, &scriptId, &lineNumber, &columnNumber))
        return;

    ScriptBreakpoint breakpoint(lineNumber, columnNumber, "", false);
    m_continueToLocationBreakpointId = scriptDebugServer().setBreakpoint(scriptId, breakpoint, &lineNumber, &columnNumber);
    resume(errorString);
}
Ejemplo n.º 8
0
void InspectorDebuggerAgent::setBreakpoint(ErrorString* errorString, PassRefPtr<InspectorObject> location, const String* const optionalCondition, String* outBreakpointId, RefPtr<InspectorObject>& actualLocation)
{
    String scriptId;
    int lineNumber;
    int columnNumber;

    if (!parseLocation(errorString, location, &scriptId, &lineNumber, &columnNumber))
        return;

    String condition = optionalCondition ? *optionalCondition : emptyString();

    String breakpointId = scriptId + ':' + String::number(lineNumber) + ':' + String::number(columnNumber);
    if (m_breakpointIdToDebugServerBreakpointIds.find(breakpointId) != m_breakpointIdToDebugServerBreakpointIds.end())
        return;
    ScriptBreakpoint breakpoint(lineNumber, columnNumber, condition);
    actualLocation = resolveBreakpoint(breakpointId, scriptId, breakpoint);
    if (actualLocation)
        *outBreakpointId = breakpointId;
    else
        *errorString = "Could not resolve breakpoint";
}
Ejemplo n.º 9
0
void Parallaction_ns::changeCharacter(const char *name) {
	debugC(1, kDebugExec, "changeCharacter(%s)", name);

	_char.setName(name);

	if (!scumm_stricmp(_char.getFullName(), _characterName1)) {
		debugC(3, kDebugExec, "changeCharacter: nothing done");
		return;
	}

	freeCharacter();

	_char._ani->gfxobj = _gfx->loadCharacterAnim(_char.getFullName());

	if (!_char.dummy()) {
		_char._head = _disk->loadHead(_char.getBaseName());
		_char._talk = _disk->loadTalk(_char.getBaseName());
		_objects = _disk->loadObjects(_char.getBaseName());
		_objectsNames = _disk->loadTable(_char.getBaseName());

		if (!_intro) {
			// prevent music changes during the introduction
			_soundManI->playCharacterMusic(_char.getBaseName());
		}

		// The original engine used to reload 'common' only on loadgames. We are reloading here since 'common'
		// contains character specific stuff. This causes crashes like bug #1816899, because parseLocation tries
		// to reload scripts but the data archive selected is occasionally wrong. This has been solved by having
		// parseLocation only load scripts when they aren't already loaded - which it should have done since the
		// beginning nevertheless.
		if (!(getFeatures() & GF_DEMO))
			parseLocation("common");
	}

	strcpy(_characterName1, _char.getFullName());

	debugC(3, kDebugExec, "changeCharacter: switch completed");

	return;
}
Ejemplo n.º 10
0
bool CupsdConf::loadFromFile(const QString &filename)
{
    QFile f(filename);
    if(!f.exists() || !f.open(IO_ReadOnly))
        return false;
    else
    {
        QTextStream t(&f);
        QString line;
        bool done(false), value(true);
        while(!done && value)
        {
            line = t.readLine().simplifyWhiteSpace();
            if(line.isEmpty())
            {
                if(t.atEnd())
                    done = true;
                else
                    continue;
            }
            else if(line[0] == '#')
                continue;
            else if(line.left(9).lower() == "<location")
            {
                CupsLocation *location = new CupsLocation();
                locations_.append(location);
                if(!location->parseResource(line) || !parseLocation(location, t))
                    value = false;
                // search corresponding resource
                for(resources_.first(); resources_.current(); resources_.next())
                    if(resources_.current()->path_ == location->resourcename_)
                        location->resource_ = resources_.current();
            }
            else
                value = parseOption(line);
        }
        f.close();
        return value;
    }
}
Ejemplo n.º 11
0
void InspectorDebuggerAgent::setBreakpoint(ErrorString& errorString, const InspectorObject& location, const InspectorObject* options, Inspector::Protocol::Debugger::BreakpointId* outBreakpointIdentifier, RefPtr<Inspector::Protocol::Debugger::Location>& actualLocation)
{
    JSC::SourceID sourceID;
    unsigned lineNumber;
    unsigned columnNumber;
    if (!parseLocation(errorString, location, sourceID, lineNumber, columnNumber))
        return;

    String condition = emptyString();
    bool autoContinue = false;
    unsigned ignoreCount = 0;
    RefPtr<InspectorArray> actions;
    if (options) {
        options->getString(ASCIILiteral("condition"), condition);
        options->getBoolean(ASCIILiteral("autoContinue"), autoContinue);
        options->getArray(ASCIILiteral("actions"), actions);
        options->getInteger(ASCIILiteral("ignoreCount"), ignoreCount);
    }

    BreakpointActions breakpointActions;
    if (!breakpointActionsFromProtocol(errorString, actions, &breakpointActions))
        return;

    String breakpointIdentifier = String::number(sourceID) + ':' + String::number(lineNumber) + ':' + String::number(columnNumber);
    if (m_breakpointIdentifierToDebugServerBreakpointIDs.find(breakpointIdentifier) != m_breakpointIdentifierToDebugServerBreakpointIDs.end()) {
        errorString = ASCIILiteral("Breakpoint at specified location already exists.");
        return;
    }

    ScriptBreakpoint breakpoint(lineNumber, columnNumber, condition, breakpointActions, autoContinue, ignoreCount);
    actualLocation = resolveBreakpoint(breakpointIdentifier, sourceID, breakpoint);
    if (!actualLocation) {
        errorString = ASCIILiteral("Could not resolve breakpoint");
        return;
    }

    *outBreakpointIdentifier = breakpointIdentifier;
}
void InspectorDebuggerAgent::setBreakpoint(ErrorString* errorString, const RefPtr<JSONObject>& location, const String* const optionalCondition, TypeBuilder::Debugger::BreakpointId* outBreakpointId, RefPtr<TypeBuilder::Debugger::Location>& actualLocation)
{
    String scriptId;
    int lineNumber;
    int columnNumber;

    if (!parseLocation(errorString, location, &scriptId, &lineNumber, &columnNumber))
        return;

    String condition = optionalCondition ? *optionalCondition : emptyString();

    String breakpointId = generateBreakpointId(scriptId, lineNumber, columnNumber, UserBreakpointSource);
    if (m_breakpointIdToDebugServerBreakpointIds.find(breakpointId) != m_breakpointIdToDebugServerBreakpointIds.end()) {
        *errorString = "Breakpoint at specified location already exists.";
        return;
    }
    ScriptBreakpoint breakpoint(lineNumber, columnNumber, condition);
    actualLocation = resolveBreakpoint(breakpointId, scriptId, breakpoint, UserBreakpointSource);
    if (actualLocation)
        *outBreakpointId = breakpointId;
    else
        *errorString = "Could not resolve breakpoint";
}
Ejemplo n.º 13
0
 bool parseComplement(U2Location &location, QString &errorReport) {
     if(!match(Token::LEFT_PARENTHESIS)) {
         ioLog.trace(QString("GENBANK LOCATION PARSER: Must be LEFT_PARENTHESIS instead of %1").arg(lexer.peek().getString().data()));
         errorReport = LocationParser::tr("Must be LEFT_PARENTHESIS instead of %1").arg(lexer.peek().getString().data());
         return false;
     }
     if (location->regions.isEmpty()) {
         location->strand = U2Strand::Complementary;
     }
     // the following doesn't match the specification
     do {
         if(!parseLocation(location, errorReport)) {
             ioLog.trace(QString("GENBANK LOCATION PARSER: Can't parse location on COMPLEMENT"));
             errorReport = LocationParser::tr("Can't parse location on COMPLEMENT");
             return false;
         }
     } while (match(Token::COMMA));
     if(!match(Token::RIGHT_PARENTHESIS)) {
         ioLog.trace(QString("GENBANK LOCATION PARSER: Must be RIGHT_PARENTHESIS instead of %1").arg(lexer.peek().getString().data()));
         errorReport = LocationParser::tr("Must be RIGHT_PARENTHESIS instead of %1").arg(lexer.peek().getString().data());
         return false;
     }
     return true;
 }
// returns false on bad mime
bool HttpMime::parse(char *mime, int32_t mimeLen, Url *url) {
#ifdef _VALGRIND_
	VALGRIND_CHECK_MEM_IS_DEFINED(mime,mimeLen);
#endif
	// reset locUrl to 0
	m_locUrl.reset();

	// return if we have no valid complete mime
	if (mimeLen == 0) {
		return false;
	}

	// status is on first line
	m_status = -1;

	// skip HTTP/x.x till we hit a space
	char *p = mime;
	char *pend = mime + mimeLen;
	while (p < pend && !is_wspace_a(*p)) p++;
	// then skip over spaces
	while (p < pend && is_wspace_a(*p)) p++;
	// return false on a problem
	if (p == pend) return false;
	// then read in the http status
	m_status = atol2(p, pend - p);
	// if no Content-Type: mime field was provided, assume html
	m_contentType = CT_HTML;
	// assume default charset
	m_charset = NULL;
	m_charsetLen = 0;

	// skip over first line
	getNextLine();

	while (getNextLine()) {
		const char *field = NULL;
		size_t fieldLen = 0;

		if (getField(&field, &fieldLen)) {
			if (parseContentEncoding(field, fieldLen)) {
				continue;
			}

			if (parseContentLength(field, fieldLen)) {
				continue;
			}

			if (parseContentType(field, fieldLen)) {
				continue;
			}

			if (parseLocation(field, fieldLen, url)) {
				continue;
			}

			if (parseSetCookie(field, fieldLen)) {
				continue;
			}

			// add parsing of other header here
		}
	}

	return true;
}
Ejemplo n.º 15
0
    bool parseLocation(U2Location &location, QString &errorReport) {
        if(match(Token::JOIN)) {
            if(!match(Token::LEFT_PARENTHESIS)) {
                ioLog.trace(QString("GENBANK LOCATION PARSER: Wrong token after JOIN %1").arg(lexer.peek().getString().data()));
                errorReport = LocationParser::tr("Wrong token after JOIN %1").arg(lexer.peek().getString().data());
                return false;
            }
            if(order) {
                ioLog.trace(QString("GENBANK LOCATION PARSER: Wrong token after JOIN  - order %1").arg(lexer.peek().getString().data()));
                errorReport = LocationParser::tr("Wrong token after JOIN  - order %1").arg(lexer.peek().getString().data());
                return false;
            }
            join = true;
            location->op = U2LocationOperator_Join;
            do {
                if(!parseLocation(location, errorReport)) {
                    ioLog.trace(QString("GENBANK LOCATION PARSER: Can't parse location on JOIN"));
                    errorReport = LocationParser::tr("Can't parse location on JOIN");
                    return false;
                }
            } while (match(Token::COMMA));
            if(!match(Token::RIGHT_PARENTHESIS)) {
                ioLog.trace(QString("GENBANK LOCATION PARSER: Must be RIGHT_PARENTHESIS instead of %1").arg(lexer.peek().getString().data()));
                errorReport = LocationParser::tr("Must be RIGHT_PARENTHESIS instead of %1").arg(lexer.peek().getString().data());
                return false;
            }
        } else if(match(Token::ORDER)) {
            if(!match(Token::LEFT_PARENTHESIS)) {
                ioLog.trace(QString("GENBANK LOCATION PARSER: Wrong token after ORDER %1").arg(lexer.peek().getString().data()));
                errorReport = LocationParser::tr("Wrong token after ORDER %1").arg(lexer.peek().getString().data());
                return false;
            }
            if(join) {
                ioLog.trace(QString("GENBANK LOCATION PARSER: Wrong token after ORDER - join %1").arg(lexer.peek().getString().data()));
                return false;
            }
            order = true;
            location->op = U2LocationOperator_Order;
            do {
                if(!parseLocation(location, errorReport)) {
                    ioLog.trace(QString("GENBANK LOCATION PARSER: Can't parse location on ORDER"));
                    errorReport = LocationParser::tr("Can't parse location on ORDER");
                    return false;
                }
            } while (match(Token::COMMA));
            if(!match(Token::RIGHT_PARENTHESIS)) {
                ioLog.trace(QString("GENBANK LOCATION PARSER: Must be RIGHT_PARENTHESIS instead of %1").arg(lexer.peek().getString().data()));
                errorReport = LocationParser::tr("Must be RIGHT_PARENTHESIS instead of %1").arg(lexer.peek().getString().data());
                return false;
            }
        } else if (match(Token::BOND)) {
            if(!match(Token::LEFT_PARENTHESIS)) {
                ioLog.trace(QString("GENBANK LOCATION PARSER: Wrong token after BOND %1").arg(lexer.peek().getString().data()));
                errorReport = LocationParser::tr("Wrong token after BOND %1").arg(lexer.peek().getString().data());
                return false;
            }
            bond = true;
            location->op = U2LocationOperator_Bond;
            do {
                if(!parseLocation(location, errorReport)) {
                    ioLog.trace(QString("GENBANK LOCATION PARSER: Can't parse location on BOND"));
                    errorReport = LocationParser::tr("Can't parse location on BONDs");
                    return false;
                }
            } while (match(Token::COMMA));
            if(!match(Token::RIGHT_PARENTHESIS)) {
                ioLog.trace(QString("GENBANK LOCATION PARSER: Must be RIGHT_PARENTHESIS instead of %1").arg(lexer.peek().getString().data()));
                errorReport = LocationParser::tr("Must be RIGHT_PARENTHESIS instead of %1").arg(lexer.peek().getString().data());
                return false;
            }

        }else if (match(Token::COMPLEMENT)) {
            return parseComplement(location, errorReport);
        } else {
            do {
                if(!parseLocationDescriptor(location, errorReport)) {
                    ioLog.trace(QString("GENBANK LOCATION PARSER: Can't parse location descriptor"));
                    return false;
                }
            } while (match(Token::COMMA));
        }
        return true;
    }
Ejemplo n.º 16
0
void Parallaction_br::changeLocation() {
	if (_newLocationName.empty()) {
		return;
	}

	if (_nextPart != -1) {
		cleanupGame();

		// more cleanup needed for part changes (see also saveload)
		_globalFlags = 0;
		cleanInventory(true);
		strcpy(_characterName1, "null");

		_part = _nextPart;

		if (getFeatures() & GF_DEMO) {
			assert(_part == 1);
		} else {
			assert(_part >= 0 && _part <= 4);
		}

		_disk->selectArchive(_partNames[_part]);

		memset(_counters, 0, ARRAYSIZE(_counters));

		_globalFlagsNames = _disk->loadTable("global");
		_objectsNames = _disk->loadTable("objects");
		_countersNames = _disk->loadTable("counters");

		// TODO: maybe handle this into Disk
		delete _objects;
		if (getPlatform() == Common::kPlatformPC) {
			_objects = _disk->loadObjects("icone.ico");
		} else {
			_objects = _disk->loadObjects("icons.ico", _part);
		}

		parseLocation("common.slf");
	}

	freeLocation(false);
	// load new location
	strcpy(_location._name, _newLocationName.c_str());
	parseLocation(_location._name);

	if (_location._startPosition.x != -1000) {
		_char._ani->setFoot(_location._startPosition);
		_char._ani->setF(_location._startFrame);
	}

	// re-link the follower animation
	setFollower(_followerName);
	if (_follower) {
		Common::Point p = _location._followerStartPosition;
		if (p.x == -1000) {
			_char._ani->getFoot(p);
		}
		_follower->setFoot(p);
		_follower->setF(_location._followerStartFrame);
	}

	_location._startPosition.x = -1000;
	_location._startPosition.y = -1000;
	_location._followerStartPosition.x = -1000;
	_location._followerStartPosition.y = -1000;

	_gfx->setScrollPosX(0);
	_gfx->setScrollPosY(0);
	if (_char._ani->gfxobj) {
		Common::Point foot;
		_char._ani->getFoot(foot);

		if (foot.x > 550)
			_gfx->setScrollPosX(320);

		if (foot.y > 350)
			_gfx->setScrollPosY(foot.y - 350);
	}

	// kFlagsRemove is cleared because the character is visible by default.
	// Commands can hide the character, anyway.
	_char._ani->_flags &= ~kFlagsRemove;
	_cmdExec->run(_location._commands);

	doLocationEnterTransition();

	_cmdExec->run(_location._aCommands);

	// NOTE: music should not started here!
	// TODO: implement the music commands which control music execution
	_soundMan->execute(SC_PLAYMUSIC);

	_engineFlags &= ~kEngineChangeLocation;
	_newLocationName.clear();
	_nextPart = -1;
}
Ejemplo n.º 17
0
//	changeLocation handles transitions between locations, and is able to display slides
//	between one and the other.
//
void Parallaction_ns::changeLocation() {
	if (_newLocationName.empty()) {
		return;
	}

	char location[200];
	strcpy(location, _newLocationName.c_str());
	strcpy(_location._name, _newLocationName.c_str());

	debugC(1, kDebugExec, "changeLocation(%s)", location);

	MouseTriState oldMouseState = _input->getMouseState();
	_input->setMouseState(MOUSE_DISABLED);

	if (!_intro) {
		// prevent music changes during the introduction
		_soundManI->playLocationMusic(location);
	}

	_input->stopHovering();
	// this is still needed to remove the floatingLabel
	_gfx->freeLabels();

	_zoneTrap.reset();

	_input->setArrowCursor();

	_gfx->showGfxObj(_char._ani->gfxobj, false);

	LocationName locname;
	locname.bind(location);

	freeLocation(false);

	if (locname.hasSlide()) {
		showSlide(locname.slide());
		GfxObj *label = _gfx->createLabel(_menuFont, _location._slideText[0].c_str(), 1);
		_gfx->showLabel(label, CENTER_LABEL_HORIZONTAL, 14);
		_gfx->updateScreen();

		_input->waitForButtonEvent(kMouseLeftUp);
		_gfx->unregisterLabel(label);
		delete label;
	}

	if (locname.hasCharacter()) {
		changeCharacter(locname.character());
	}

	strcpy(g_saveData1, locname.location());
	parseLocation(g_saveData1);

	if (_location._startPosition.x != -1000) {
		_char._ani->setX(_location._startPosition.x);
		_char._ani->setY(_location._startPosition.y);
		_char._ani->setF(_location._startFrame);
		_location._startPosition.y = -1000;
		_location._startPosition.x = -1000;
	}


	_gfx->setBlackPalette();
	_gfx->updateScreen();

	// BUG #1837503: kEngineChangeLocation flag must be cleared *before* commands
	// and acommands are executed, so that it can be set again if needed.
	g_engineFlags &= ~kEngineChangeLocation;

	_cmdExec->run(_location._commands);

	doLocationEnterTransition();

	_cmdExec->run(_location._aCommands);

	if (_location._hasSound)
		_soundManI->playSfx(_location._soundFile, 0, true);

	if (!_intro) {
		_input->setMouseState(oldMouseState);
		// WORKAROUND: Fix a script bug in the Multilingual DOS version of
		// Nippon Safes: the mouse cursor is incorrectly hidden outside the
		// cave at the end of the game. Fix it here.
		if (!strcmp(_location._name, "ingressocav"))
			_input->setMouseState(MOUSE_ENABLED_SHOW);
	}

	debugC(1, kDebugExec, "changeLocation() done");
	_newLocationName.clear();
}
Ejemplo n.º 18
0
bool QGeoCodeXmlParser::parsePlace(QGeoPlace *place)
{
    /*
    <xsd:complexType name="Place">
        <xsd:all>
            <xsd:element name="location" type="gc:Location"/>
            <xsd:element minOccurs="0" name="address" type="gc:Address"/>
            <xsd:element minOccurs="0" name="alternatives" type="gc:Alternatives"/>
        </xsd:all>
        <xsd:attribute name="title" type="xsd:string" use="required"/>
        <xsd:attribute name="language" type="gc:LanguageCode" use="required"/>
    </xsd:complexType>

    <xsd:simpleType name="LanguageCode">
        <xsd:restriction base="xsd:string">
            <xsd:length value="3"/>
        </xsd:restriction>
    </xsd:simpleType>
    */

    Q_ASSERT(m_reader->isStartElement() && m_reader->name() == "place");

    if (!m_reader->attributes().hasAttribute("title")) {
        m_reader->raiseError("The element \"place\" did not have the required attribute \"title\".");
        return false;
    }

    if (!m_reader->attributes().hasAttribute("language")) {
        //m_reader->raiseError("The element \"place\" did not have the required attribute \"language\".");
        //return false;
    } else {
        QString lang = m_reader->attributes().value("language").toString();

        if (lang.length() != 3) {
            m_reader->raiseError(QString("The attribute \"language\" of the element \"place\" was not of length 3 (length was %1).").arg(lang.length()));
            return false;
        }
    }

    bool parsedLocation = false;
    bool parsedAddress = false;
    bool parsedAlternatives = false;

    while (m_reader->readNextStartElement()) {
        QString name = m_reader->name().toString();
        if (name == "location") {
            if (parsedLocation) {
                m_reader->raiseError("The element \"place\" has multiple child elements named \"location\" (exactly one expected)");
                return false;
            }

            if (!parseLocation(place))
                return false;

            parsedLocation = true;
        } else if (name == "address") {
            if (parsedAddress) {
                m_reader->raiseError("The element \"place\" has multiple child elements named \"address\" (at most one expected)");
                return false;
            }

            QGeoAddress address;
            if (!parseAddress(&address))
                return false;
            else
                place->setAddress(address);

            place->setAddress(address);

            parsedAddress = true;
        } else if (name == "alternatives") {
            if (parsedAlternatives) {
                m_reader->raiseError("The element \"place\" has multiple child elements named \"alternatives\" (at most one expected)");
                return false;
            }

            // skip alternatives for now
            // need to work out if we have a use for them at all
            // and how to store them if we get them
            m_reader->skipCurrentElement();

            parsedAlternatives = true;
        } else {
            m_reader->raiseError(QString("The element \"place\" did not expect a child element named \"%1\".").arg(m_reader->name().toString()));
            return false;
        }
    }

    if (!parsedLocation) {
        m_reader->raiseError("The element \"place\" has no child elements named \"location\" (exactly one expected)");
        return false;
    }

    return true;
}