本文整理匯總了C++中GML_STDMUTEX_LOCK函數的典型用法代碼示例。如果您正苦於以下問題:C++ GML_STDMUTEX_LOCK函數的具體用法?C++ GML_STDMUTEX_LOCK怎麽用?C++ GML_STDMUTEX_LOCK使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了GML_STDMUTEX_LOCK函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: StringTrimInPlace
unsigned int CCategoryHandler::GetCategory(std::string name)
{
StringTrimInPlace(name);
StringToLowerInPlace(name);
if (name.empty())
return 0; // the empty category
unsigned int cat = 0;
GML_STDMUTEX_LOCK(cat); // GetCategory
if (categories.find(name) == categories.end()) {
// this category is yet unknown
if (firstUnused >= CCategoryHandler::GetMaxCategories()) {
// skip this category
LOG_L(L_WARNING, "too many unit categories (%i), skipping %s",
firstUnused, name.c_str());
cat = 0;
} else {
// create the category (bit field value)
cat = (1 << firstUnused);
//LOG_L(L_DEBUG, "New unit-category %s #%i", name.c_str(), firstUnused);
}
// if (cat == 0), this will prevent further warnings for this category
categories[name] = cat;
firstUnused++;
} else {
// this category is already known
cat = categories[name];
}
return cat;
}
示例2: LOG_L
void CAICallback::DrawUnit(const char* unitName, const float3& pos,
float rotation, int lifetime, int teamId, bool transparent,
bool drawBorder, int facing)
{
CUnitDrawer::TempDrawUnit tdu;
tdu.unitdef = unitDefHandler->GetUnitDefByName(unitName);
if (!tdu.unitdef) {
LOG_L(L_WARNING, "Unknown unit in CAICallback::DrawUnit %s", unitName);
return;
}
tdu.pos = pos;
tdu.rotation = rotation;
tdu.team = teamId;
tdu.drawBorder = drawBorder;
tdu.facing = facing;
std::pair<int, CUnitDrawer::TempDrawUnit> tp(gs->frameNum + lifetime, tdu);
GML_STDMUTEX_LOCK(temp); // DrawUnit
if (transparent) {
unitDrawer->tempTransparentDrawUnits.insert(tp);
} else {
unitDrawer->tempDrawUnits.insert(tp);
}
}
示例3: GML_STDMUTEX_LOCK
bool CInMapDrawModel::AddPoint(const float3& constPos, const std::string& label, int playerID)
{
if (!playerHandler->IsValidPlayer(playerID)) {
return false;
}
GML_STDMUTEX_LOCK(inmap); // LocalPoint
// GotNetMsg() alreadys checks validity of playerID
const CPlayer* sender = playerHandler->Player(playerID);
const bool allowed = AllowedMsg(sender);
float3 pos = constPos;
pos.ClampInBounds();
pos.y = ground->GetHeightAboveWater(pos.x, pos.z, false) + 2.0f;
// event clients may process the point
// if their owner is allowed to see it
if (allowed && eventHandler.MapDrawCmd(playerID, MAPDRAW_POINT, &pos, NULL, &label)) {
return false;
}
// let the engine handle it (disallowed
// points added here are filtered while
// rendering the quads)
MapPoint point(sender->spectator, sender->team, sender, pos, label);
const int quad = int(pos.z * QUAD_SCALE) * drawQuadsX +
int(pos.x * QUAD_SCALE);
drawQuads[quad].points.push_back(point);
numPoints++;
return true;
}
示例4: GML_STDMUTEX_LOCK
void CConsoleHistory::ResetPosition()
{
GML_STDMUTEX_LOCK(hist); // ResetPosition
pos = lines.end();
return;
}
示例5: GML_STDMUTEX_LOCK
void CLogOutput::Output(const std::string& str)
{
GML_STDMUTEX_LOCK(log); // Output
std::string msg;
#if !defined UNITSYNC && !defined DEDICATED
if (gs) {
msg += IntToString(gs->frameNum, "[f=%07d] ");
}
#endif
msg += str;
if (!initialized) {
ToStderr(msg);
preInitLog().push_back(msg);
return;
}
#ifdef _MSC_VER
int index = strlen(str.c_str()) - 1;
bool newline = ((index < 0) || (str[index] != '\n'));
OutputDebugString(msg.c_str());
if (newline) {
OutputDebugString("\n");
}
#endif // _MSC_VER
ToFile(msg);
ToStderr(msg);
}
示例6: GML_STDMUTEX_LOCK
void CInMapDraw::LocalLine(const float3& constPos1, const float3& constPos2,
int playerID)
{
if (!playerHandler->IsValidPlayer(playerID))
return;
GML_STDMUTEX_LOCK(inmap); // LocalLine
const CPlayer* sender = playerHandler->Player(playerID);
float3 pos1 = constPos1;
float3 pos2 = constPos2;
pos1.CheckInBounds();
pos2.CheckInBounds();
pos1.y = ground->GetHeight(pos1.x, pos1.z) + 2.0f;
pos2.y = ground->GetHeight(pos2.x, pos2.z) + 2.0f;
if (AllowedMsg(sender) && eventHandler.MapDrawCmd(playerID, MAPDRAW_LINE, &pos1, &pos2, NULL)) {
return;
}
MapLine line;
line.pos = pos1;
line.pos2 = pos2;
line.color = sender->spectator ? color4::white : teamHandler->Team(sender->team)->color;
line.senderAllyTeam = teamHandler->AllyTeam(sender->team);
line.senderSpectator = sender->spectator;
const int quad = int(pos1.z * quadScale) * drawQuadsX +
int(pos1.x * quadScale);
drawQuads[quad].lines.push_back(line);
}
示例7: GML_STDMUTEX_LOCK
void EventBatchHandler::UpdateDrawUnits() {
GML_STDMUTEX_LOCK(runit); // UpdateDrawUnits
unitCreatedDestroyedEventBatch.execute();
unitCloakStateChangedEventBatch.execute();
unitLOSStateChangedEventBatch.execute();
}
示例8: GML_STDMUTEX_LOCK
void CUnitHandler::RemoveBuilderCAI(CBuilderCAI* b)
{
GML_STDMUTEX_LOCK(cai); // RemoveBuilderCAI
// called from ~CUnit --> owner is still valid
assert(b->owner != NULL);
builderCAIs.erase(b->owner->id);
}
示例9: GML_STDMUTEX_LOCK
/**
* @brief Process the queue of pending fartexture creation requests.
* This loops through the queue calling ReallyCreateFarTexture() on each entry,
* and empties the queue afterwards.
*/
void CFartextureHandler::CreateFarTextures()
{
GML_STDMUTEX_LOCK(tex); // CreateFarTextures
for(std::vector<S3DModel*>::const_iterator it = pending.begin(); it != pending.end(); ++it) {
ReallyCreateFarTexture(*it);
}
pending.clear();
}
示例10: GML_STDMUTEX_LOCK
void EventBatchHandler::UpdateObjects() {
{
GML_STDMUTEX_LOCK(runit); // UpdateObjects
UpdateUnits();
}
{
GML_STDMUTEX_LOCK(rfeat); // UpdateObjects
UpdateFeatures();
}
{
GML_STDMUTEX_LOCK(rproj); // UpdateObjects
UpdateProjectiles();
}
}
示例11: glBindTexture
void CBasicTreeDrawer::Draw(float treeDistance,bool drawReflection)
{
glBindTexture(GL_TEXTURE_2D, treetex);
glEnable(GL_ALPHA_TEST);
int cx=(int)(camera->pos.x/(SQUARE_SIZE*TREE_SQUARE_SIZE));
int cy=(int)(camera->pos.z/(SQUARE_SIZE*TREE_SQUARE_SIZE));
CBasicTreeSquareDrawer drawer;
drawer.td = this;
drawer.cx = cx;
drawer.cy = cy;
drawer.treeDistance = treeDistance;
GML_STDMUTEX_LOCK(tree); // Draw
readmap->GridVisibility (camera, TREE_SQUARE_SIZE, treeDistance*2*SQUARE_SIZE*TREE_SQUARE_SIZE, &drawer);
int startClean=lastListClean*20%nTrees;
lastListClean=gs->frameNum;
int endClean=gs->frameNum*20%nTrees;
if(startClean>endClean){
for(TreeSquareStruct *pTSS=trees+startClean; pTSS<trees+nTrees; ++pTSS) {
if(pTSS->lastSeen<gs->frameNum-50 && pTSS->displist){
glDeleteLists(pTSS->displist,1);
pTSS->displist=0;
}
if(pTSS->lastSeenFar<gs->frameNum-50 && pTSS->farDisplist){
glDeleteLists(pTSS->farDisplist,1);
pTSS->farDisplist=0;
}
}
for(TreeSquareStruct *pTSS=trees; pTSS<trees+endClean; ++pTSS) {
if(pTSS->lastSeen<gs->frameNum-50 && pTSS->displist){
glDeleteLists(pTSS->displist,1);
pTSS->displist=0;
}
if(pTSS->lastSeenFar<gs->frameNum-50 && pTSS->farDisplist){
glDeleteLists(pTSS->farDisplist,1);
pTSS->farDisplist=0;
}
}
} else {
for(TreeSquareStruct *pTSS=trees+startClean; pTSS<trees+endClean; ++pTSS) {
if(pTSS->lastSeen<gs->frameNum-50 && pTSS->displist){
glDeleteLists(pTSS->displist,1);
pTSS->displist=0;
}
if(pTSS->lastSeenFar<gs->frameNum-50 && pTSS->farDisplist){
glDeleteLists(pTSS->farDisplist,1);
pTSS->farDisplist=0;
}
}
}
glDisable(GL_BLEND);
glDisable(GL_ALPHA_TEST);
}
示例12: GML_STDMUTEX_LOCK
void CGroup::RemoveUnit(CUnit *unit)
{
GML_STDMUTEX_LOCK(group); // RemoveUnit
eventHandler.GroupChanged(id);
if(ai)
ai->RemoveUnit(unit->id);
units.erase(unit);
}
示例13: GML_STDMUTEX_LOCK
void CDynWater::AddExplosion(const float3& pos, float strength, float size)
{
if(pos.y>size || size < 8)
return;
GML_STDMUTEX_LOCK(water); // AddExplosion
explosions.push_back(Explosion(pos,std::min(size*20,strength),size));
}
示例14: GML_STDMUTEX_LOCK
void CNetProtocol::InitLocalClient()
{
GML_STDMUTEX_LOCK(net); // InitLocalClient
serverConn.reset(new netcode::CLocalConnection);
serverConn->Flush();
logOutput.Print("Connecting to local server");
}
示例15: GML_STDMUTEX_LOCK
void CInMapDraw::Draw(void)
{
GML_STDMUTEX_LOCK(inmap); //! Draw
CVertexArray* va = GetVertexArray();
va->Initialize();
CVertexArray* lineva = GetVertexArray();
lineva->Initialize();
InMapDraw_QuadDrawer drawer;
drawer.imd = this;
drawer.lineva = lineva;
drawer.va = va;
drawer.visLabels = &visibleLabels;
glDepthMask(0);
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
glBindTexture(GL_TEXTURE_2D, texture);
readmap->GridVisibility(camera, DRAW_QUAD_SIZE, 3000.0f, &drawer);
glDisable(GL_TEXTURE_2D);
glLineWidth(3.f);
lineva->DrawArrayC(GL_LINES); //! draw lines
// XXX hopeless drivers, retest in a year or so...
// width greater than 2 causes GUI flicker on ATI hardware as of driver version 9.3
// so redraw lines with width 1
if (globalRendering->atiHacks) {
glLineWidth(1.f);
lineva->DrawArrayC(GL_LINES);
}
// draw points
glLineWidth(1);
glEnable(GL_TEXTURE_2D);
va->DrawArrayTC(GL_QUADS); //! draw point markers
if (!visibleLabels.empty()) {
font->SetColors(); //! default
//! draw point labels
for (std::vector<MapPoint*>::iterator pi = visibleLabels.begin(); pi != visibleLabels.end(); ++pi) {
float3 pos = (*pi)->pos;
pos.y += 111.0f;
font->SetTextColor((*pi)->color[0]/255.0f, (*pi)->color[1]/255.0f, (*pi)->color[2]/255.0f, 1.0f); //FIXME (overload!)
font->glWorldPrint(pos, 26.0f, (*pi)->label);
}
visibleLabels.clear();
}
glDepthMask(1);
}