示例#1
0
void CCollideInterface::DeactivateTile(uint32 mapId, uint32 tileX, uint32 tileY)
{
	m_loadLock.Acquire();
	if(!(--m_tilesLoaded[mapId][tileX][tileY]))
	{
		COLLISION_BEGINTIMER;
		CollisionMgr->unloadMap(mapId, tileY, tileX);
		printf("[%u ns] collision_deactivate_cell %u %u %u\n", c_GetNanoSeconds(c_GetTimerValue(), v1), mapId, tileX, tileY);
	}

	m_loadLock.Release();
}
示例#2
0
	ConsoleSocket * GetRequest(uint32 id)
	{
		ConsoleSocket* rtn;
		authmgrlock.Acquire();
		map<uint32,ConsoleSocket*>::iterator itr = requestmap.find(id);
		if(itr == requestmap.end())
			rtn = NULL;
		else
			rtn = itr->second;
		authmgrlock.Release();
		return rtn;
	}
示例#3
0
void CCollideInterface::ActivateTile(uint32 mapId, uint32 tileX, uint32 tileY)
{
	VMAP::IVMapManager* mgr = VMAP::VMapFactory::createOrGetVMapManager();
	m_loadLock.Acquire();
	if(m_tilesLoaded[mapId][tileX][tileY] == 0)
	{
		mgr->loadMap(sWorld.vMapPath.c_str(), mapId, tileX, tileY);
		LoadNavMeshTile(mapId, tileX, tileY);
	}
	++m_tilesLoaded[mapId][tileX][tileY];
	m_loadLock.Release();
}
示例#4
0
void CCollideInterface::ActivateTile(uint32 mapId, uint32 tileX, uint32 tileY)
{
	m_loadLock.Acquire();
	if(m_tilesLoaded[mapId][tileX][tileY] == 0)
	{
		COLLISION_BEGINTIMER;
		CollisionMgr->loadMap(sWorld.vMapPath.c_str, mapId, tileY, tileX);
		//LOG_DEBUG("[%u ns] collision_activate_cell %u %u %u", c_GetNanoSeconds(c_GetTimerValue(), v1), mapId, tileX, tileY);
	}

	++m_tilesLoaded[mapId][tileX][tileY];
	m_loadLock.Release();
}
示例#5
0
bool IsServerAllowedMod(unsigned int IP)
{
	m_allowedIpLock.Acquire();
	for(vector<AllowedIP>::iterator itr = m_allowedModIps.begin(); itr != m_allowedModIps.end(); ++itr)
	{
		if( ParseCIDRBan(IP, itr->IP, itr->Bytes) )
		{
			m_allowedIpLock.Release();
			return true;
		}
	}
	m_allowedIpLock.Release();
	return false;
}
示例#6
0
void CCollideInterface::ActivateMap(uint32 mapId)
{
	if( !CollisionMgr ) return;
	m_mapCreateLock.Acquire();
	if( m_mapLocks[mapId] == NULL )
	{
		m_mapLocks[mapId] = new CollisionMap;
		m_mapLocks[mapId]->m_loadCount = 1;
		memset(m_mapLocks[mapId]->m_tileLoadCount, 0, sizeof(uint32)*64*64);
	}
	else
		m_mapLocks[mapId]->m_loadCount++;

	m_mapCreateLock.Release();
}
示例#7
0
void CCollideInterface::DeactivateMap(uint32 mapId)
{
	if( !CollisionMgr ) return;
	m_mapCreateLock.Acquire();
	ASSERT(m_mapLocks[mapId] != NULL);
	--m_mapLocks[mapId]->m_loadCount;
	if( m_mapLocks[mapId]->m_loadCount == 0 )
	{
		// no instances using this anymore
		delete m_mapLocks[mapId];
		CollisionMgr->unloadMap(mapId);
		m_mapLocks[mapId] = NULL;
	}
	m_mapCreateLock.Release();
}
示例#8
0
//when player pushes gossip menu to start event
void StartJumpEvent(Player *Plr, uint64 NPCGUID)
{
	CreateLock.Acquire();
	//check if this player already has an ongoing jump event
	uint64 PlayerGUID = Plr->GetGUID();
	uint32 stampnow = GetTickCount();
	for( uint32 i=0;i<MAX_NUMBER_OF_CONCURENT_JUMP_EVENT_HOLDERS;i++)
		if( JumpEventHolders[i].PlayerGUID == PlayerGUID 
			&& stampnow < JumpEventHolders[i].EventExpireStamp
			)
		{
			Plr->BroadcastMessage("You are already participating in a Jump Event. Close that one");
			CreateLock.Release();
			return;
		}
	//check if NPC already is busy with someone
	int32 NPC_slot = -1;
	for( uint32 i=0;i<MAX_NUMBER_OF_CONCURENT_JUMP_EVENT_HOLDERS;i++)
		if( JumpEventHolders[i].SupervizorNPC == NPCGUID )
		{
			if( stampnow < JumpEventHolders[i].EventExpireStamp	)
			{
				Plr->BroadcastMessage("This NPC seems to be busy with someone. Strange.");
				CreateLock.Release();
				return;
			}
			NPC_slot = i;
		}
	//sanity check
	if( NPC_slot == -1 )
	{
		Plr->BroadcastMessage("Omg Bug.Shoot a developer pls and wait a server crash to refresh list");
		CreateLock.Release();
		return;
	}
	//ocupy this slot
	JumpEventHolders[ NPC_slot ].PlayerGUID = PlayerGUID;
	JumpEventHolders[ NPC_slot ].EventExpireStamp = MAX_EVENT_DURATION + stampnow;
	JumpEventHolders[ NPC_slot ].EventState = JES_WAITING_TO_START;
	CreateLock.Release();
	//start timer player side also
	uint32 estimated_time = Plr->getLevel() * 10;
	WorldPacket data(SMSG_START_MIRROR_TIMER, 20);
	data << uint32( TIMER_EXHAUSTION ) << estimated_time << estimated_time << int32(-1) << uint32(0);
	Plr->GetSession()->SendPacket(&data);
	//rest will be done by the supervizor AI : generate pads, spawn them 1 by 1, monitor progress
}
示例#9
0
void Transporter::AddNPC(uint32 Entry, float offsetX, float offsetY, float offsetZ, float offsetO)
{
	uint32 guid;
	m_transportGuidGen.Acquire();
	guid = ++m_transportGuidMax;
	m_transportGuidGen.Release();

	CreatureInfo * inf = CreatureNameStorage.LookupEntry(Entry);
	CreatureProto * proto = CreatureProtoStorage.LookupEntry(Entry);
	if(inf==NULL||proto==NULL)
		return;

	Creature * pCreature = new Creature((uint64)HIGHGUID_TYPE_TRANSPORTER<<32 | guid);
	pCreature->Load(proto, m_position.x, m_position.y, m_position.z);
	pCreature->m_transportPosition = new LocationVector(offsetX, offsetY, offsetZ, offsetO);
	pCreature->m_transportGuid = GetUIdFromGUID();
	m_npcs.insert(make_pair(guid,pCreature));
}
示例#10
0
//early end a jump event due to player request
void EarlyEndJumpEvent(Player *Plr, uint64 NPCGUID)
{
	CreateLock.Acquire();
	//check if this player already has an ongoing jump event
	uint64 PlayerGUID = Plr->GetGUID();
	for( uint32 i=0;i<MAX_NUMBER_OF_CONCURENT_JUMP_EVENT_HOLDERS;i++)
		if( JumpEventHolders[i].PlayerGUID == PlayerGUID 
			&& JumpEventHolders[i].SupervizorNPC == NPCGUID
			)
		{
			Plr->BroadcastMessage("Removing now");
			//stop timer player side also
			Plr->StopMirrorTimer( TIMER_EXHAUSTION );
			//clear identifyers
			JumpEventHolders[i].EventExpireStamp = 0;
			JumpEventHolders[i].PlayerGUID = 0;
			JumpEventHolders[i].EventState = JES_NOTHING_INTELIGENT;
		}
	CreateLock.Release();
}
示例#11
0
void Transporter::AddNPC(uint32 Entry, float offsetX, float offsetY, float offsetZ, float offsetO)
{
    if(!this)
        return;

    uint32 guid;
    m_transportGuidGen.Acquire();
    guid = ++m_transportGuidMax;
    m_transportGuidGen.Release();

    CreatureInfo * inf = CreatureNameStorage.LookupEntry(Entry);
    CreatureProto * proto = CreatureProtoStorage.LookupEntry(Entry);
    if(inf == NULL || proto == NULL)
        return;

    Creature* pCreature(new Creature((uint64)HIGHGUID_TYPE_TRANSPORTER<<32 | guid));
    pCreature->Init();
    pCreature->Load(proto, GetMapMgr()->iInstanceMode, offsetX, offsetY, offsetZ, offsetO);
    pCreature->GetMovementInfo()->SetTransportData(GetGUID(), offsetX, offsetY, offsetZ, offsetO, 0);
    m_npcs.insert(make_pair(guid,pCreature));
}
示例#12
0
void Transporter::AddNPC(uint32 Entry, float offsetX, float offsetY, float offsetZ, float offsetO)
{
    uint32 guid;
    m_transportGuidGen.Acquire();
    guid = ++m_transportGuidMax;
    m_transportGuidGen.Release();

    CreatureInfo* inf = CreatureNameStorage.LookupEntry(Entry);
    CreatureProto* proto = CreatureProtoStorage.LookupEntry(Entry);
    if (inf == NULL || proto == NULL)
        return;

    Creature* pCreature = new Creature((uint64)HIGHGUID_TYPE_TRANSPORTER << 32 | guid);
    pCreature->Load(proto, m_position.x, m_position.y, m_position.z);
    pCreature->obj_movement_info.transporter_info.position.x = offsetX;
    pCreature->obj_movement_info.transporter_info.position.y = offsetY;
    pCreature->obj_movement_info.transporter_info.position.z = offsetZ;
    pCreature->obj_movement_info.transporter_info.position.o = offsetO;
    pCreature->obj_movement_info.transporter_info.guid = GetGUID();
    m_npcs.insert(std::make_pair(guid, pCreature));
}
示例#13
0
Channel * ChannelMgr::GetCreateChannel(const char *name, Player * p, uint32 type_id)
{
	ChannelList::iterator itr;
	ChannelList * cl = &Channels[0];
	Channel * chn;
	uint32 cid;
	if( seperatechannels && p != NULL )
		cl = &Channels[p->GetTeam()];

	lock.Acquire();
	for(itr = cl->begin(); itr != cl->end(); ++itr)
	{
		if(!stricmp(name, itr->first.c_str()))
		{
			lock.Release();
			return itr->second;
		}
	}

	// make sure the name isn't banned
	m_confSettingLock.Acquire();
	for(vector<string>::iterator itr = m_bannedChannels.begin(); itr != m_bannedChannels.end(); ++itr)
	{
		if(!strnicmp( name, itr->c_str(), itr->size() ) )
		{
			lock.Release();
			m_confSettingLock.Release();
			return NULL;
		}
	}
	m_confSettingLock.Release();

	cid = ++m_idHigh;
	chn = new Channel(name, ( seperatechannels && p != NULL ) ? p->GetTeam() : 0, type_id, cid);
	cl->insert(make_pair(chn->m_name, chn));
	m_idToChannel.insert(make_pair(cid, chn));
	lock.Release();
	return chn;
}
示例#14
0
void Transporter::AddNPC(uint32 Entry, float offsetX, float offsetY, float offsetZ, float offsetO)
{
	if(!this)
		return;

	uint32 guid;
	m_transportGuidGen.Acquire();
	guid = ++m_transportGuidMax;
	m_transportGuidGen.Release();

	CreatureInfo * inf = CreatureNameStorage.LookupEntry(Entry);
	CreatureProto * proto = CreatureProtoStorage.LookupEntry(Entry);
	if(inf == NULL || proto == NULL)
		return;

	Creature* pCreature(new Creature((uint64)HIGHGUID_TYPE_TRANSPORTER<<32 | guid));
	pCreature->Init();
	pCreature->Load(proto, GetMapMgr()->iInstanceMode, offsetX, offsetY, offsetZ, offsetO);
	pCreature->m_TransporterUnk = UNIXTIME;
	pCreature->m_transportPosition = new LocationVector(offsetX, offsetY, offsetZ, offsetO);
	pCreature->m_TransporterGUID = GetGUID();
	pCreature->m_transportNewGuid = GetNewGUID();
	m_npcs.insert(make_pair(guid,pCreature));
}
示例#15
0
Channel* ChannelMgr::GetCreateChannel(const char* name, Player* p, uint32 type_id)
{
	ChannelList::iterator itr;
	ChannelList* cl = &Channels[0];
	Channel* chn;
	if(seperatechannels && p != NULL && stricmp(name, sWorld.getGmClientChannel().c_str()))
		cl = &Channels[p->GetTeam()];

	lock.Acquire();
	for(itr = cl->begin(); itr != cl->end(); ++itr)
	{
		if(!stricmp(name, itr->first.c_str()))
		{
			lock.Release();
			return itr->second;
		}
	}

	// make sure the name isn't banned
	m_confSettingLock.Acquire();
	for(vector<string>::iterator itr2 = m_bannedChannels.begin(); itr2 != m_bannedChannels.end(); ++itr2)
	{
		if(!strnicmp(name, itr2->c_str(), itr2->size()))
		{
			lock.Release();
			m_confSettingLock.Release();
			return NULL;
		}
	}

	chn = new Channel(name, (seperatechannels && p != NULL) ? p->GetTeam() : 0, type_id);
	m_confSettingLock.Release();//Channel::Channel() reads configs so we release the lock after we create the Channel.
	cl->insert(make_pair(chn->m_name, chn));
	lock.Release();
	return chn;
}
示例#16
0
bool Rehash()
{
#ifdef WIN32
	char * config_file = "configs/logon.conf";
#else
	char * config_file = (char*)CONFDIR "/logon.conf";
#endif
	if(!Config.MainConfig.SetSource(config_file))
	{
		printf("Config file could not be rehashed.\n");
		return false;
	}

	// re-set the allowed server IP's
	string ips = Config.MainConfig.GetStringDefault("LogonServer", "AllowedIPs", "");
	string ipsmod = Config.MainConfig.GetStringDefault("LogonServer", "AllowedModIPs", "");

	vector<string> vips = StrSplit(ips, " ");
	vector<string> vipsmod = StrSplit(ips, " ");

	m_allowedIpLock.Acquire();
	m_allowedIps.clear();
	m_allowedModIps.clear();
	vector<string>::iterator itr;
	for(itr = vips.begin(); itr != vips.end(); ++itr)
	{
		string::size_type i = itr->find("/");
		if( i == string::npos )
		{
			printf("IP: %s could not be parsed. Ignoring\n", itr->c_str());
			continue;
		}

		string stmp = itr->substr(0, i);
		string smask = itr->substr(i+1);

		unsigned int ipraw = MakeIP(stmp.c_str());
		unsigned char ipmask = (char)atoi(smask.c_str());
		if( ipraw == 0 || ipmask == 0 )
		{
			printf("IP: %s could not be parsed. Ignoring\n", itr->c_str());
			continue;
		}

		AllowedIP tmp;
		tmp.Bytes = ipmask;
		tmp.IP = ipraw;
		m_allowedIps.push_back(tmp);
	}

	for(itr = vipsmod.begin(); itr != vipsmod.end(); ++itr)
	{
		string::size_type i = itr->find("/");
		if( i == string::npos )
		{
			printf("IP: %s could not be parsed. Ignoring\n", itr->c_str());
			continue;
		}

		string stmp = itr->substr(0, i);
		string smask = itr->substr(i+1);

		unsigned int ipraw = MakeIP(stmp.c_str());
		unsigned char ipmask = (char)atoi(smask.c_str());
		if( ipraw == 0 || ipmask == 0 )
		{
			printf("IP: %s could not be parsed. Ignoring\n", itr->c_str());
			continue;
		}

		AllowedIP tmp;
		tmp.Bytes = ipmask;
		tmp.IP = ipraw;
		m_allowedModIps.push_back(tmp);
	}

	if( InformationCore::getSingletonPtr() != NULL )
		sInfoCore.CheckServers();

	m_allowedIpLock.Release();

	return true;
}
示例#17
0
文件: trace.cpp 项目: pdh11/chorale
Tracer::Tracer(const char *env_var, const char *file, unsigned int line)
    : m_emit(false)
{
    s_trace_mutex.Acquire();

#ifdef __APPLE__
    m_emit = true;
#endif

    if (getenv("LOG_ALL"))
	m_emit = true;
    else
    {
	if (env_var)
	{
	    const char *value = getenv(env_var);
	    if (value && *value)
		m_emit = true;
	}
	else
	    m_emit = true;
    }

    if (m_emit)
    {
	if (getenv("LOG_TIME"))
	{
	    struct timeval tv;
	    gettimeofday(&tv, NULL);

	    if (s_logfile)
		fprintf(s_logfile, "%09u.%06u:", (unsigned)tv.tv_sec,
			(unsigned)tv.tv_usec);
	    else
		printf("%09u.%06u:", (unsigned)tv.tv_sec,
		       (unsigned)tv.tv_usec);

//	    struct timespec tp;
//	    clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp);
//	    printf("%02u.%09u:", (unsigned)tp.tv_sec,
//		   (unsigned)tp.tv_nsec);
	}
	if (getenv("LOG_TID"))
	{
	    /// @todo boost::thread_id
#if HAVE_GETTID
	    unsigned int raw_tid = gettid();
#elif HAVE_NR_GETTID
	    unsigned int raw_tid = (unsigned int)syscall(__NR_gettid);
#elif HAVE_GETCURRENTTHREADID
	    unsigned int raw_tid = ::GetCurrentThreadId();
#else
#warning "No thread id implementation on this platform"
	    unsigned int raw_tid = 0;
#endif
	    static std::map<unsigned int, unsigned int> tidmap;
	    if (tidmap.find(raw_tid) == tidmap.end())
	    {
		// We're still under the Tracer sm_mutex so this is safe
		unsigned int tid = (unsigned int)tidmap.size();
		tidmap[raw_tid] = tid;
	    }

	    if (s_logfile)
		fprintf(s_logfile, "%03u:", tidmap[raw_tid]);
	    else
		printf("%03u:", tidmap[raw_tid]);
	}

	if (!strncmp(file, "../", 3))
	    file += 3;

	if (s_logfile)
	    fprintf(s_logfile, "%-25s:%4u: ", file, line);
	else
	    printf("%-25s:%4u: ", file, line);
    }
}
示例#18
0
void TizenMutexManager::lockMutex(OSystem::MutexRef mutex) {
	Mutex *m = (Mutex *)mutex;
	m->Acquire();
}