Exemplo n.º 1
0
QVariant TestVarint::value( int column, bool*, int ) const
{
    QVariant v;
//    switch (column) {
//        case 0: v = m_lsVar.at(recno()); break;
//        case 1: v = m_lsVar.at(recno()); break;
//        case 2: v = m_lsVar.at(recno()); break;
//        case 3: v = m_lsVar.at(recno()); break;
//        case 4: v = m_lsVar.at(recno()); break;
//    }
    if(column<m_lsVar.at(recno()).size())
//    if(column<m_colName.size())
        v=m_lsVar.at(recno()).at(column);
    return v;
}
Exemplo n.º 2
0
//--------- Begin of function TornadoArray::create_tornado ------//
//
// return: <int> recno of the tornado created. 
//
short TornadoArray::create_tornado()
{
	Tornado *tornadoPtr = new Tornado;
	add(tornadoPtr);

	return recno();
}
Exemplo n.º 3
0
Arquivo: ospya.cpp Projeto: mecirt/7k2
//--------- Begin of function SpyArray::add_spy ----------//
//
// <int> unitRecno - unit recno of the spy
// <int> spySkill  - spying skill of the unit
// [int] trueNation - true nation recno (default -1:unit's nation)
//
// return: <int> recno of the spy record added
//
int SpyArray::add_spy(int unitRecno, int spySkill, int trueNation)
{
	Spy 	spy;
	Unit* unitPtr = unit_array[unitRecno];

	memset( &spy, 0, sizeof(spy) );

	spy.spy_place 			= SPY_MOBILE;
	spy.spy_place_para	= unitRecno;
	spy.spy_skill 			= spySkill;
	spy.spy_loyalty 		= unitPtr->loyalty;
	spy.race_id			   = unitPtr->race_id;
	spy.is_civilian		= unitPtr->is_civilian();
	spy.name_id				= unitPtr->name_id;
	// ####### begin Gilbert 24/2 #######//
	spy.unique_id        = unitPtr->unique_id;
	// ####### end Gilbert 24/2 #######//

	err_when( unitPtr->race_id < 1 || unitPtr->race_id > MAX_RACE );

	err_when( nation_array.is_deleted(unitPtr->nation_recno) );

	err_when( trueNation == 0 );
	if( trueNation < 0 )
		trueNation = unitPtr->nation_recno;

	spy.true_nation_recno    = trueNation;
	spy.cloaked_nation_recno = unitPtr->nation_recno;

	//--- spies hold a use right of the name id even though the unit itself will register the usage right of the name already ---//

	race_res[spy.race_id]->use_name_id(spy.name_id);		// the spy will free it up in deinit(). Keep an additional right because when a spy is assigned to a town, the normal program will free up the name id., so we have to keep an additional copy

	// ------- set camouflage vars --------//

	spy.camouflage_count = 0;
	spy.camouflage_power = spySkill / 4;

	//------- link in the spy_array -------//

	linkin( &spy );

	((Spy*)get())->spy_recno = recno();

	return recno();
}
Exemplo n.º 4
0
TownNetwork* TownNetworkArray::add_network(int nationRecno)
{
	TownNetwork *network = new TownNetwork(nationRecno);
	
	linkin(&network);
	network->set_recno(recno());

	return network;
}
Exemplo n.º 5
0
bool CustomDataSet::open()
{
    if ( m_lsVar.isEmpty() ) {
        error()->setError(QString("No data in CustomDataSet datasource") );
        return false;
    }
    recno() =0;
    setOpened(true);
    return true;
}
Exemplo n.º 6
0
bool CustomDataSet::last()
{
    recno() = m_lsVar.count()-1;
    return true;
}
Exemplo n.º 7
0
bool CustomDataSet::first()
{
    recno()=0;
    return true;
}
Exemplo n.º 8
0
CustomDataSet::CustomDataSet(QObject * parent) : NCReportDataSource( parent )
{
    setDataSourceType(Custom);
    setLocationType(Static);
    recno() =0;
}
Exemplo n.º 9
0
bool CustomDataSet::close()
{
    recno() =0;
    setOpened(false);
    return true;
}
Exemplo n.º 10
0
//--------- Begin of function FirmArray::create_firm ---------//
//
// create_firm() will be called directly by :
//
// 1. FirmArray::build_firm()  for setting up a new firm
// 2. FirmArray::read_file() when loading game.
//
// <int> firmId = firm type id
//
// Return : <int> the record no. of the newly added firm
//
int FirmArray::create_firm(int firmId)
{
	Firm* firmPtr;

//	static char firmAnimalTrainArray[] = { UNIT_JAGUAR, UNIT_GORILLA, UNIT_RHINO, 0 };
	static char firmIncubatorTrainArray[] = { UNIT_BALLISTA, UNIT_CATAPULT, UNIT_CANNON, 0 };

	switch(firmId)
	{
		case FIRM_BASE:
			firmPtr = new FirmBase;
			break;

		case FIRM_FORT:
			firmPtr = new FirmFort;
			break;

		case FIRM_CAMP:
			firmPtr = new FirmCamp;
			break;

		case FIRM_FACTORY:
			firmPtr = new FirmFactory;
			break;

		case FIRM_INN:
			firmPtr = new FirmInn;
			break;

		case FIRM_MARKET:
			firmPtr = new FirmMarket;
			break;

		case FIRM_MINE:
			firmPtr = new FirmMine;
			break;

		case FIRM_RESEARCH:
			firmPtr = new FirmResearch;
			break;

		case FIRM_WAR_FACTORY:
			firmPtr = new FirmWar;
			break;

//		case FIRM_HARBOR:
//			firmPtr = new FirmHarbor;
//			break;

		case FIRM_SPY:
			firmPtr = new FirmSpy;
			break;

		case FIRM_SPECIAL:
			firmPtr = new FirmSpecial;
			break;

		case FIRM_LAIR:
			firmPtr = new FirmLair;
			break;

		case FIRM_BEE:
			firmPtr = new FirmMonsterTrain(UNIT_BEE);
			break;

		case FIRM_TERMITE:
			firmPtr = new FirmMonsterTrain(UNIT_TERMITE);
			break;
		
		case FIRM_LISHORR:
		case FIRM_WILDE_LISHORR:
			firmPtr = new FirmLishorr;
			break;

		case FIRM_ALCHEMY:
			firmPtr = new FirmMonsterAlchemy;
			break;

		case FIRM_INCUBATOR:
			firmPtr = new FirmIncubator;
			break;

		case FIRM_ANIMAL:
			firmPtr = new FirmAnimal;
			break;

		case FIRM_FORTRESS:
			firmPtr = new FirmMonsterFortress(UNIT_ROCK);
			break;

		case FIRM_MAGIC:
			firmPtr = new FirmMagic;
			break;

		case FIRM_OFFENSIVE_BUILDING_1:
		case FIRM_OFFENSIVE_BUILDING_2:
		case FIRM_OFFENSIVE_BUILDING_4:
			firmPtr = new FirmOffensive;
			break;

		case FIRM_OFFENSIVE_BUILDING_3:	
			firmPtr = new FirmOffensive2;
			break;

		default:
			err_now("FirmArray::create_firm()");
	}
 
	//----------------------------------------//

	linkin(&firmPtr);
	firmPtr->firm_recno = recno();

	return firmPtr->firm_recno;
}
Exemplo n.º 11
0
int FirmDieArray::add(FirmDie *r)
{
	linkin(r);
	return recno();
}
Exemplo n.º 12
0
bool TestVarint::last()
{
    recno() = m_lsVar.count()-1;
    return true;
}
Exemplo n.º 13
0
bool TestVarint::first()
{
    recno()=0;
    return true;
}
Exemplo n.º 14
0
bool TestVarint::close()
{
    recno() =0;
    setOpened(false);
    return true;
}
Exemplo n.º 15
0
Arquivo: osite.cpp Projeto: 112212/7k2
//--------- Begin of function SiteArray::add_site ---------//
//
// Add a raw item to the site array
//
// If the given location is occupied, it will locate a closest empty
// location to add the item.
//
// <int> xLoc, yLoc - the location of the site
// <int> siteType	  - site type
// <int> objectId   - site parameter
// [int] reserveQty - reserve qty, for raw site only
//
// Return : >0 - the recno of the site.
//          0  - duplicated, not added
//
int SiteArray::add_site(int xLoc, int yLoc, int siteType, int objectId, int reserveQty)
{
	//---- check if the given location is empty ----//

	int foundFlag = 0;

	int siteWidth = 1;
	int siteHeight = 1;
	int gapSpace = 0;
	if( siteType == SITE_RAW )
	{
		siteWidth = raw_res[objectId]->map_loc_width;
		siteHeight = raw_res[objectId]->map_loc_height;
		gapSpace = INTER_PLACE_SPACE;
	}

	if( world.can_build_site(xLoc, yLoc, siteWidth, siteHeight, gapSpace) )
	{
		foundFlag = 1;
	}
	else
	{
		//------ locate for empty space to add the item -------//

		#define ADD_SITE_RANGE	5

		int		 xOffset, yOffset;
		int		 curXLoc = xLoc, curYLoc = yLoc;
		Location* locPtr;
		BYTE	 	 regionId = world.get_region_id(curXLoc, curYLoc);

		for( int i=1 ; i<ADD_SITE_RANGE*ADD_SITE_RANGE ; i++ )
		{
			misc.cal_move_around_a_point(i, ADD_SITE_RANGE, ADD_SITE_RANGE, xOffset, yOffset);

			xLoc = curXLoc + xOffset;
			yLoc = curYLoc + yOffset;

			xLoc = MAX(0, xLoc);
			xLoc = MIN(MAX_WORLD_X_LOC-siteWidth, xLoc);

			yLoc = MAX(0, yLoc);
			yLoc = MIN(MAX_WORLD_Y_LOC-siteHeight, yLoc);

			locPtr = world.get_loc(xLoc, yLoc);

			if( world.can_build_site(xLoc, yLoc, siteWidth, siteHeight, gapSpace) 
				&& locPtr->region_id==regionId )
			{
				foundFlag = 1;
				break;
			}
		}
	}

	if( !foundFlag )
		return 0;

	//----- linkin the raw and update raw attribute ----//

	Site site;

	linkin(&site);

	Site* sitePtr = (Site*) get(recno());

	// #### begin Gilbert 1/2 ######//
	Location *locPtr = NULL;
	if( sizeof(locPtr->extra_para)==sizeof(unsigned char)
		&& recno() > 0xff )
	{
		linkout();
		return 0;
	}
	// #### end Gilbert 1/2 ######//

	sitePtr->init(recno(), siteType, xLoc, yLoc);

	sitePtr->object_id 	= objectId;
	sitePtr->reserve_qty = reserveQty;

	switch( siteType )
	{
		case SITE_RAW:
			untapped_raw_count++;
			break;

		case SITE_SCROLL:
			scroll_count++;
			break;

		case SITE_GOLD_COIN:
		{
			sitePtr->animation_count = 5;
			gold_coin_count++;
			break;
		}
		case SITE_ITEM:
			item_count++;
			break;

		case SITE_WEAPON_BLUEPRINT:
			weapon_blueprint_count++;
			break;
	}

	return sitePtr->site_recno;
}
Exemplo n.º 16
0
void SpriteArray::add(Sprite *newSprite)
{
	linkin(&newSprite);

	newSprite->sprite_recno = recno();
}