示例#1
0
void parse_commands(uint8_t *str) {
  uint8_t *token;
  
  do {
    token = (uint8_t*)strtok((char*)str, " \t"); //split on spaces and tabs
    str = NULL;
    if (token) addObj(token);
  } while (token);
}
示例#2
0
fListItem::fListItem(char* fileName)
  : drawGroup(FLI_X, FLI_Y, FLI_W, FLI_H) {

  // Set up the bits..
  mText = new bmpLabel(TXT_X, TXT_Y, TXT_W, TXT_H, fileName, &paper);
  mText->setFastDraw(false);
  mText->setColors(&pencil);
  mSelector = new DBSelector(mText);
  mMarker = new marker(MK_X, MK_Y, MK_W, MK_H);
  mPlayFile = new playFile(mText);
  
  // Add them in the correct order.
  // NOTE: Let the list delete them.
  addObj(mText);
  addObj(mSelector);
  addObj(mPlayFile);
  addObj(mMarker);
}
示例#3
0
void ModelFactory::addObj(std::string name)
{
    ObjLoader objLoader;
    obj_data obj = objLoader.import(objSource + name + ".obj");
    obj.name = name;
    objMap.insert(std::pair<std::string, obj_data>(name, obj));

    // create blank frame for animation hiding
    if (!isBlankSet) {
        isBlankSet = true;
        addObj("blank");
    }
}
示例#4
0
文件: gncTaxTable.c 项目: mlq/gnucash
/* Create/Destroy Functions */
GncTaxTable *
gncTaxTableCreate (QofBook *book)
{
    GncTaxTable *table;
    if (!book) return NULL;

    table = g_object_new (GNC_TYPE_TAXTABLE, NULL);
    qof_instance_init_data (&table->inst, _GNC_MOD_NAME, book);
    table->name = CACHE_INSERT ("");
    addObj (table);
    qof_event_gen (&table->inst, QOF_EVENT_CREATE, NULL);
    return table;
}
示例#5
0
/* Create/Destroy Functions */
GncBillTerm * gncBillTermCreate (QofBook *book)
{
    GncBillTerm *term;
    if (!book) return NULL;

    term = g_object_new (GNC_TYPE_BILLTERM, NULL);
    qof_instance_init_data(&term->inst, _GNC_MOD_NAME, book);
    term->name = CACHE_INSERT ("");
    term->desc = CACHE_INSERT ("");
    term->discount = gnc_numeric_zero ();
    addObj (term);
    qof_event_gen (&term->inst,  QOF_EVENT_CREATE, NULL);
    return term;
}
示例#6
0
GncBillTerm *
gncCloneBillTerm (GncBillTerm *from, QofBook *book)
{
    GList *node;
    GncBillTerm *term;

    if (!book || !from) return NULL;

    term = g_object_new (GNC_TYPE_BILLTERM, NULL);
    qof_instance_init_data(&term->inst, _GNC_MOD_NAME, book);
    qof_instance_gemini (&term->inst, &from->inst);

    term->name = CACHE_INSERT (from->name);
    term->desc = CACHE_INSERT (from->desc);
    term->type = from->type;
    term->due_days = from->due_days;
    term->disc_days = from->disc_days;
    term->discount = from->discount;
    term->cutoff = from->cutoff;
    term->invisible = from->invisible;

    term->refcount = 0;

    /* Make copies of parents and children. Note that this can be
     * a recursive copy ... treat as doubly-linked list. */
    if (from->child)
    {
        term->child = gncBillTermObtainTwin (from->child, book);
        term->child->parent = term;
    }
    if (from->parent)
    {
        term->parent = gncBillTermObtainTwin (from->parent, book);
        term->parent->child = term;
    }
    for (node = g_list_last(from->children); node; node = node->next)
    {
        GncBillTerm *btrm = node->data;
        btrm = gncBillTermObtainTwin (btrm, book);
        btrm->parent = term;
        term->children = g_list_prepend(term->children, btrm);
    }

    addObj (term);
    qof_event_gen (&term->inst, QOF_EVENT_CREATE, NULL);
    return term;
}
示例#7
0
/**
 * Loads the system.
 */
void load() {
   FILE *file;
   file = fopen("save", "r");

   objs.clear();

   char *s;
   s = (char*)malloc(5012 * sizeof(char));
   while (1) {
      s = readWord(file);
      if (s == NULL) {
         break;
      }
      addObj(s);

      s = readLine(file); 
      if (s == NULL) {
         break;
      }
      objs.back()->readString(s);
   }
   fclose(file);
}
示例#8
0
ICPWidget::ICPWidget(QWidget *parent) :
    QFrame(parent),
    ui(new Ui::ICPWidget)
{
    ui->setupUi(this);

    v.initCameraParameters();
    v.setBackgroundColor(1.0,1.0,1.0);
    v.addCoordinateSystem(0.3);
    v.registerPointPickingCallback<ICPWidget>(&ICPWidget::pick,*this,NULL);
    v.registerKeyboardCallback<ICPWidget>(&ICPWidget::key,*this,NULL);

    widget.SetRenderWindow(v.getRenderWindow());

    ui->frameView->layout()->addWidget(&widget);
    ui->tools->setCurrentIndex(0);

    QString dataInfo;
    Pipe::loadData(_FrameKeyList,dataInfo,Pipe::_FrameListKey);
    Pipe::loadData(_IdMapKeyList,dataInfo,Pipe::_IdMapListKey);
    frameCloud = FullPointCloud::Ptr(new FullPointCloud);
    segCloud = FullPointCloud::Ptr(new FullPointCloud);
    currentFrame = 0;
    currentState = PICK_FRAME;
    currentObjIndex = -1;

    connect(ui->nextFrame,SIGNAL(clicked()),this,SLOT(nextFrame()));
    connect(ui->lastFrame,SIGNAL(clicked()),this,SLOT(lastFrame()));
    connect(ui->loadFrame,SIGNAL(clicked()),this,SLOT(reLoadFrameWithView()));
    connect(ui->addObj,SIGNAL(clicked()),this,SLOT(addObj()));
    connect(ui->delObj,SIGNAL(clicked()),this,SLOT(delObj()));
    connect(ui->icpObj,SIGNAL(clicked()),this,SLOT(icpObj()));

    connect(ui->tools,SIGNAL(currentChanged(int)),this,SLOT(changeState(int)));
    connect(ui->outObj,SIGNAL(clicked()),this,SLOT(outputObj()));
    connect(ui->outFrame,SIGNAL(clicked()),this,SLOT(outputFrame()));
}
示例#9
0
 INT32 aggrProjectParser::parseSelectorField( const BSONElement &beField,
                                           const CHAR *pCLName,
                                           qgmOPFieldVec &selectorVec,
                                           _qgmPtrTable *pTable,
                                           BOOLEAN &hasFunc )
 {
    INT32 rc = SDB_OK;
    try
    {
       if ( beField.isNumber() )
       {
          if ( beField.number() == 0 )
          {
             goto done;
          }
          const CHAR *pAlias = beField.fieldName();
          const CHAR *pPara = beField.fieldName();
          rc = addField( pAlias, pPara, pCLName, selectorVec, pTable );
          PD_RC_CHECK( rc, PDERROR,
                      "failed to add the field(name=%s, rc=%d)",
                      pPara, rc );
       }
       else if ( beField.type() == String )
       {
          const CHAR *pAlias = beField.fieldName();
          const CHAR *pPara = beField.valuestr();
          PD_CHECK( AGGR_KEYWORD_PREFIX == pPara[0], SDB_INVALIDARG, error, PDERROR,
                   "failed to parse selector field(%s), parameter must begin with \"$\"",
                   pPara );
          rc = addField( pAlias, &(pPara[1]), pCLName, selectorVec, pTable );
          PD_RC_CHECK( rc, PDERROR,
                      "failed to add the field(alias-name=%s, para-name=%s, rc=%d)",
                      pAlias, pPara, rc );
       }
       else if ( beField.type() == Object )
       {
          const CHAR *pAlias = beField.fieldName();
          BSONObj fieldObj = beField.embeddedObject();
          rc = addObj( pAlias, fieldObj, pCLName, selectorVec, pTable );
          PD_RC_CHECK( rc, PDERROR,
                      "failed add the function(alis-name=%s, rc=%d)",
                      pAlias, rc );
          hasFunc = TRUE;
       }
       else
       {
          PD_RC_CHECK( SDB_INVALIDARG, PDERROR,
                      "failed to parse the field(%s), invalid field type!",
                      beField.fieldName() );
       }
    }
    catch ( std::exception &e )
    {
       PD_CHECK( SDB_INVALIDARG, SDB_INVALIDARG, error, PDERROR,
                "failed to parse selector field, received unexpected error:%s",
                e.what() );
    }
 done:
    return rc;
 error:
    goto done;
 }
示例#10
0
bool World::loadWorld(Common::MacResManager *resMan) {
	Common::MacResIDArray resArray;
	Common::SeekableReadStream *res;
	Common::MacResIDArray::const_iterator iter;

	// Dumping interpreter code
#if 1
	res = resMan->getResource(MKTAG('C','O','D','E'), 1);
	warning("code size: %d", res->size());
	byte *buf = (byte *)malloc(res->size());
	res->read(buf, res->size());
	Common::DumpFile out;
	out.open("code.bin");
	out.write(buf, res->size());
	out.close();
	free(buf);
	delete res;
#endif

	if ((resArray = resMan->getResIDArray(MKTAG('G','C','O','D'))).size() == 0)
		return false;

	// Load global script
	res = resMan->getResource(MKTAG('G','C','O','D'), resArray[0]);
	_globalScript = new Script(res);

	// TODO: read creator

	// Load main configuration
	if ((resArray = resMan->getResIDArray(MKTAG('V','E','R','S'))).size() == 0)
		return false;

	_name = resMan->getBaseFileName();

	if (resArray.size() > 1)
		warning("Too many VERS resources");

	if (!resArray.empty()) {
		debug(3, "Loading version info");

		res = resMan->getResource(MKTAG('V','E','R','S'), resArray[0]);

		res->skip(10);
		byte b = res->readByte();
		_weaponMenuDisabled = (b != 0);
		if (b != 0 && b != 1)
			error("Unexpected value for weapons menu");

		res->skip(3);
		_aboutMessage = readPascalString(res);

		if (!scumm_stricmp(resMan->getBaseFileName().c_str(), "Scepters"))
			res->skip(1); // ????

		_soundLibrary1 = readPascalString(res);
		_soundLibrary2 = readPascalString(res);

		delete res;
	}

	Common::String *message;
	if ((message = loadStringFromDITL(resMan, 2910, 1)) != NULL) {
		message->trim();
		debug(2, "_gameOverMessage: %s", message->c_str());
		_gameOverMessage = message;
	}
	if ((message = loadStringFromDITL(resMan, 2480, 3)) != NULL) {
		message->trim();
		debug(2, "_saveBeforeQuitMessage: %s", message->c_str());
		_saveBeforeQuitMessage = message;
	}
	if ((message = loadStringFromDITL(resMan, 2490, 3)) != NULL) {
		message->trim();
		debug(2, "_saveBeforeCloseMessage: %s", message->c_str());
		_saveBeforeCloseMessage = message;
	}
	if ((message = loadStringFromDITL(resMan, 2940, 2)) != NULL) {
		message->trim();
		debug(2, "_revertMessage: %s", message->c_str());
		_revertMessage = message;
	}

	// Load scenes
	resArray = resMan->getResIDArray(MKTAG('A','S','C','N'));
	debug(3, "Loading %d scenes", resArray.size());

	for (iter = resArray.begin(); iter != resArray.end(); ++iter) {
		res = resMan->getResource(MKTAG('A','S','C','N'), *iter);
		Scene *scene = new Scene(resMan->getResName(MKTAG('A','S','C','N'), *iter), res);

		res = resMan->getResource(MKTAG('A','C','O','D'), *iter);
		if (res != NULL)
			scene->_script = new Script(res);

		res = resMan->getResource(MKTAG('A','T','X','T'), *iter);
		if (res != NULL) {
			scene->_textBounds = readRect(res);
			scene->_fontType = res->readUint16BE();
			scene->_fontSize = res->readUint16BE();

			Common::String text;
			while (res->pos() < res->size()) {
				char c = res->readByte();
				if (c == 0x0d)
					c = '\n';
				text += c;
			}
			scene->_text = text;

			delete res;
		}
		addScene(scene);
	}

	// Load Objects
	resArray = resMan->getResIDArray(MKTAG('A','O','B','J'));
	debug(3, "Loading %d objects", resArray.size());

	for (iter = resArray.begin(); iter != resArray.end(); ++iter) {
		res = resMan->getResource(MKTAG('A','O','B','J'), *iter);
		addObj(new Obj(resMan->getResName(MKTAG('A','O','B','J'), *iter), res));
	}

	// Load Characters
	resArray = resMan->getResIDArray(MKTAG('A','C','H','R'));
	debug(3, "Loading %d characters", resArray.size());

	for (iter = resArray.begin(); iter != resArray.end(); ++iter) {
		res = resMan->getResource(MKTAG('A','C','H','R'), *iter);
		Chr *chr = new Chr(resMan->getResName(MKTAG('A','C','H','R'), *iter), res);

		addChr(chr);
		// TODO: What if there's more than one player character?
		if (chr->_playerCharacter)
			_player = chr;
	}

	// Load Sounds
	resArray = resMan->getResIDArray(MKTAG('A','S','N','D'));
	debug(3, "Loading %d sounds", resArray.size());

	for (iter = resArray.begin(); iter != resArray.end(); ++iter) {
		res = resMan->getResource(MKTAG('A','S','N','D'), *iter);
		addSound(new Sound(resMan->getResName(MKTAG('A','S','N','D'), *iter), res));
	}

	if (!_soundLibrary1.empty()) {
		loadExternalSounds(_soundLibrary1);
	}
	if (!_soundLibrary2.empty()) {
		loadExternalSounds(_soundLibrary2);
	}

	// Load Patterns
	res = resMan->getResource(MKTAG('P','A','T','#'), 900);
	if (res != NULL) {
		int count = res->readUint16BE();
		debug(3, "Loading %d patterns", count);

		for (int i = 0; i < count; i++) {
			byte *pattern = (byte *)malloc(8);

			res->read(pattern, 8);
			_patterns->push_back(pattern);
		}

		delete res;
	} else {
		/* Enchanted Scepters did not use the PAT# resource for the textures. */
		res = resMan->getResource(MKTAG('C','O','D','E'), 1);
		if (res != NULL) {
			res->skip(0x55ac);
			for (int i = 0; i < 29; i++) {
				byte *pattern = (byte *)malloc(8);

				res->read(pattern, 8);
				_patterns->push_back(pattern);
			}
		}
		delete res;
	}

	res = resMan->getResource(MKTAG('M','E','N','U'), 2001);
	if (res != NULL) {
		Common::StringArray *menu = readMenu(res);
		_aboutMenuItemName.clear();
		Common::String string = menu->operator[](1);

		for (uint i = 0; i < string.size() && string[i] != ';'; i++) // Read token
			_aboutMenuItemName += string[i];

		delete menu;
		delete res;
	}
	res = resMan->getResource(MKTAG('M','E','N','U'), 2004);
	if (res != NULL) {
		Common::StringArray *menu = readMenu(res);
		_commandsMenuName = menu->operator[](0);
		_commandsMenu = menu->operator[](1);
		delete menu;
		delete res;
	}
	res = resMan->getResource(MKTAG('M','E','N','U'), 2005);
	if (res != NULL) {
		Common::StringArray *menu = readMenu(res);
		_weaponsMenuName = menu->operator[](0);
		delete menu;
		delete res;
	}
	// TODO: Read Apple menu and get the name of that menu item..

	// store global info in state object for use with save/load actions
	//world.setCurrentState(initialState);	// pass off the state object to the world

	return true;
}
示例#11
0
void mdItem::create(double nx, double ny)
{
	Item *obj = new Item(nx, ny);  
	addObj(obj);  
}
示例#12
0
// Initializes last times, inventory, scrolls, etc
int Monster::initMonster(bool loadOriginal, bool prototype) {
    int n=0, alnum=0, x=0;
    long t=0;
    Object* object=0;

    t = time(0);
    // init the timers
    lasttime[LT_MON_SCAVANGE].ltime =
    lasttime[LT_MON_WANDER].ltime =
    lasttime[LT_MOB_THIEF].ltime =
    lasttime[LT_TICK].ltime = t;
    lasttime[LT_TICK_SECONDARY].ltime = t;
    lasttime[LT_TICK_HARMFUL].ltime = t;

    // Make sure armor is set properly
    if(armor < (unsigned)(balancedStats[MIN<short>(level, MAXALVL)].armor - 150)) {
        armor = balancedStats[MIN<short>(level, MAXALVL)].armor;
    }

    if(dexterity.getCur() < 200)
        setAttackDelay(30);
    else
        setAttackDelay(20);

    if(flagIsSet(M_FAST_TICK))
        lasttime[LT_TICK].interval = lasttime[LT_TICK_SECONDARY].interval = 15L;
    else if(flagIsSet(M_REGENERATES))
        lasttime[LT_TICK].interval = lasttime[LT_TICK_SECONDARY].interval = 15L;
    else
        lasttime[LT_TICK].interval = lasttime[LT_TICK_SECONDARY].interval = 60L - (2*bonus((int)constitution.getCur()));

    lasttime[LT_TICK_HARMFUL].interval = 30;
    // Randomize alignment and gold unless we don' want it
    if(!loadOriginal) {
        if(flagIsSet(M_ALIGNMENT_VARIES) && alignment != 0) {
            alnum = mrand(1,100);
            if(alnum == 1)
                alignment = 0;
            else if(alnum < 51)
                alignment = mrand((short)1, (short)std::abs(alignment)) * -1;
            else
                alignment = mrand((short)1, (short)std::abs(alignment));
        }

        if(!flagIsSet(M_NO_RANDOM_GOLD) && coins[GOLD])
            coins.set(mrand(coins[GOLD]/10, coins[GOLD]), GOLD);
    }
    // Check for loading of random scrolls
    if(checkScrollDrop()) {
        n = new_scroll(level, &object);
        if(n > 0) {
            object->value.zero();
            addObj(object);
            object->setFlag(O_JUST_LOADED);
        }
    }

    // Now load up any always drop objects (Trading perms don't drop inventory items)
    if(!flagIsSet(M_TRADES)) {
        for(x=0;x<10;x++) {
            if(!loadObject(carry[x].info, &object))
                continue;
            object->init(!prototype);
            if( object->flagIsSet(O_ALWAYS_DROPPED) &&
                !object->getName().empty() &&
                object->getName()[0] != ' ' )
            {
                addObj(object);
                object->setFlag(O_JUST_LOADED);
            } else {
                delete object;
                continue;
            }
        }

        object = 0;

        int numDrops = mrand(1,100), whichDrop=0;

             if(numDrops<90)    numDrops=1;
        else if(numDrops<96)    numDrops=2;
        else                    numDrops=3;

        if(prototype)
            numDrops = 10;
        for(x=0; x<numDrops; x++) {
            if(prototype)
                whichDrop=x;
            else
                whichDrop = mrand(0,9);
            if(carry[whichDrop].info.id && !flagIsSet(M_TRADES)) {
                if(!loadObject(carry[whichDrop].info, &object))
                    continue;
                if( object->getName().empty() || object->getName()[0] == ' ')
                {
                    delete object;
                    continue;
                }

                object->init(!prototype);

                // so we don't get more than one always drop item.
                if(object->flagIsSet(O_ALWAYS_DROPPED)) {
                    delete object;
                    continue;
                }

                object->value.set(mrand((object->value[GOLD]*9)/10,(object->value[GOLD]*11)/10), GOLD);

                addObj(object);
                object->setFlag(O_JUST_LOADED);
            }
        }
    }

    if(weaponSkill < (level * 3))
        weaponSkill = (level-1) * mrand(9,11);
    return(1);
}