本文整理汇总了C++中CArea类的典型用法代码示例。如果您正苦于以下问题:C++ CArea类的具体用法?C++ CArea怎么用?C++ CArea使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CArea类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Disappear
void CAPet::Disappear()
{
CArea* area = m_pArea;
//#ifdef MONSTER_COMBO_BUGFIX
// GAMELOG << init("APET DISAPPEAR PREV")
// << m_index
// << end;
//#endif // MONSTER_COMBO_BUGFIX
if (area == NULL)
{
//#ifdef MONSTER_COMBO_BUGFIX
// GAMELOG << init("MONSTER_COMBO_BUGFIX") << "AREA NULL" << end;
//#endif // MONSTER_COMBO_BUGFIX
return ;
}
if (!IS_IN_CELL(this))
{
//#ifdef MONSTER_COMBO_BUGFIX
// GAMELOG << init("MONSTER_COMBO_BUGFIX")
// << "IS_IN_CELL" << delim
// << m_cellX
// << end;
//#endif // MONSTER_COMBO_BUGFIX
return ;
}
if (!m_bSummon)
{
//#ifdef MONSTER_COMBO_BUGFIX
// GAMELOG << init("MONSTER_COMBO_BUGFIX") << "SUMMON FALSE" << end;
//#endif // MONSTER_COMBO_BUGFIX
return ;
}
// 어택 리스트 지우고
DelAttackList(this);
{
// 사라짐을 알리고
CNetMsg::SP rmsg(new CNetMsg);
DisappearMsg(rmsg, this);
area->SendToCell(rmsg, this, true);
}
// 셀에서 제거
area->CharFromCell(this, true);
m_pZone = NULL;
m_pArea = NULL;
m_bSummon = false;
//#ifdef MONSTER_COMBO_BUGFIX
// GAMELOG << init("APET DISAPPEAR AFTER")
// << m_index << delim
// << m_cellX << delim
// << m_cellZ << end;
//#endif // MONSTER_COMBO_BUGFIX
}
示例2: Split
void CArea::Split(std::list<CArea> &m_areas)const
{
if(HolesLinked())
{
for(std::list<CCurve>::const_iterator It = m_curves.begin(); It != m_curves.end(); It++)
{
const CCurve& curve = *It;
m_areas.push_back(CArea());
m_areas.back().m_curves.push_back(curve);
}
}
else
{
CArea a = *this;
a.Reorder();
if(CArea::m_please_abort)return;
for(std::list<CCurve>::const_iterator It = a.m_curves.begin(); It != a.m_curves.end(); It++)
{
const CCurve& curve = *It;
if(curve.IsClockwise())
{
if(m_areas.size() > 0)
m_areas.back().m_curves.push_back(curve);
}
else
{
m_areas.push_back(CArea());
m_areas.back().m_curves.push_back(curve);
}
}
}
}
示例3: PreSpawn
/************************************************************************************************
* CRMInstance::PreSpawn
* Prepares the instance for spawning by flattening the ground under it
*
* inputs:
* landscape: landscape the instance will be spawned on
*
* return:
* true: spawn preparation successful
* false: spawn preparation failed
*
************************************************************************************************/
bool CRMInstance::PreSpawn ( CRandomTerrain* terrain, qboolean IsServer )
{
vec3_t origin;
CArea area;
VectorCopy(GetOrigin(), origin);
if (mMirror)
{
origin[0] = TheRandomMissionManager->GetLandScape()->GetBounds()[0][0] + TheRandomMissionManager->GetLandScape()->GetBounds()[1][0] - origin[0];
origin[1] = TheRandomMissionManager->GetLandScape()->GetBounds()[0][1] + TheRandomMissionManager->GetLandScape()->GetBounds()[1][1] - origin[1];
}
const vec3_t& terxelSize = terrain->GetLandScape()->GetTerxelSize ( );
const vec3pair_t& bounds = terrain->GetLandScape()->GetBounds();
// Align the instance to the center of a terxel
origin[0] = bounds[0][0] + (int)((origin[0] - bounds[0][0] + terxelSize[0] / 2) / terxelSize[0]) * terxelSize[0];
origin[1] = bounds[0][1] + (int)((origin[1] - bounds[0][1] + terxelSize[1] / 2) / terxelSize[1]) * terxelSize[1];
// This is BAD - By copying the mirrored origin back into the instance, you've now mirrored the original instance
// so when anything from this point on looks at the instance they'll be looking at a mirrored version but will be expecting the original
// so later in the spawn functions the instance will be re-mirrored, because it thinks the mInstances have not been changed
// VectorCopy(origin, GetOrigin());
// Flatten the area below the instance
if ( GetFlattenRadius() )
{
area.Init( origin, GetFlattenRadius(), 0.0f, AT_NONE, 0, 0 );
terrain->GetLandScape()->FlattenArea( &area, mFlattenHeight | (mSurfaceSprites?0:0x80), false, true, true );
}
return true;
}
示例4: Mount
void CAPet::Mount( bool bMount )
{
m_bMount = bMount;
// 주인관련 처리
if( m_pOwner )
{
CArea* area = m_pOwner->m_pArea;
if( bMount ) // 탈때
{
if(m_pArea != NULL) // NULL이 아니면 실행, NULL이면 건너뛸것.
m_pArea->MoveChar( this, GET_YLAYER(m_pOwner), GET_X(m_pOwner), GET_Z(m_pOwner), GET_H(m_pOwner), GET_R(m_pOwner), MSG_MOVE_STOP, NULL );
// 소환 해제
while ( m_pOwner->m_elementalList)
m_pOwner->UnsummonElemental(m_pOwner->m_elementalList);
}
if(area)
{
{
// 사라졌다 나타나기
CNetMsg::SP rmsg(new CNetMsg);
DisappearMsg(rmsg, this);
area->SendToCell(rmsg, this, true);
}
{
CNetMsg::SP rmsg(new CNetMsg);
AppearMsg(rmsg, this);
area->SendToCell(rmsg, this, true);
}
}
if (m_pArea)
{
CNetMsg::SP rmsg(new CNetMsg);
ExAPetStatusMsg( rmsg, this );
m_pArea->SendToCell(rmsg, GetOwner(), true);
}
m_pOwner->CalcStatus(true);
{
CNetMsg::SP rmsg(new CNetMsg);
ExAPetFuntionMsg( rmsg, MSG_SUB_MOUNT_REP, this , 0 );
m_pOwner->m_pArea->SendToCell(rmsg, m_pOwner, true);
}
}
}
示例5: main
int main(int argc, char *argv[])
{
QGuiApplication a(argc, argv);
QFile area_file( a.arguments().at( 1 ) );
area_file.open( QIODevice::ReadOnly );
QDataStream stream( &area_file );
stream.setByteOrder( QDataStream::LittleEndian );
CArea area;
area.read( stream );
qDebug() << area_file.fileName();
CMainWindow w( &area );
w.show();
return a.exec();
}
示例6: MakePocketToolpath
boost::python::list MakePocketToolpath(const CArea& a, double tool_radius, double extra_offset, double stepover, bool from_center, bool use_zig_zag, double zig_angle)
{
std::list<CCurve> toolpath;
CAreaPocketParams params(tool_radius, extra_offset, stepover, from_center, use_zig_zag ? ZigZagPocketMode : SpiralPocketMode, zig_angle);
a.SplitAndMakePocketToolpath(toolpath, params);
boost::python::list clist;
BOOST_FOREACH(const CCurve& c, toolpath) {
clist.append(c);
}
示例7: make_obround
static CArea make_obround(const Point& p0, const Point& p1, double radius)
{
Point dir = p1 - p0;
double d = dir.length();
dir.normalize();
Point right(dir.y, -dir.x);
CArea obround;
CCurve c;
if(fabs(radius) < 0.0000001)radius = (radius > 0.0) ? 0.002 : (-0.002);
Point vt0 = p0 + right * radius;
Point vt1 = p1 + right * radius;
Point vt2 = p1 - right * radius;
Point vt3 = p0 - right * radius;
c.append(vt0);
c.append(vt1);
c.append(CVertex(1, vt2, p1));
c.append(vt3);
c.append(CVertex(1, vt0, p0));
obround.append(c);
return obround;
}
示例8: Cell
/************************************************************************************************
* CRMPathManager::PathVisit
* This method is called recursively to create a network of nodes connected with paths.
*
* inputs:
* c_x, c_y - cell to visit
*
* return:
* none
*
************************************************************************************************/
void CRMPathManager::PathVisit(const int c_x, const int c_y)
{
// does this cell have any neighbors with all walls intact?
int i,off;
// look at neighbors in random order
off = TheRandomMissionManager->GetLandScape()->irand(DIR_FIRST, DIR_MAX-1);
++mDepth; // track our depth of recursion
for (i = DIR_FIRST; i<DIR_MAX && mDepth <= mMaxDepth; i++)
{
int d = (i + off) % DIR_MAX;
if ( !Cell(c_x, c_y).Border(d) )
{ // we can move this way, since no border
int new_c_x = c_x + neighbor_x[d];
int new_c_y = c_y + neighbor_y[d];
if (Cell(new_c_x,new_c_y).Wall() == DIR_ALL)
{ // we have a new cell that has not been visited!
int new_dir;
// d is the direction relative to the current cell
// new_dir is the direction relative to the next cell (N becomes S, NE becomes SW, etc...)
if( d < HALF_DIR_MAX )
{
new_dir = d + HALF_DIR_MAX;
}
else
{
new_dir = d - HALF_DIR_MAX;
}
// knock down walls
Cell(c_x,c_y).RemoveWall(d);
Cell(new_c_x,new_c_y).RemoveWall(new_dir); //DIR_MAX - d);
// set path id
Node(c_x, c_y)->SetPath(d, mPathCount);
Node(new_c_x, new_c_y)->SetPath(new_dir, mPathCount); //DIR_MAX - d, mPathCount);
// create path between cells
mTerrain->CreatePath( mPathCount++,
-1,
0,
mPathPoints,
GetNodePos(c_x,c_y)[0],
GetNodePos(c_x,c_y)[1],
GetNodePos(new_c_x,new_c_y)[0],
GetNodePos(new_c_x,new_c_y)[1],
mPathMinWidth,
mPathMaxWidth,
mPathDepth,
mPathDeviation,
mPathBreadth );
// flatten a small spot
CArea area;
float flat_radius = mPathMaxWidth *
fabs(TheRandomMissionManager->GetLandScape()->GetBounds()[1][0] - TheRandomMissionManager->GetLandScape()->GetBounds()[0][0]);
area.Init( GetNodePos(c_x,c_y), flat_radius, 0.0f, AT_NONE, 0, 0 );
TheRandomMissionManager->GetLandScape()->FlattenArea(&area, 255 * mPathDepth, false, true, true );
// recurse
PathVisit(new_c_x, new_c_y);
}
}
}
--mDepth;
// NOTE: *whoop* hack alert, the first time this is reached, it should be the very last placed node.
if( !mCrossed && TheRandomMissionManager->GetMission()->GetSymmetric() &&
TheRandomMissionManager->GetMission()->GetBackUpPath() )
{
mCrossed = true;
int directionSet[3][3] = {DIR_NW,DIR_W,DIR_SW,DIR_N,-1,DIR_S,DIR_NE,DIR_E,DIR_SE};
int ncx = (mXNodes-1)-c_x;
int ncy = (mYNodes-1)-c_y;
int x_delta = ncx - c_x;
int y_delta = ncy - c_y;
if( x_delta < -1 )
{
x_delta = -1;
}
else if( x_delta > 1 )
{
x_delta = 1;
//.........这里部分代码省略.........
示例9: Appear
void CAPet::Appear(bool bIncludeOwner, bool bAction )
{
//#ifdef MONSTER_COMBO_BUGFIX
// GAMELOG << init("APET APEAR PREV")
// << m_index << end;
//#endif // MONSTER_COMBO_BUGFIX"
if (m_pOwner == NULL)
{
//#ifdef MONSTER_COMBO_BUGFIX
// GAMELOG << init("MONSTER_COMBO_BUGFIX") << "OWNER NULL"<< end;
//#endif // MONSTER_COMBO_BUGFIX
return ;
}
CArea* area = m_pOwner->m_pArea;
if (area == NULL)
{
//#ifdef MONSTER_COMBO_BUGFIX
// GAMELOG << init("MONSTER_COMBO_BUGFIX") << "AREA NULL" << end;
//#endif // MONSTER_COMBO_BUGFIX
return ;
}
if (m_bSummon)
{
//#ifdef MONSTER_COMBO_BUGFIX
// GAMELOG << init("MONSTER_COMBO_BUGFIX") << "SUMMON FALSE" << end;
//#endif // MONSTER_COMBO_BUGFIX
return ;
}
// 셀에 넣기
m_pZone = area->m_zone;
m_pArea = area;
m_pos = m_pOwner->m_pos;
int cx, cz;
area->PointToCellNum(GET_X(this), GET_Z(this), &cx, &cz);
area->CharToCell(this, GET_YLAYER(this), cx, cz);
{
CNetMsg::SP rmsg(new CNetMsg);
// 나타남을 알림
AppearMsg(rmsg, this, true, true);
area->SendToCell(rmsg, this, bIncludeOwner);
}
CalcStatus(false);
{
CNetMsg::SP rmsg(new CNetMsg);
ExAPetStatusMsg( rmsg, this );
m_pArea->SendToCell(rmsg, GetOwner(), true);
}
for( int i=0 ; i < APET_WEARPOINT; i++ )
{
if( m_wearing[i] )
{
CNetMsg::SP rmsg(new CNetMsg);
AddItemExAPetMsg(rmsg, m_wearing[i]);
SEND_Q(rmsg, GetOwner()->m_desc);
}
}
m_bSummon = true;
//#ifdef MONSTER_COMBO_BUGFIX
// GAMELOG << init("APET APEAR AFTER")
// << m_index << delim
// << m_cellX << delim
// << m_cellZ << end;
//#endif // MONSTER_COMBO_BUGFIX
}
示例10: switch
bool CAPet::TransFormationCheck()
{
if( m_pProto->m_TansType != APET_TRANS_NONE )
{
int comp = 0;
char oldState = this->m_cTransSate;
switch( m_pProto->m_TansType)
{
case APET_TRANS_TIME:
{
int nowsec = gserver->getNowSecond() % 3600;
if (nowsec == (3600 - 30) || nowsec == (3600 / 2) - 30) // 30초 전
{
CNetMsg::SP rmsg(new CNetMsg);
SysMsg(rmsg, MSG_SYS_TRANSLATE_START );
SEND_Q(rmsg, m_pOwner->m_desc);
}
else if (nowsec >= 0 && nowsec <= (3600 / 2)) // 정각s
{
m_cTransSate = 0;
}
else
{
m_cTransSate = 1;
}
}
break;
case APET_TRANS_FAITH:
comp = m_nFaith;
break;
case APET_TRANS_STM:
comp = m_nStm;
break;
}
// 옵션이 0 또는 100 이상일때 강제로 설정해주는 부분
if( m_cForceTrans == 1 ) // 무조건 변신
this->m_cTransSate = 1;
else if ( m_cForceTrans == 2 ) // 무조건 변신 안함
this->m_cTransSate = 0;
if( oldState != m_cTransSate )
{
// 변신했는데 마운트 타입이 아닌경우
if( m_pProto->m_nMount[ (unsigned int)m_cTransSate ] < 1 && IsMount() )
{
Mount(false);
}
else
{
CArea* area = m_pOwner->m_pArea;
{
CNetMsg::SP rmsg(new CNetMsg);
DisappearMsg(rmsg, this);
area->SendToCell(rmsg, this, true);
}
{
CNetMsg::SP rmsg(new CNetMsg);
AppearMsg(rmsg, this);
area->SendToCell(rmsg, this, true);
}
}
CalcStatus(false);
return true;
}
}
return false;
}
示例11: CreateRandomDensityMap
void CRMLandScape::CreateRandomDensityMap(byte *density, int width, int height, int seed)
{
// int i, border, inc;
int x, y, count;
// byte *work, *work2;
CArea *area;
vec3_t derxelSize, pos;
ivec3_t dmappos;
byte *hm_map = common->GetHeightMap();
int hm_width = common->GetRealWidth();
int hm_height = common->GetRealHeight();
int xpos, ypos, dx, dy;
byte *densityPos = density;
bool foundUneven;
// Init to linear spread
memset(density, 0, width * height);
/* // Make more prevalent towards the edges
border = Com_Clamp(6, 12, (width + height) >> 4);
for(i = 0; i < border; i++)
{
inc = (border - i + 1) * 9;
// Top line
work = density + i + (i * width);
for(x = i; x < width - i; x++, work++)
{
*work += (byte)common->irand(inc >> 1, inc);
}
// Left and right edges
work = density + i + ((i + 1) * width);
work2 = density + (width - i) + ((i + 1) * width);
for(y = i + 1; y < height - i - 2; y++, work += width, work2 += width)
{
*work += (byte)common->irand(inc >> 1, inc);
*work2 += (byte)common->irand(inc >> 1, inc);
}
// Bottom line
work = density + i + ((height - i - 1) * width);
for(x = i; x < width - i; x++, work++)
{
*work += (byte)common->irand(inc >> 1, inc);
}
}
*/
count = 0;
for(y=0;y<height;y++)
{
for(x=0;x<width;x++,densityPos++)
{
xpos = (x * hm_width / width);
ypos = (y * hm_height / height);
ypos = hm_height - ypos - 1;
if (hm_map[ypos*hm_width + xpos] < 150)
{
continue;
}
foundUneven = false;
for(dx=-4;(dx<=4 && !foundUneven);dx++)
{
for(dy=-4;(dy<=4 && !foundUneven);dy++)
{
if (dx == 0 && dy == 0)
{
continue;
}
if ((xpos+dx) >= 0 && (xpos+dx) < hm_width && (ypos+dy) >= 0 && (ypos+dy) < hm_height)
{
if (hm_map[(ypos+dy)*hm_width + (xpos+dx)] < 190)
{
*densityPos = 205;
count++;
foundUneven = true;
}
}
}
}
}
}
/* FILE *FH;
FH = fopen("c:\o.raw", "wb");
fwrite(hm_map, 1, common->GetRealWidth() * common->GetRealHeight(), FH);
fclose(FH);
FH = fopen("c:\d.raw", "wb");
fwrite(density, 1, width*height, FH);
fclose(FH);
*/
// Reduce severely for any settlements/buildings/objectives
VectorScale(common->GetSize(), 1.0f / width, derxelSize);
//.........这里部分代码省略.........
示例12: CurveTree
void CurveTree::MakeOffsets2()
{
// make offsets
if(CArea::m_please_abort)return;
CArea smaller;
smaller.m_curves.push_back(curve);
smaller.Offset(pocket_params->stepover);
if(CArea::m_please_abort)return;
// test islands
for(std::list<const IslandAndOffset*>::iterator It = offset_islands.begin(); It != offset_islands.end();)
{
const IslandAndOffset* island_and_offset = *It;
if(GetOverlapType(island_and_offset->offset, smaller) == eInside)
It++; // island is still inside
else
{
inners.push_back(new CurveTree(*island_and_offset->island));
islands_added.push_back(inners.back());
inners.back()->point_on_parent = curve.NearestPoint(*island_and_offset->island);
if(CArea::m_please_abort)return;
Point island_point = island_and_offset->island->NearestPoint(inners.back()->point_on_parent);
if(CArea::m_please_abort)return;
inners.back()->curve.ChangeStart(island_point);
if(CArea::m_please_abort)return;
// add the island offset's inner curves
for(std::list<CCurve>::const_iterator It2 = island_and_offset->island_inners.begin(); It2 != island_and_offset->island_inners.end(); It2++)
{
const CCurve& island_inner = *It2;
inners.back()->inners.push_back(new CurveTree(island_inner));
inners.back()->inners.back()->point_on_parent = inners.back()->curve.NearestPoint(island_inner);
if(CArea::m_please_abort)return;
Point island_point = island_inner.NearestPoint(inners.back()->inners.back()->point_on_parent);
if(CArea::m_please_abort)return;
inners.back()->inners.back()->curve.ChangeStart(island_point);
to_do_list_for_MakeOffsets.push_back(inners.back()->inners.back()); // do it later, in a while loop
if(CArea::m_please_abort)return;
}
smaller.Subtract(island_and_offset->offset);
std::set<const IslandAndOffset*> added;
std::list<IslandAndOffsetLink> touching_list;
for(std::list<IslandAndOffset*>::const_iterator It2 = island_and_offset->touching_offsets.begin(); It2 != island_and_offset->touching_offsets.end(); It2++)
{
const IslandAndOffset* touching = *It2;
touching_list.push_back(IslandAndOffsetLink(touching, inners.back()));
added.insert(touching);
}
while(touching_list.size() > 0)
{
IslandAndOffsetLink touching = touching_list.front();
touching_list.pop_front();
touching.add_to->inners.push_back(new CurveTree(*touching.island_and_offset->island));
islands_added.push_back(touching.add_to->inners.back());
touching.add_to->inners.back()->point_on_parent = touching.add_to->curve.NearestPoint(*touching.island_and_offset->island);
Point island_point = touching.island_and_offset->island->NearestPoint(touching.add_to->inners.back()->point_on_parent);
touching.add_to->inners.back()->curve.ChangeStart(island_point);
smaller.Subtract(touching.island_and_offset->offset);
// add the island offset's inner curves
for(std::list<CCurve>::const_iterator It2 = touching.island_and_offset->island_inners.begin(); It2 != touching.island_and_offset->island_inners.end(); It2++)
{
const CCurve& island_inner = *It2;
touching.add_to->inners.back()->inners.push_back(new CurveTree(island_inner));
touching.add_to->inners.back()->inners.back()->point_on_parent = touching.add_to->inners.back()->curve.NearestPoint(island_inner);
if(CArea::m_please_abort)return;
Point island_point = island_inner.NearestPoint(touching.add_to->inners.back()->inners.back()->point_on_parent);
if(CArea::m_please_abort)return;
touching.add_to->inners.back()->inners.back()->curve.ChangeStart(island_point);
to_do_list_for_MakeOffsets.push_back(touching.add_to->inners.back()->inners.back()); // do it later, in a while loop
if(CArea::m_please_abort)return;
}
for(std::list<IslandAndOffset*>::const_iterator It2 = touching.island_and_offset->touching_offsets.begin(); It2 != touching.island_and_offset->touching_offsets.end(); It2++)
{
if(added.find(*It2)==added.end() && ((*It2) != island_and_offset))
{
touching_list.push_back(IslandAndOffsetLink(*It2, touching.add_to->inners.back()));
added.insert(*It2);
}
}
}
if(CArea::m_please_abort)return;
It = offset_islands.erase(It);
for(std::set<const IslandAndOffset*>::iterator It2 = added.begin(); It2 != added.end(); It2++)
{
const IslandAndOffset* i = *It2;
offset_islands.remove(i);
}
if(offset_islands.size() == 0)break;
//.........这里部分代码省略.........
示例13: do_pd_Attack
// 믈리 어택
void do_pd_Attack(CPC* pc, CNetMsg::SP& msg)
{
CDratanCastle * pCastle = CDratanCastle::CreateInstance();
pCastle->CheckRespond(pc);
RequestClient::doPDAttack* packet = reinterpret_cast<RequestClient::doPDAttack*>(msg->m_buf);
if (packet->multicount > 20)
{
LOG_ERROR("HACKING : invalid multi count[%d]. charIndex[%d]", packet->multicount, pc->m_index);
pc->m_desc->Close("invalid multi count");
return;
}
// multi target의 중복 검사
if (packet->multicount > 1)
{
std::set<int> tset;
for (int i = 0; i < packet->multicount; ++i)
{
if (tset.insert(packet->list[i].index).second == false)
{
LOG_ERROR("HACKING : duplicate multi target[%d]. charIndex[%d]", packet->list[i].index, pc->m_index);
pc->m_desc->Close("duplicate multi target");
return;
}
}
}
// 대상 검색 : 인접 셀에서만
CArea* area = pc->m_pArea;
if (area == NULL)
{
LOG_ERROR("HACKING : not found area. charIndex[%d]", pc->m_index);
pc->m_desc->Close("not found area");
return;
}
CCharacter* tch = area->FindCharInCell(pc, packet->tIndex, (MSG_CHAR_TYPE)packet->tCharType);
if (tch == NULL)
return;
int preIndex = -1;
for (int i = 0; i < packet->multicount; ++i)
{
if(preIndex == packet->list[i].index)
{
// 가까운 마을로
int nearZone;
int nearZonePos;
CZone* pZone = gserver->FindNearestZone(pc->m_pZone->m_index, GET_X(pc), GET_Z(pc), &nearZone, &nearZonePos);
if (pZone == NULL)
return;
GoZone(pc, nearZone,
pZone->m_zonePos[nearZonePos][0], // ylayer
GetRandom(pZone->m_zonePos[nearZonePos][1], pZone->m_zonePos[nearZonePos][3]) / 2.0f, // x
GetRandom(pZone->m_zonePos[nearZonePos][2], pZone->m_zonePos[nearZonePos][4]) / 2.0f); // z
return;
}
preIndex = packet->list[i].index;
CCharacter* ch = area->FindCharInCell(pc, packet->list[i].index, (MSG_CHAR_TYPE) MSG_CHAR_NPC);
if(!ch) continue;
if( !IS_NPC(ch) )
{
CPC* bugPC = NULL;
if( IS_ELEMENTAL(ch) )
{
CElemental *ele = TO_ELEMENTAL(ch);
bugPC = ele->GetOwner();
}
if( IS_PET(ch) )
{
CPet* pet = TO_PET(ch);
bugPC = pet->GetOwner();
}
if( IS_PC(ch) )
{
bugPC = TO_PC(ch);
}
if( !bugPC )
return;
// 가까운 마을로
int nearZone;
int nearZonePos;
CZone* pZone = gserver->FindNearestZone(bugPC->m_pZone->m_index, GET_X(bugPC), GET_Z(bugPC), &nearZone, &nearZonePos);
if (pZone == NULL)
return;
GoZone(bugPC, nearZone,
pZone->m_zonePos[nearZonePos][0], // ylayer
//.........这里部分代码省略.........
示例14: RiverCell
void CRMPathManager::RiverVisit(const int c_x, const int c_y)
{
// does this cell have any neighbors with all walls intact?
int i,off;
// look at neighbors in random order
off = TheRandomMissionManager->GetLandScape()->irand(DIR_FIRST, DIR_MAX-1);
++mDepth; // track our depth of recursion
for (i = DIR_FIRST; i<DIR_MAX && mDepth <= mMaxDepth; i+=2)
{
int d = (i + off) % DIR_MAX;
if ( !Cell(c_x, c_y).Border(d) )
{ // we can move this way, since no border
int new_c_x = c_x + neighbor_x[d];
int new_c_y = c_y + neighbor_y[d];
if (RiverCell(new_c_x,new_c_y).Wall() == DIR_ALL)
{ // we have a new cell that has not been visited!
int new_dir;
// d is the direction relative to the current cell
// new_dir is the direction relative to the next cell (N becomes S, NE becomes SW, etc...)
if( d < HALF_DIR_MAX )
{
new_dir = d + HALF_DIR_MAX;
}
else
{
new_dir = d - HALF_DIR_MAX;
}
// knock down walls
RiverCell(c_x,c_y).RemoveWall(d);
RiverCell(new_c_x,new_c_y).RemoveWall(new_dir); //DIR_MAX - d);
// create river between cells
mTerrain->CreatePath ( mPathCount++,
-1,
0,
mRiverPoints,
GetRiverPos(c_x,c_y)[0],
GetRiverPos(c_x,c_y)[1],
GetRiverPos(new_c_x,new_c_y)[0],
GetRiverPos(new_c_x,new_c_y)[1],
mRiverMinWidth,
mRiverMaxWidth,
mRiverBedDepth,
mRiverDeviation,
mRiverBreadth );
// flatten a small spot
CArea area;
float flat_radius = mRiverMinWidth *
fabs(TheRandomMissionManager->GetLandScape()->GetBounds()[1][0] - TheRandomMissionManager->GetLandScape()->GetBounds()[0][0]);
area.Init( GetRiverPos(c_x,c_y), flat_radius, 0.0f, AT_NONE, 0, 0 );
TheRandomMissionManager->GetLandScape()->FlattenArea (&area, 255 * mRiverBedDepth, false, true, true );
// recurse
RiverVisit(new_c_x, new_c_y);
}
}
}
// --mDepth;
}
示例15: feed_possible
static bool feed_possible(const CArea &area_for_feed_possible, const Point& p0, const Point& p1, double tool_radius)
{
CArea obround = make_obround(p0, p1, tool_radius);
obround.Subtract(area_for_feed_possible);
return obround.m_curves.size() == 0;
}