本文整理汇总了C++中Site::init方法的典型用法代码示例。如果您正苦于以下问题:C++ Site::init方法的具体用法?C++ Site::init怎么用?C++ Site::init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Site
的用法示例。
在下文中一共展示了Site::init方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: add_site
//--------- Begin of function SiteArray::add_site ---------//
//
// Add a raw item to the site array
//
// Return : 1 - the raw is added
// 0 - duplicated, not added
//
int SiteArray::add_site(int xLoc, int yLoc, int siteType, int objectId, int reserveQty)
{
//----- linkin the raw and update raw attribute ----//
Site site;
linkin(&site);
Site* sitePtr = (Site*) get(recno());
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:
gold_coin_count++;
break;
}
return 1;
}
示例2: add_site
//--------- 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++;
//.........这里部分代码省略.........