faction *update_owners(region * r) { faction *f = NULL; assert(rule_region_owners()); if (r->land) { building *bowner = largestbuilding(r, &cmp_current_owner, false); building *blargest = largestbuilding(r, &cmp_taxes, false); if (blargest) { if (!bowner || bowner->size < blargest->size) { /* region owners update? */ unit *u = building_owner(blargest); f = region_get_owner(r); if (u == NULL) { if (f) { region_set_owner(r, NULL, turn); r->land->ownership->flags |= OWNER_MOURNING; f = NULL; } } else if (u->faction != f) { if (!r->land->ownership) { /* there has never been a prior owner */ region_set_morale(r, MORALE_DEFAULT, turn); } else { alliance *al = region_get_alliance(r); if (al && u->faction->alliance == al) { int morale = _max(0, r->land->morale - MORALE_TRANSFER); region_set_morale(r, morale, turn); } else { region_set_morale(r, MORALE_TAKEOVER, turn); if (f) { r->land->ownership->flags |= OWNER_MOURNING; } } } region_set_owner(r, u->faction, turn); f = u->faction; } } } else if (r->land->ownership && r->land->ownership->owner) { r->land->ownership->flags |= OWNER_MOURNING; region_set_owner(r, NULL, turn); f = NULL; } } return f; }
extern bool _wrectvisible( /************************/ float x1, float y1, float x2, float y2 ) { int px1, py1; int px2, py2; WPI_RECT rect; int left, right, top, bottom; convert_pt( x1, y1, &px1, &py1 ); convert_pt( x2, y2, &px2, &py2 ); left = _min( px1, px2 ); right = _max( px1, px2 ); top = _min( py1, py2 ); bottom = _max( py1, py2 ); _wpi_setintrectvalues( &rect, left, top, right, bottom ); return( RectVisible( Win_dc, &rect ) ); }
void Vision::feel_vision_update (CObject* parent, Fvector& P, float dt, float vis_threshold) { // B-A = objects, that become visible if (!seen.empty()) { xr_vector<CObject*>::iterator E = std::remove(seen.begin(),seen.end(),parent); seen.resize (E-seen.begin()); { diff.resize (_max(seen.size(),query.size())); xr_vector<CObject*>::iterator E = std::set_difference( seen.begin(), seen.end(), query.begin(),query.end(), diff.begin() ); diff.resize(E-diff.begin()); for (u32 i=0; i<diff.size(); i++) o_new(diff[i]); } } // A-B = objects, that are invisible if (!query.empty()) { diff.resize (_max(seen.size(),query.size())); xr_vector<CObject*>::iterator E = std::set_difference( query.begin(),query.end(), seen.begin(), seen.end(), diff.begin() ); diff.resize(E-diff.begin()); for (u32 i=0; i<diff.size(); i++) o_delete(diff[i]); } // Copy results and perform traces query = seen; o_trace (P,dt,vis_threshold); }
bool CCollisionBox::IsColliding(CCollisionBox& other) { CVector3f _min(CVector3f(m_position.x - (1 * m_scale.x), m_position.y - (1 * m_scale.y), m_position.z - (1 * m_scale.z))); CVector3f _max(CVector3f(m_position.x + (1 * m_scale.x), m_position.y + (1 * m_scale.y), m_position.z + (1 * m_scale.z))); CVector3f oMin(CVector3f(other.GetPosition().x - (1 * other.GetScale().x), other.GetPosition().y - (1 *other.GetScale().y), other.GetPosition().z - (1 * other.GetScale().z))); CVector3f oMax(CVector3f(other.GetPosition().x + (1 * other.GetScale().x), other.GetPosition().y + (1 *other.GetScale().y), other.GetPosition().z + (1 * other.GetScale().z))); return(_min.x > oMin.x && _min.x < oMax.x && _max.y > oMin.y && _min.y < oMax.y && _max.z > oMin.z && _min.z < oMax.z); }
int calc(int *ht, int n) { int ret = 0, top = 1, st[MAX], i; ht[0] = st[0] = ht[++n] = 0; for(i = 1; i <= n; i++) { while(top > 1 && ht[st[top-1]] >= ht[i]) { ret = _max(ret, ht[st[top-1]]*(i - st[top-2]-1)); top--; } st[top++] = i; } return ret; }
void Image::blt(int x, int y, Image const* src, int srcX, int srcY, int srcW, int srcH) { if (src == NULL || src->_bits == NULL || src == this) return; int startY = _max(0, -y); int endY = _min(_height - y, srcH); int startX = _max(0, -x); int endX = _min(_width - x, srcW); startY += srcY; endY += srcY; startX += srcX; endX += srcX; x -= srcX; y -= srcY; for (int cy = startY; cy < endY; cy++) { uint8* srcBits = (uint8*) (src->_bits + src->_width * cy + startX); uint8* dstBits = (uint8*) (_bits + _width * (cy + y) + (startX + x)); if ((src->_flags & _premult) == 0) memcpy(dstBits, srcBits, (endX - startX) * 4); else { for (int cx = startX; cx < endX; cx++) { uint8* tDst = mtable + uint32(srcBits[3]) * 256; *dstBits = _add(tDst[*dstBits], *srcBits++); dstBits++; *dstBits = _add(tDst[*dstBits], *srcBits++); dstBits++; *dstBits = _add(tDst[*dstBits], *srcBits++); dstBits++; *dstBits = 255 - tDst[255 - *dstBits]; dstBits++, srcBits++; } } } if ((src->_flags & _premult) == 0 && startX == 0 && endX == _width && startY == 0 && endY == _height) _flags &= ~_premult; }
BOOL CClimableObject:: net_Spawn ( CSE_Abstract* DC) { CSE_Abstract *e = (CSE_Abstract*)(DC); CSE_ALifeObjectClimable *CLB=smart_cast<CSE_ALifeObjectClimable*>(e); const Fmatrix& b=CLB->shapes[0].data.box; m_box.m_halfsize.set(b._11,b._22,b._33); m_radius=_max(_max(m_box.m_halfsize.x,m_box.m_halfsize.y),m_box.m_halfsize.z); //m_box.m_halfsize.set(1.f,1.f,1.f); BOOL ret = inherited::net_Spawn(DC); const float f_min_width=0.2f; Fvector shift;shift.set(0.f,0.f,0.f); SORT(b._11,m_axis.set(XFORM().i);m_axis.mul(m_box.m_halfsize.x),m_side.set(XFORM().i);m_side.mul(m_box.m_halfsize.x),m_norm.set(XFORM().i);if(m_box.m_halfsize.x<f_min_width){m_box.m_halfsize.x=f_min_width;shift.set(1.f,0.f,0.f);};m_norm.mul(m_box.m_halfsize.x), b._22,m_axis.set(XFORM().j);m_axis.mul(m_box.m_halfsize.y),m_side.set(XFORM().j);m_side.mul(m_box.m_halfsize.y),m_norm.set(XFORM().j);if(m_box.m_halfsize.y<f_min_width){m_box.m_halfsize.y=f_min_width;shift.set(0.f,1.f,0.f);};m_norm.mul(m_box.m_halfsize.y), b._33,m_axis.set(XFORM().k);m_axis.mul(m_box.m_halfsize.z),m_side.set(XFORM().k);m_side.mul(m_box.m_halfsize.z),m_norm.set(XFORM().k);if(m_box.m_halfsize.z<f_min_width){m_box.m_halfsize.z=f_min_width;shift.set(0.f,0.f,1.f);};m_norm.mul(m_box.m_halfsize.z) ); shift.mul(f_min_width); XFORM().transform_dir(shift); CObject::Position().sub(shift); m_box.xform_set(Fidentity); m_pStaticShell= new CPHLeaderGeomShell(this); P_BuildStaticGeomShell(smart_cast<CPHStaticGeomShell*>(m_pStaticShell),smart_cast<CGameObject*>(this),0,m_box); m_pStaticShell->SetMaterial("materials\\fake_ladders"); if(m_axis.y<0.f) { m_axis.invert(); m_side.invert(); } // shedule_unregister(); processing_deactivate(); m_pStaticShell->set_ObjectContactCallback(ObjectContactCallback); return ret; }
/////////////////////////////////////////////////////////////////////////////////////////// // Stripify() // // // in_indices are the input indices of the mesh to stripify // in_cacheSize is the target cache size // void NvStripifier::Stripify(const WordVec &in_indices, const int in_cacheSize, const int in_minStripLength, NvStripInfoVec &outStrips, NvFaceInfoVec& outFaceList) { meshJump = 0.0f; bFirstTimeResetPoint = true; //used in FindGoodResetPoint() //the number of times to run the experiments int numSamples = 10; //the cache size, clamped to one cacheSize = _max (1, in_cacheSize - CACHE_INEFFICIENCY); minStripLength = in_minStripLength; //this is the strip size threshold below which we dump the strip into a list indices = in_indices; // build the stripification info NvFaceInfoVec allFaceInfos; NvEdgeInfoVec allEdgeInfos; BuildStripifyInfo(allFaceInfos, allEdgeInfos); NvStripInfoVec allStrips; // stripify FindAllStrips(allStrips, allFaceInfos, allEdgeInfos, numSamples); //split up the strips into cache friendly pieces, optimize them, then dump these into outStrips SplitUpStripsAndOptimize(allStrips, outStrips, allEdgeInfos, outFaceList); //clean up for(int i = 0; i < allStrips.size(); i++) { xr_delete(allStrips[i]); } for (u32 i = 0; i < allEdgeInfos.size(); i++) { NvEdgeInfo *info = allEdgeInfos[i]; while (info != NULL) { NvEdgeInfo *next = (info->m_v0 == int(i) ? info->m_nextV0 : info->m_nextV1); info->Unref(); info = next; } } }
int sp_keeploot(struct castorder * co) { fighter * fi = co->magician.fig; int level = co->level; double power = co->force; const spell * sp = co->sp; battle *b = fi->side->battle; message *m = msg_message("cast_spell_effect", "mage spell", fi->unit, sp); message_all(b, m); msg_release(m); b->keeploot = (int)_max(25, b->keeploot + 5 * power); return level; }
void CStreamReader::construct ( const HANDLE &file_mapping_handle, const u32 &start_offset, const u32 &file_size, const u32 &archive_size, const u32 &window_size ) { m_file_mapping_handle = file_mapping_handle; m_start_offset = start_offset; m_file_size = file_size; m_archive_size = archive_size; m_window_size = _max(window_size,FS.dwAllocGranularity); map (0); }
void Light::_fade() { switch(_state) { case _RISING: _rising(); break; case _MAX: _max(); break; case _FALLING: _falling(); break; case _MIN: _min(); break; } }
veValue::veValue(Type type) : USE_VE_PTR_INIT , _type(type) { } veValue::~veValue() { } veValueFixed::veValueFixed() : veValue(Type::VAL_FIXED) , _value(0.0f) { } veValueFixed::~veValueFixed() { } veReal veValueFixed::getValue(veReal x) { return _value; } veValueRandom::veValueRandom() : veValue(Type::VAL_RANDOM) , _min(0.0f) , _max(0.0f) { } veValueRandom::~veValueRandom() { } veReal veValueRandom::getValue(veReal x) { veReal t = veMath::veRandomUnitization(); return _min * t + _max * (1.0f - t); }
void MxPropSlim::apply_mesh_penalties(edge_info *info) { unsigned int i; const MxFaceList& N1 = m->neighbors(info->v1); const MxFaceList& N2 = m->neighbors(info->v2); // Set up the face marks as the check_xxx() functions expect. // for(i=0; i<(unsigned int)N2.length(); i++) m->face_mark(N2[i], 0); for(i=0; i<(unsigned int)N1.length(); i++) m->face_mark(N1[i], 1); for(i=0; i<(unsigned int)N2.length(); i++) m->face_mark(N2[i], m->face_mark(N2[i])+1); double base_error = info->heap_key(); double bias = 0.0; // Check for excess over degree bounds. // unsigned int max_degree = _max(N1.length(), N2.length()); if( max_degree > vertex_degree_limit ) bias += (max_degree-vertex_degree_limit) * meshing_penalty * 0.001f; // Local validity checks // float vnew[3]; vnew[0] = (float)info->target[0]; vnew[1] = (float)info->target[1]; vnew[2] = (float)info->target[2]; unsigned int nfailed = 0; nfailed += check_local_validity(info->v1, vnew); nfailed += check_local_validity(info->v2, vnew); if( nfailed ) bias += nfailed*meshing_penalty; float _scale = 1.f; if( compactness_ratio > 0.0 ){ double c1_min=check_local_compactness(info->v1, vnew); double c2_min=check_local_compactness(info->v2, vnew); double c_min = _min(c1_min, c2_min); if( c_min < compactness_ratio ) _scale += float((compactness_ratio-c_min)/compactness_ratio); } info->heap_key(float((base_error-EDGE_BASE_ERROR)*_scale - bias)); }
group *new_group(faction * f, const char *name, int gid) { group **gp = &f->groups; int index = gid % GMAXHASH; group *g = calloc(sizeof(group), 1); while (*gp) gp = &(*gp)->next; *gp = g; maxgid = _max(gid, maxgid); g->name = _strdup(name); g->gid = gid; g->nexthash = ghash[index]; return ghash[index] = g; }
void CInventoryOwner::set_money (u32 amount, bool bSendEvent) { if(InfinitiveMoney()) m_money = _max(m_money, amount); else m_money = amount; if(bSendEvent) { CGameObject *object = smart_cast<CGameObject*>(this); NET_Packet packet; object->u_EventGen (packet,GE_MONEY,object->ID()); packet.w_u32 (m_money); object->u_EventSend (packet); } }
int curse_age(attrib * a) { curse *c = (curse *) a->data.v; int result = 0; if (c_flags(c) & CURSE_NOAGE) { c->duration = INT_MAX; } if (c->type->age) { result = c->type->age(c); } if (result != 0) { c->duration = 0; } else if (c->duration != INT_MAX) { c->duration = _max(0, c->duration - 1); } return c->duration; }
bool CLevelTool::GetSelectionPosition(Fmatrix& result) { if(pCurTool) { Fvector center; Fbox BB; BB.invalidate (); // pCurTool->GetBBox (BB, true); const CCustomObject* object = pCurTool->LastSelected(); if(!object) return false; object->GetBox (BB); BB.getcenter (center); center.y = BB.max.y; Fvector2 pt_ss; pt_ss.set (10000,-10000); Fvector pt_ss_3d; BB.setb (center, Fvector().set(1.0f,1.0f,1.0f)); for(int k=0;k<8;++k) { Fvector pt; BB.getpoint(k,pt); EDevice.mFullTransform.transform(pt_ss_3d, pt); pt_ss.x = _min(pt_ss.x, pt_ss_3d.y); pt_ss.y = _max(pt_ss.y, pt_ss_3d.y); } float r_bb_ss = pt_ss.y - pt_ss.x; clamp(r_bb_ss, 0.0f,0.10f); float des_radius = 0.2f; float csale = des_radius/r_bb_ss; result.scale (csale,csale,csale); result.c = center; return true; }else return false; }
type bst<type>::_remove(np cur) { np tmp; type x; if (_isleaf(cur)) { x = cur->_data; if (!_isroot(cur)) { _setnull(_root, cur); delete(cur); cur = NULL; } return x; } else { tmp = cur->left ? _max(cur->left) : _min(cur->right); x = cur->_data; cur->_data = _remove(tmp); return x; } }
IC void CSoundMemoryManager::update_sound_threshold () { VERIFY (_valid(m_self_sound_factor)); VERIFY (_valid(m_sound_threshold)); VERIFY (_valid(m_min_sound_threshold)); VERIFY (!fis_zero(m_decrease_factor)); VERIFY (m_sound_decrease_quant); // t = max(t*f^((tc - tl)/tq),min_threshold) m_sound_threshold = _max( m_self_sound_factor* m_sound_threshold* exp( float(Device.dwTimeGlobal - m_last_sound_time)/ float(m_sound_decrease_quant)* log(m_decrease_factor) ), m_min_sound_threshold ); VERIFY (_valid(m_sound_threshold)); }
static int heal_fighters(quicklist * fgs, int *power, bool heal_monsters) { int healhp = *power, healed = 0, qi; quicklist *ql; for (qi = 0, ql = fgs; ql; ql_advance(&ql, &qi, 1)) { fighter *df = (fighter *)ql_get(ql, qi); if (healhp <= 0) break; /* Untote kann man nicht heilen */ if (df->unit->number == 0 || (u_race(df->unit)->flags & RCF_NOHEAL)) continue; /* wir heilen erstmal keine Monster */ if (heal_monsters || playerrace(u_race(df->unit))) { int n, hp = df->unit->hp / df->unit->number; int rest = df->unit->hp % df->unit->number; for (n = 0; n < df->unit->number; n++) { int wound = hp - df->person[n].hp; if (rest > n) ++wound; if (wound > 0 && wound < hp) { int heal = _min(healhp, wound); assert(heal >= 0); df->person[n].hp += heal; healhp = _max(0, healhp - heal); ++healed; if (healhp <= 0) break; } } } } *power = healhp; return healed; }
FE_TMPL FE_SYS::FastEvaluationRBFSystem(const std::vector<glm::vec4> &points,int threshold,unsigned int p,float relativeAccuracy ){ if(points.empty()){ root = 0; return; } glm::vec3 _min(points[0]),_max(points[0]); root = new FE_NODE(BoundingAABB(glm::vec3(),glm::vec3())); for(int i = 1;i<points.size();i++){ _min.x = std::min(_min.x,points[i].x); _min.y = std::min(_min.y,points[i].y); _min.z = std::min(_min.z,points[i].z); _max.x = std::max(_max.x,points[i].x); _max.y = std::max(_max.y,points[i].y); _max.z = std::max(_max.z,points[i].z); root->_points.push_back(glm::vec4(points[i])); } root->_aabb = BoundingAABB(_min,_max); root->_c = root->_aabb.getPosition(glm::vec3(0.5f,0.5f,0.5f)); root->_h = root->_aabb.maxPos() - root->_c; std::vector<FE_NODE*> nodes; nodes.push_back(root); while(!nodes.empty()){ auto node = nodes[0]; nodes.erase(nodes.begin()); if(node->_points.size()<threshold*2){ //only split nodes with points more than threshold*2 continue; } node->split(threshold); nodes.push_back(node->_left); nodes.push_back(node->_right); } root->calcFarFieldSeries(p); }
/* <3fea72> ../public/MemPool.cpp:157 */ void *CMemoryPool::Alloc(unsigned int amount) { void *returnBlock; if (amount > (unsigned int)_blockSize) return NULL; _blocksAllocated++; _peakAlloc = _max(_peakAlloc, _blocksAllocated); if (_blocksAllocated >= _numElements) AddNewBlob(); #ifdef _WIN32 if (!_headOfFreeList) DebugBreak(); #endif // _WIN32 returnBlock = _headOfFreeList; _headOfFreeList = *((void **)_headOfFreeList); return returnBlock; }
static void _boxdis (char *msg, char *input, int pos, int max) { char *p; int i, j, len = strlen(msg); clear (); border ( '|', '|', '-', '-', '+', '+', '+', '+' ); j = _intlength(max - 1); len = MAX(len, j * 3 + 2); j += _intlength(strlen(input)) + _intlength(POS) + 2; _mvchgrectat(WIN_Y, WIN_X, 5, len + 4, 0, clr_bkg, NULL); move(WIN_Y + 1, WIN_X + 2); attron(COLOR_PAIR(clr_ttl)); addstr(msg); attroff(COLOR_PAIR(clr_ttl)); move(WIN_Y + 2, WIN_X + len - j + 2); attron(COLOR_PAIR(clr_pnum) | A_BOLD); printw("%d", POS); attroff(COLOR_PAIR(clr_pnum) | A_BOLD); addch(' ' | COLOR_PAIR(clr_bkg)); attron(COLOR_PAIR(clr_tnum)); printw("%d/%d", strlen(input), max - 1); attroff(COLOR_PAIR(clr_tnum)); move(WIN_Y + 3, WIN_X + 1); i = POS - DISPOS; if (i < len / 3) dispos = _strpos(input, _max(0, POS - len / 3)); else if (i > len / 3 * 2) dispos = _nstrpos(input, _min(strlen(input) + 1 - len, POS - len / 3 * 2)); addch(COLOR_PAIR(clr_bkg) | (dispos == 0 ? ' ' : '<')); attron(COLOR_PAIR(clr_nptchr) | A_BOLD); addnstr(p = _arrange(&input[DISPOS]), _WSTRPOS(input, DISPOS + len) - DISPOS); free(p); attroff(COLOR_PAIR(clr_nptchr)); attron(COLOR_PAIR(clr_nptspc)); while (getcurx(stdscr) != WIN_X + 2 + len) addch(' '); attroff(COLOR_PAIR(clr_nptspc) | A_BOLD); addch(COLOR_PAIR(clr_bkg) | (DISPOS < (int)strlen(input) + 1 - len ? '>' : ' ')); move(WIN_Y + 3, WIN_X + 2 + pos - dispos ); refresh (); }
void CAI_Space::load (LPCSTR level_name) { // Msg ("level %s",level_name); unload (true); #ifdef DEBUG Memory.mem_compact (); u32 mem_usage = Memory.mem_usage(); CTimer timer; timer.Start (); #endif m_level_graph = xr_new<CLevelGraph>(); m_cross_table = xr_new<CGameLevelCrossTable>(); R_ASSERT2 (cross_table().header().level_guid() == level_graph().header().guid(), "cross_table doesn't correspond to the AI-map"); R_ASSERT2 (cross_table().header().game_guid() == game_graph().header().guid(), "graph doesn't correspond to the cross table"); m_graph_engine = xr_new<CGraphEngine>( _max( game_graph().header().vertex_count(), level_graph().header().vertex_count() ) ); const CGameGraph::SLevel ¤t_level = game_graph().header().level(level_name); R_ASSERT2 (current_level.guid() == level_graph().header().guid(), "graph doesn't correspond to the AI-map"); #ifdef DEBUG if (!xr_strcmp(current_level.name(),level_name)) validate (current_level.id()); #endif level_graph().level_id (current_level.id()); game_graph().set_current_level(current_level.id()); m_cover_manager->compute_static_cover (); #ifdef DEBUG Msg ("* Loading ai space is successfully completed (%.3fs, %7.3f Mb)",timer.GetElapsed_sec(),float(Memory.mem_usage() - mem_usage)/1048576.0); #endif }
double GetLEMass(LERec theLE, double halfLife) // AH 06/20/2012 { #ifndef pyGNOME long i; double tHours, fracLeft = 0.; TWeatherer *thisWeatherer; OilComponent component; CMyList *weatherList = model->GetWeatherList(); if (theLE.pollutantType == CHEMICAL) { //weatherList->GetListItem((Ptr)&thisWeatherer, 0); // assume there is only one //((dynamic_cast<TOSSMWeatherer*>(thisWeatherer)))->componentsList -> GetListItem ((Ptr) &component, theLE.pollutantType - 1); tHours = (double) ( model -> GetModelTime () - theLE.releaseTime)/ 3600.0 + theLE.ageInHrsWhenReleased; // if LE has not been released yet return 0? //if (theLE.releaseTime > model->GetModelTime()) return theLE.mass; if (theLE.releaseTime > model->GetModelTime()) return 0; /*for(i = 0;i<3;i++) // at this point only using 1 half life component { if(component.percent[i] > 0.0) { fracLeft += (component.percent[i])*pow(0.5,tHours/(component.halfLife[i])); } }*/ fracLeft = pow(.5,tHours/halfLife); fracLeft = _max (0.0,fracLeft); fracLeft = _min (1.0,fracLeft); return fracLeft*theLE.mass; } else return theLE.mass; #else return theLE.mass; #endif }
void CUIMessagesWindow::AddIconedPdaMessage(GAME_NEWS_DATA* news) { CUIPdaMsgListItem *pItem = m_pGameLog->AddPdaMessage(); LPCSTR time_str = InventoryUtilities::GetTimeAsString( news->receive_time, InventoryUtilities::etpTimeToMinutes ).c_str(); pItem->UITimeText.SetText (time_str); pItem->UITimeText.AdjustWidthToText (); Fvector2 p = pItem->UICaptionText.GetWndPos(); p.x = pItem->UITimeText.GetWndPos().x + pItem->UITimeText.GetWidth() + 3.0f; pItem->UICaptionText.SetWndPos (p); pItem->UICaptionText.SetTextST (news->news_caption.c_str()); pItem->UIMsgText.SetTextST (news->news_text.c_str()); pItem->UIMsgText.AdjustHeightToText (); pItem->SetColorAnimation ("ui_main_msgs_short", LA_ONLYALPHA|LA_TEXTCOLOR|LA_TEXTURECOLOR, float(news->show_time)); pItem->UIIcon.InitTexture (news->texture_name.c_str()); float h1 = _max( pItem->UIIcon.GetHeight(), pItem->UIMsgText.GetWndPos().y + pItem->UIMsgText.GetHeight() ); pItem->SetHeight( h1 + 3.0f ); m_pGameLog->SendMessage(pItem,CHILD_CHANGED_SIZE); }
static const char *b_nameroad(const connection * b, const region * r, const struct faction *f, int gflags) { region *r2 = (r == b->to) ? b->from : b->to; int local = (r == b->from) ? b->data.sa[0] : b->data.sa[1]; static char buffer[64]; unused_arg(f); if (gflags & GF_PURE) return "road"; if (gflags & GF_ARTICLE) { if (!(gflags & GF_DETAILED)) return LOC(f->locale, mkname("border", "a_road")); else if (r->terrain->max_road <= local) { int remote = (r2 == b->from) ? b->data.sa[0] : b->data.sa[1]; if (r2->terrain->max_road <= remote) { return LOC(f->locale, mkname("border", "a_road")); } else { return LOC(f->locale, mkname("border", "an_incomplete_road")); } } else { int percent = _max(1, 100 * local / r->terrain->max_road); if (local) { slprintf(buffer, sizeof(buffer), LOC(f->locale, mkname("border", "a_road_percent")), percent); } else { return LOC(f->locale, mkname("border", "a_road_connection")); } } } else if (gflags & GF_PLURAL) return LOC(f->locale, mkname("border", "roads")); else return LOC(f->locale, mkname("border", "road")); return buffer; }
void ArrayImpl::removeIndex(size_t i, size_t count) { DEFINEMETHODNAME; if(count == 0) { return; } const size_t j = i + count; if(j > m_size) { indexError(method,j); } for(size_t k = i; k < j; k++) { m_objectManager->deleteObject(m_elem[k]); } if(j < m_size) { memmove(m_elem+i, m_elem+j, (m_size-j)*sizeof(m_elem[0])); // m_elem[m_size] = NULL; } m_size -= count; if(m_size < m_capacity/2 && m_capacity > 10) { setCapacity(_max(10, m_size)); } m_updateCount++; }
void CDeflector::L_Direct_Edge (CDB::COLLIDER* DB, base_lighting* LightsSelected, Fvector2& p1, Fvector2& p2, Fvector& v1, Fvector& v2, Fvector& N, float texel_size, Face* skip) { Fvector vdir; vdir.sub (v2,v1); lm_layer& lm = layer; Fvector2 size; size.x = p2.x-p1.x; size.y = p2.y-p1.y; int du = iCeil(_abs(size.x)/texel_size); int dv = iCeil(_abs(size.y)/texel_size); int steps = _max(du,dv); if (steps<=0) return; for (int I=0; I<=steps; I++) { float time = float(I)/float(steps); Fvector2 uv; uv.x = size.x*time+p1.x; uv.y = size.y*time+p1.y; int _x = iFloor(uv.x*float(lm.width)); int _y = iFloor(uv.y*float(lm.height)); if ((_x<0)||(_x>=(int)lm.width)) continue; if ((_y<0)||(_y>=(int)lm.height)) continue; if (lm.marker[_y*lm.width+_x]) continue; // ok - perform lighting base_color_c C; Fvector P; P.mad(v1,vdir,time); LightPoint (DB, RCAST_Model, C, P, N, *LightsSelected, (b_norgb?LP_dont_rgb:0)|(b_nosun?LP_dont_sun:0)|LP_DEFAULT, skip); //. C.mul (.5f); lm.surface [_y*lm.width+_x]._set (C); lm.marker [_y*lm.width+_x] = 255; } }
void Camera::debugUpdate(float speed) { if (mode == CAMERA_MODE_FREE || mode == CAMERA_MODE_TARGET) if (Core::input->touch[0].down) { vec2 delta = Core::input->touch[0].pos - Core::input->touch[0].start; angle.x -= delta.y * 0.01f; angle.y -= delta.x * 0.01f; angle.x = _min(_max(angle.x, -_PI *0.5f + _EPS), _PI * 0.5f - _EPS); Core::input->touch[0].start = Core::input->touch[0].pos; } if (mode == CAMERA_MODE_FREE) { vec3 dir = vec3(sinf(angle.y - _PI) * cosf(-angle.x), -sinf(-angle.x), cosf(angle.y - _PI) * cosf(-angle.x)); vec3 v = vec3(0, 0, 0); if (Core::input->down[IK_W]) v += dir; if (Core::input->down[IK_S]) v -= dir; if (Core::input->down[IK_D]) v += dir.cross(vec3(0, 1, 0)); if (Core::input->down[IK_A]) v -= dir.cross(vec3(0, 1, 0)); if (Core::input->touch[1].down) { // vec2 d = Core::input->touch[1].pos - Core::input->touch[1].start; v += dir; /* if (Core::input->key['W']) v += dir; if (Core::input->key['S']) v -= dir; if (Core::input->key['D']) v += dir.cross(vec3(0, 1, 0)); if (Core::input->key['A']) v -= dir.cross(vec3(0, 1, 0)); */ } pos += v.normal() * (Core::deltaTime * speed); } if (mode == CAMERA_MODE_TARGET && Core::input->touch[1].down) { dist -= (Core::input->touch[1].pos.y - Core::input->touch[1].start.y) * 0.01f; Core::input->touch[1].start = Core::input->touch[1].pos; } }