Ejemplo n.º 1
0
int FWScript::o2_removeGfxElementType21() {
	uint16 a = getNextWord();
	uint16 b = getNextWord();
	debugC(5, kCineDebugScript, "Line: %d: o2_removeGfxElementType21(%d,%d)", _line, a, b);
	removeGfxElement(a, b, 21);
	return 0;
}
Ejemplo n.º 2
0
int FWScript::o2_removeGfxElementType20() {
	uint16 idx = getNextWord();
	uint16 param = getNextWord();
	debugC(5, kCineDebugScript, "Line: %d: o2_removeGfxElementType20(%d,%d)", _line, idx, param);
	removeGfxElement(idx, param, 20);
	return 0;
}
Ejemplo n.º 3
0
/*************************************************************************
    Return the number of lines the given text would be formatted to.
*************************************************************************/
size_t Font::getFormattedLineCount(const String& text, const Rect& format_area, TextFormatting fmt, float x_scale)
{
    // handle simple non-wrapped cases.
    if ((fmt == LeftAligned) || (fmt == Centred) || (fmt == RightAligned) || (fmt == Justified))
    {
        return std::count(text.begin(), text.end(), static_cast<utf8>('\n')) + 1;
    }

    // handle wraping cases
    size_t lineStart = 0, lineEnd = 0;
    String	sourceLine;

    float	wrap_width = format_area.getWidth();
    String  whitespace = TextUtils::DefaultWhitespace;
    String	thisLine, thisWord;
    size_t	line_count = 0, currpos = 0;

    while (lineEnd < text.length())
    {
        if ((lineEnd = text.find_first_of('\n', lineStart)) == String::npos)
        {
            lineEnd = text.length();
        }

        sourceLine = text.substr(lineStart, lineEnd - lineStart);
        lineStart = lineEnd + 1;

        // get first word.
        currpos = getNextWord(sourceLine, 0, thisLine);

        // while there are words left in the string...
        while (String::npos != sourceLine.find_first_not_of(whitespace, currpos))
        {
            // get next word of the string...
            currpos += getNextWord(sourceLine, currpos, thisWord);

            // if the new word would make the string too long
            if ((getTextExtent(thisLine, x_scale) + getTextExtent(thisWord, x_scale)) > wrap_width)
            {
                // too long, so that's another line of text
                line_count++;

                // remove whitespace from next word - it will form start of next line
                thisWord = thisWord.substr(thisWord.find_first_not_of(whitespace));

                // reset for a new line.
                thisLine.clear();
            }

            // add the next word to the line
            thisLine += thisWord;
        }

        // plus one for final line
        line_count++;
    }

    return line_count;
}
Ejemplo n.º 4
0
int FWScript::o2_addGfxElementType20() {
	uint16 param1 = getNextWord();
	uint16 param2 = getNextWord();

	debugC(5, kCineDebugScript, "Line: %d: o2_addGfxElementType20(%d,%d)", _line, param1, param2);
	addGfxElement(param1, param2, 20);
	return 0;
}
Ejemplo n.º 5
0
/**
 * @todo Implement this instruction
 * @note According to the scripts' opcode usage comparison this opcode isn't used at all.
 */
int FWScript::o2_op9C() {
	uint16 a = getNextWord();
	uint16 b = getNextWord();
	uint16 c = getNextWord();
	uint16 d = getNextWord();
	warning("STUB: o2_op9C(%x, %x, %x, %x)", a, b, c, d);
	return 0;
}
Ejemplo n.º 6
0
static ssize_t dbgcfgtool_write(struct file *fp, const char __user *buf,
			 size_t count, loff_t *pos)
{
    char* buf_idx;
    char szCommand[TEMP_BUF_SIZE * 3];
    char szMaskName[TEMP_BUF_SIZE];
    int mask;

    if(count > (DBGCFG_COMMAND_BUFFER_SIZE - 1))
    {
        return -EFAULT;
    }

    write_buf = kmalloc(DBGCFG_COMMAND_BUFFER_SIZE, GFP_KERNEL);
    if(write_buf)
    {
        memset(write_buf, 0, DBGCFG_COMMAND_BUFFER_SIZE);
    }
    else
    {
        return 0;
    }

    if(copy_from_user(write_buf, buf, count))
    {
        return -EFAULT;
    }
	
    write_buf[count] = '\0';
    //printk(KERN_INFO "dbgcfgtool_write: write_buf=%s=\n", write_buf);	
	
    buf_idx = write_buf;
    getNextWord(&buf_idx, szCommand, 30);

    if(!strncmp(szCommand, "HANG_LINUX", DBGCFG_COMMAND_BUFFER_SIZE))
    {
        printk(KERN_INFO "dbgcfgtool_write: hang linux\n");
        panic("dbgcfgtool");
    }
    else if(!strncmp(szCommand, "DALVIK_HEAP_DUMP", DBGCFG_COMMAND_BUFFER_SIZE))
    {
        getNextWord(&buf_idx, szMaskName, TEMP_BUF_SIZE);  //this is pid value.
        printk(KERN_INFO "dbgcfgtool_write: %s %s\n", szCommand, szMaskName);
        mask  = (int)simple_strtol(szMaskName, NULL, TEMP_BUF_SIZE);
        printk(KERN_INFO "dbgcfgtool_write: pid=%d sig=%d\n", mask, SIGUSR1);
        kill_proc_info(SIGUSR1, SEND_SIG_PRIV, mask);
    }

    *pos += count;

    if(write_buf)
    {
        kfree(write_buf);
        write_buf = NULL;
    }

    return count;
}
Ejemplo n.º 7
0
void AGOSEngine_Feeble::off_isAdjNoun() {
	// 165: item unk1 unk2 is
	Item *item = getNextItemPtr();
	int16 a = getNextWord(), b = getNextWord();
	if (item->adjective == a && item->noun == b)
		setScriptCondition(true);
	else if (a == -1 && item->noun == b)
		setScriptCondition(true);
	else
		setScriptCondition(false);
}
Ejemplo n.º 8
0
int FWScript::o2_modifySeqListElement() {
	byte a = getNextByte();
	byte b = getNextByte();
	uint16 c = getNextWord();
	uint16 d = getNextWord();
	byte e = getNextByte();
	debugC(5, kCineDebugScript, "Line: %d: o2_modifySeqListElement(%d,%d,%d,%d,%d)", _line, a, b, c, d, e);

	modifySeqListElement(a, 0, b, c, d, e);
	return 0;
}
Ejemplo n.º 9
0
void AGOSEngine::o_setAdjNoun() {
	// 130: set adj noun
	uint var = getVarOrByte();
	if (var == 1) {
		_scriptAdj1 = getNextWord();
		_scriptNoun1 = getNextWord();
	} else {
		_scriptAdj2 = getNextWord();
		_scriptNoun2 = getNextWord();
	}
}
Ejemplo n.º 10
0
int FWScript::o2_addSeqListElement() {
	byte param1 = getNextByte();
	byte param2 = getNextByte();
	byte param3 = getNextByte();
	byte param4 = getNextByte();
	uint16 param5 = getNextWord();
	uint16 param6 = getNextWord();
	uint16 param7 = getNextWord();

	debugC(5, kCineDebugScript, "Line: %d: addSeqListElement(%d,%d,%d,%d,%d,%d,%d)", _line, param1, param2, param3, param4, param5, param6, param7);
	addSeqListElement(param1, 0, param2, param3, param4, param5, param6, 0, param7);
	return 0;
}
Ejemplo n.º 11
0
int FWScript::o2_playSample() {
	if (g_cine->getPlatform() == Common::kPlatformAmiga || g_cine->getPlatform() == Common::kPlatformAtariST) {
		// no-op in these versions
		getNextByte();
		getNextByte();
		getNextWord();
		getNextByte();
		getNextWord();
		getNextWord();
		return 0;
	}
	return o1_playSample();
}
Ejemplo n.º 12
0
string
WKTReader::getNextEmptyOrOpener(StringTokenizer *tokenizer)
{
	string nextWord=getNextWord(tokenizer);

    // Skip the Z, M or ZM of an SF1.2 3/4 dim coordinate. 
    if (nextWord == "Z" || nextWord == "M" || nextWord == "ZM" )
        nextWord = getNextWord(tokenizer);

	if (nextWord=="EMPTY" || nextWord=="(") {
		return nextWord;
	}
	throw  ParseException("Expected 'Z', 'M', 'ZM', 'EMPTY' or '(' but encountered ",nextWord);
}
Ejemplo n.º 13
0
std::string wordcountmap(std::string inputFile, int64_t startOffset, int64_t endOffset)
{
  std::ifstream inFile;
  inFile.open(inputFile.c_str(), std::fstream::in);
  inFile.seekg (startOffset, inFile.beg); //read all till < endOffset
  std::string token;
  std::stringstream ss;
  uint64_t count =0;
 
  while(inFile.tellg() < endOffset){
    getNextWord(inFile,token," ",endOffset); //tokenizer

    if(token.size() == 0) continue;

    count++;
  }

  inFile.close();

  ss.clear();
  ss<<PATH<<getpid()<<fileAppend();
  std::string pidstr(ss.str());

  std::ofstream outFile;
  outFile.open(pidstr.c_str(), std::fstream::out);
  outFile<<"count "<<count<<std::endl;
  outFile.close();
  return ss.str();

}
Ejemplo n.º 14
0
void AGOSEngine_Elvira2::oe2_isAdjNoun() {
	// 179: item unk1 unk2 is
	Item *item = getNextItemPtr();
	int16 a = getNextWord();
	int16 n = getNextWord();

	if (getGameType() == GType_ELVIRA2 && item == NULL) {
		// WORKAROUND bug #1745996: A NULL item can occur when
		// interacting with items in the dinning room
		setScriptCondition(false);
		return;
	}

	assert(item);
	setScriptCondition(item->adjective == a && item->noun == n);
}
Ejemplo n.º 15
0
void AGOSEngine_Simon1::os1_screenTextMsg() {
	// 162: print string
	uint vgaSpriteId = getVarOrByte();
	uint color = getVarOrByte();
	uint stringId = getNextStringID();
	const byte *stringPtr = NULL;
	uint speechId = 0;
	TextLocation *tl;

	if (stringId != 0xFFFF)
		stringPtr = getStringPtrByID(stringId);

	if (getFeatures() & GF_TALKIE) {
		if (getGameType() == GType_FF || getGameType() == GType_PP)
			speechId = (uint16)getVarOrWord();
		else
			speechId = (uint16)getNextWord();
	}

	if (getGameType() == GType_FF || getGameType() == GType_PP)
		vgaSpriteId = 1;

	tl = getTextLocation(vgaSpriteId);
	if (_speech && speechId != 0)
		playSpeech(speechId, vgaSpriteId);
	if (((getGameType() == GType_SIMON2 && (getFeatures() & GF_TALKIE)) || getGameType() == GType_FF) &&
		speechId == 0) {
		stopAnimateSimon2(2, vgaSpriteId + 2);
	}

	if (stringPtr != NULL && stringPtr[0] != 0 && (speechId == 0 || _subtitles))
		printScreenText(vgaSpriteId, color, (const char *)stringPtr, tl->x, tl->y, tl->width);

}
Ejemplo n.º 16
0
/**
 * @brief Extract a global flag implementing a delta function
 *
 * This function extracts the condition, the sign of the flag and the resets
 */
void xppParser::extractGlobal(void) {
    auto line = lines.begin();
    while (line != lines.end()) {
        std::size_t pos1 = line->first.find("global");
        std::size_t pos2 = line->first.find(" ", pos1);
        if (pos1 != std::string::npos) {
            opts opt(line->second);

            /* Parse the sign flag. For simplicity store it in the name slot */
            opt.Name = getNextWord(*line, pos1, pos2);

            /* Parse flip condition. */
            pos1 = line->first.find_first_not_of(" ", pos2);
            pos2 = line->first.find("{", pos1);
            opt.Expr = line->first.substr(pos1, pos2-pos1-1);

            /* The individual resets are separated by a semicolon */
            opt.Args = getList(line->first.substr(pos2), opt.Line, "}", ";");
            Globals.push_back(opt);
            lines.erase(line);
        } else {
            ++line;
        }
    }
}
Ejemplo n.º 17
0
void TextRenderer::renderToBox(string text,float width, float height){

	int maxChars=width/renderWidth;
	int maxLines=height/renderHeight;
	int cnt=0;
	int begin=0;
	int x=0;
	int lx=0;

	while(x<text.length()){
    lx=x;
	x=getNextWord(text,x,maxChars);

	if(x-begin>maxChars){
	renderString(text.substr(begin,lx-begin),-cnt*renderHeight);
	cnt++;
    if(cnt>maxLines)
        break;

	begin=lx+1;

	}

    renderString(text.substr(begin,x-begin),-cnt*renderHeight);


	}

}
Ejemplo n.º 18
0
/**
 * @brief Extract a markov process from the parsed lines
 *
 * This function extracts the definition of markov processes as they constitute
 * one of the few multiline statements in an ode file.
 */
void xppParser::extractMarkov(void) {
    auto line = lines.begin();
    while (line != lines.end()) {
        std::size_t pos1 = line->first.find("markov");
        std::size_t pos2 = line->first.find(" ", pos1);
        if (pos1 != std::string::npos) {
            opts opt(line->second);

            opt.Name = getNextWord(*line, pos1, pos2);
            checkName(opt.Name, *line, pos1);

            /* Parse the number of states */
            int nstates;
            try {
                nstates = std::stoi(getNextWord(*line, pos1, pos2));
            } catch (std::invalid_argument) {
                throw xppParserException(EXPECTED_NUMBER, *line, pos1);
            }
            opt.Expr = nstates;

            /* Parse the transition probabilities */
            opt.Args.reserve(nstates*nstates);
            for (int i=0; i < nstates; i++) {
                auto line2 = std::next(line);
                pos2 = 0;
                for (int j=0; j < nstates; j++) {
                    pos1 = line2->first.find("{", pos2);
                    pos2 = line2->first.find("}", pos1);
                    if (pos1 == std::string::npos) {
                        throw xppParserException(MISSING_MARKOV_ASSIGNMENT,
                                                 *line2, pos2);
                    }
                    opt.Args.push_back(line2->first.substr(pos1+1, pos2-pos1-1));
                }
                if (pos2 != line2->first.size()-1) {
                    throw xppParserException(WRONG_MARKOV_ASSIGNMENT,
                                             *line2, line2->first.size());
                }
                lines.erase(line2);
            }
            Markovs.push_back(opt);
            lines.erase(line);
        } else {
            ++line;
        }
    }
}
Ejemplo n.º 19
0
/*************************************************************************
    draws wrapped text
*************************************************************************/
size_t Font::drawWrappedText(const String& text, const Rect& draw_area, float z, const Rect& clip_rect, TextFormatting fmt, const ColourRect& colours, float x_scale, float y_scale)
{
    size_t	line_count = 0;
    Rect	dest_area(draw_area);
    float	wrap_width = draw_area.getWidth();

    String  whitespace = TextUtils::DefaultWhitespace;
    String	thisLine, thisWord;
    size_t	currpos = 0;

    // get first word.
    currpos += getNextWord(text, currpos, thisLine);

    // while there are words left in the string...
    while (String::npos != text.find_first_not_of(whitespace, currpos))
    {
        // get next word of the string...
        currpos += getNextWord(text, currpos, thisWord);

        // if the new word would make the string too long
        if ((getTextExtent(thisLine, x_scale) + getTextExtent(thisWord, x_scale)) > wrap_width)
        {
            // output what we had until this new word
            line_count += drawText(thisLine, dest_area, z, clip_rect, fmt, colours, x_scale, y_scale);

            // remove whitespace from next word - it will form start of next line
            thisWord = thisWord.substr(thisWord.find_first_not_of(whitespace));

            // reset for a new line.
            thisLine.clear();

            // update y co-ordinate for next line
            dest_area.d_top += getLineSpacing(y_scale);
        }

        // add the next word to the line
        thisLine += thisWord;
    }

    // Last line is left aligned
    TextFormatting last_fmt = (fmt == Justified ? LeftAligned : fmt);
    // output last bit of string
    line_count += drawText(thisLine, dest_area, z, clip_rect, last_fmt, colours, x_scale, y_scale);

    return line_count;
}
Ejemplo n.º 20
0
void AGOSEngine_PuzzlePack::opp_iconifyWindow() {
	// 30
	getNextWord();
	if (_clockStopped != 0)
		_gameTime += getTime() - _clockStopped;
	_clockStopped = 0;
	_system->setFeatureState(OSystem::kFeatureIconifyWindow, true);
}
Ejemplo n.º 21
0
/**
 * @brief Parser::attachWords Attachs the words to the leaves of the tree
 * @param S the tree
 */
void Parser::attachWords(SyntaxTree& S){
    TNpair::TNvector L = S.getLeaves();
    for(std::size_t i = 0; i < L.size(); ++i){
        Word W = getNextWord(i);
        removeAllOtherTypes(W,GPtoWT[L[i]->data()._d.first]);
        L[i]->data()._d.second.setWord(W);
    }
}
Ejemplo n.º 22
0
string
WKTReader::getNextCloser(StringTokenizer *tokenizer)
{
	string nextWord=getNextWord(tokenizer);
	if (nextWord==")") {
		return nextWord;
	}
	throw  ParseException("Expected ')' but encountered",nextWord);
}
Ejemplo n.º 23
0
string
WKTReader::getNextEmptyOrOpener(StringTokenizer *tokenizer)
{
	string nextWord=getNextWord(tokenizer);
	if (nextWord=="EMPTY" || nextWord=="(") {
		return nextWord;
	}
	throw  ParseException("Expected 'EMPTY' or '(' but encountered ",nextWord);
}
Ejemplo n.º 24
0
int getNextInt(char **buf)
{char word[50];
 int i;
  
	getNextWord(buf,word);
	i=(uint32)strtoul(word,0,10);	 // nao .. entao le o valor corrente

	return i;
}
Ejemplo n.º 25
0
/**
 * @todo Implement this instruction
 * @note According to the scripts' opcode usage comparison this opcode isn't used at all.
 */
int FWScript::o2_op9B() {
	uint16 a = getNextWord();
	uint16 b = getNextWord();
	uint16 c = getNextWord();
	uint16 d = getNextWord();
	uint16 e = getNextWord();
	uint16 f = getNextWord();
	uint16 g = getNextWord();
	uint16 h = getNextWord();
	warning("STUB: o2_op9B(%x, %x, %x, %x, %x, %x, %x, %x)", a, b, c, d, e, f, g, h);
	return 0;
}
Ejemplo n.º 26
0
char * getNextStr(char **buf)
{char word[100];
 char *str;

	getNextWord(buf,word);
	str=mymalloc(strlen(word)+1);
	strcpy(str,word);

	return str;
}
Ejemplo n.º 27
0
/*************************************************************************
    returns extent of widest line of wrapped text.
*************************************************************************/
float Font::getWrappedTextExtent(const String& text, float wrapWidth, float x_scale)
{
    String  whitespace = TextUtils::DefaultWhitespace;
    String	thisWord;
    size_t	currpos;
    float	lineWidth, wordWidth;
    float	widest = 0;

    // get first word.
    currpos = getNextWord (text, 0, thisWord);
    lineWidth = getTextExtent (thisWord, x_scale);

    // while there are words left in the string...
    while (String::npos != text.find_first_not_of (whitespace, currpos))
    {
        // get next word of the string...
        currpos += getNextWord (text, currpos, thisWord);
        wordWidth = getTextExtent (thisWord, x_scale);

        // if the new word would make the string too long
        if ((lineWidth + wordWidth) > wrapWidth)
        {
            if (lineWidth > widest)
                widest = lineWidth;

            // remove whitespace from next word - it will form start of next line
            thisWord = thisWord.substr (thisWord.find_first_not_of (whitespace));
            wordWidth = getTextExtent (thisWord, x_scale);

            // reset for a new line.
            lineWidth = 0;
        }

        // add the next word to the line
        lineWidth += wordWidth;
    }

    if (lineWidth > widest)
        widest = lineWidth;

    return widest;
}
Ejemplo n.º 28
0
/**
 * @brief Extract exports to link to procompiled C routines inside xppaut
 *
 * This function extracts the in and out arguments of the respective function.
 * To keep with the other structures the Args vector contains both the input and
 * the output. Therefore the Expr string contains the number of input arguments.
 */
void xppParser::extractExport(void) {
    auto line = lines.begin();
    while (line != lines.end()) {
        std::size_t pos1 = line->first.find("export");
        std::size_t pos2 = line->first.find(" ", pos1);
        if (pos1 != std::string::npos) {
            opts opt(line->second);
            opt.Args = getList(getNextWord(*line, pos1, pos2), opt.Line, "}", ",");;
            opt.Expr = std::to_string(opt.Args.size());

            stringList temp = getList(getNextWord(*line, pos1, pos2), opt.Line, "}", ",");
            opt.Args.insert(opt.Args.end(), temp.begin(), temp.end());

            Exports.push_back(opt);
            lines.erase(line);
        } else {
            ++line;
        }
    }
}
Ejemplo n.º 29
0
void AGOSEngine_PuzzlePack::opp_restoreOopsPosition() {
	// 32: restore oops position
	uint i;

	getNextWord();
	getNextWord();

	if (_oopsValid) {
		for (i = 0; i < _numVars; i++) {
			_variableArray[i] = _variableArray2[i];
		}
		i = _variableArray[999] * 100 + 11;
		setWindowImage(4,i);
		_gameTime += 10;
		// Swampy adventures
		if (!getBitFlag(110))
			_gameTime += 20;
		_oopsValid = false;
	}
}
Ejemplo n.º 30
0
bool DBMS::parseCreateTable() {
	if (getNextWord(tableName, 32) == -1)
		return false;
	this->pos++; // skip '('

	// 生成链表
	Data *p = new Data;
	data = p; // head
	p->next = p;
	//TODO 没有检查返回值是-1的情况
	while (!endOfSql()) {
		p = p->next;
		getNextWord(p->name, 32);
		p->num = getNextWord(p->value, 32); // 如果是char,返回值是char的长度,否则为0
		p->next = new Data;
	}
	delete p->next;
	p->next = NULL;

	return true;
}