Пример #1
0
 void get_ip_nettype(char* content, char res[][MaxFieldLenInNetStatus],const int32_t max_field_count,  int32_t& count, char* ip, char* nettype)
 {
	 if(NULL == content)
	 {
		 return;
	 }

	 count = 0;
	 for(int32_t i=0; i<(int32_t)strlen(content); ++i)
	 {
		 if(content[i] == ':')
		 {
			 count++;
		 }
	 }

	 if(CurFieldCountInNetStatus != (count + 1))
	 {
		 return;
	 }

	 int32_t cnt_count = 0;
	 int32_t pindex = 0;
	 int32_t resindex = 0;
	 while(cnt_count < count)
	 {
		 if(content[pindex] == ':')
		 {
			 cnt_count++;
			 resindex= 0;
			 pindex++;
		 }
		 else
		 {
			 if(resindex >= MaxFieldLenInNetStatus)
			 {
				 return;
			 }
			 res[cnt_count][resindex] = content[pindex];
			 pindex++;
			 resindex++;
		 }
	 }

	 //拷贝最后一个字段
	 resindex = 0;

	 if(strlen(content) - pindex >= MaxFieldLenInNetStatus)
	 {
		 strncpy(res[count], &content[pindex], MaxFieldLenInNetStatus - 1);
	 }
	 else
	 {
		 strncpy(res[count], &content[pindex], strlen(content) - pindex);
	 }

	strcpy_safe(ip, enmMaxIPAddressLength, res[2], MaxFieldLenInNetStatus);
	strcpy_safe(nettype, MaxNetTypeLen, res[0], MaxFieldLenInNetStatus);
 }
Пример #2
0
void ZRoomListBox::SetRoomName( int i, char* pRoomName, sMapInfo* info )
{
	strcpy_safe( m_pMapInfo[i].map_name,  info->map_name );
	strcpy_safe( m_pMapInfo[i].room_name,  info->room_name );
	m_pMapInfo[i].nPeople		= info->nPeople;
	m_pMapInfo[i].RoomNumber	= info->RoomNumber;
	m_pMapInfo[i].nMaxPeople	= info->nMaxPeople;
	m_pMapInfo[i].roomState		= info->roomState;
}
Пример #3
0
void MMatchClan::InitClanInfoEx(const int nLevel, const int nTotalPoint, const int nPoint, const int nRanking,
		            const int nWins, const int nLosses, const int nTotalMemberCount, const char* szMaster,
					const char* szEmblemUrl, int nEmblemChecksum)
{
	m_ClanInfoEx.nLevel = nLevel;
	m_ClanInfoEx.nTotalPoint = nTotalPoint;
	m_ClanInfoEx.nPoint = nPoint;
	m_ClanInfoEx.nRanking = nRanking;
	m_ClanInfoEx.nWins = nWins;
	m_ClanInfoEx.nLosses = nLosses;
	m_ClanInfoEx.nTotalMemberCount = nTotalMemberCount;
	strcpy_safe(m_ClanInfoEx.szMaster, szMaster);
	strcpy_safe(m_ClanInfoEx.szEmblemUrl, szEmblemUrl);
	m_ClanInfoEx.nEmblemChecksum = nEmblemChecksum;
}
Пример #4
0
bool MMatchAdmin::Execute(const MUID& uidAdmin, const char* szStr)
{
	if (!m_pMatchServer) return false;

	MAdminArgvInfo ai;
	memset(&ai, 0, sizeof(ai));

	char szBuf[1024];
	strcpy_safe(szBuf, szStr);

	if (MakeArgv(szBuf, &ai))
	{
		if (ai.cargc > 0)
		{
			char szOut[65535];
			if (m_pMatchServer->OnAdminExecute(&ai, szOut))
			{
				m_pMatchServer->AdminTerminalOutput(uidAdmin, szOut);
			}
		}
	}
	else
	{
		return false;
	}

	return true;
}
Пример #5
0
bool MEmblemMgr::CreateCache()
{
	TCHAR szEmblemPath[MAX_PATH]="";
	TCHAR szPath[MAX_PATH]="";

	if(GetMyDocumentsPath(szPath)) {
		strcpy_safe(szEmblemPath, szPath);
		strcat_safe(szEmblemPath, GUNZ_FOLDER);
		CreatePath(szEmblemPath);

		strcat_safe(szEmblemPath, MPATH_EMBLEMFOLDER);
		CreatePath(szEmblemPath);

		strcat_safe(szEmblemPath, MPATH_EMBLEMFILE);
	} else {
		return false;
	}

	MXmlDocument	xmlDoc;

	xmlDoc.Create();
	bool bResult = xmlDoc.SaveToFile(szEmblemPath);
	xmlDoc.Destroy();

	return bResult;
}
Пример #6
0
bool RWFile::open(const char* path, ExistingFileAction efa)
{
	if (efa.Value == Nonexistent.Value && Exists(path))
	{
		state.error = true;
		return false;
	}

	char mode_string[8];
	auto base_string = [&] {
		switch (efa.Value)
		{
		case Nonexistent.Value:
		case Clear.Value:
			return "w+";
		case Append.Value:
			return "a+";
		case Prepend.Value:
			// "r+" will fail if the file doesn't exist.
			return Exists(path) ? "r+" : "w+";
		}
		assert(false);
		return "r+";
	}();
	strcpy_safe(mode_string, base_string);
	if (!efa.Text)
		strcat_safe(mode_string, "b");

	return open_impl(path, mode_string);
}
Пример #7
0
static bool GetNextFileData(FileRange& Range)
{
	do {
		++Range.CurFileIndex;
	} while (Range.CurFileIndex < Range.GlobData.gl_pathc && IsDots(Range.GlobData.gl_pathv[Range.CurFileIndex]));

	if (Range.CurFileIndex >= Range.GlobData.gl_pathc)
	{
		Range.GlobData.gl_pathc = 0;
		return false;
	}

 	auto Path = Range.GlobData.gl_pathv[Range.CurFileIndex];
 	auto MaybeAttributes = GetAttributes(Path);
	if (!MaybeAttributes)
	{
		Range.Handle = nullptr;
		Range.ErrorCode = errno;
		return false;
	}
	auto& Attributes = *MaybeAttributes;
	FileData& dest = Range.Data;
	dest.Attributes = Attributes.Attributes;
	dest.CreationTime = Attributes.CreationTime;
	dest.LastAccessTime = Attributes.LastAccessTime;
	dest.LastModifiedTime = Attributes.LastModifiedTime;
	dest.Size = Attributes.Size;
	std::string PathCopy = Path;
	strcpy_safe(dest.Name, basename(PathCopy.c_str()));

	return true;
}
Пример #8
0
void ZRoomListBox::RequestSelStageJoin()
{
	MUID uidChar = ZGetGameClient()->GetPlayerUID();

	if (GetSelRoomUID() != MUID(0,0))
	{
		if ( (ZGetMyInfo()->IsAdminGrade() == false) && (m_pMapInfo[m_Selection].bPrivate) )
		{
			char szStageName[SMI_ROOMNAME_LENGTH] = "";
			MUID uidStage = MUID(0,0);

			const sMapInfo* pSelRoomInfo = GetSelMapInfo();

			if (pSelRoomInfo != NULL)
			{
				strcpy_safe(szStageName, pSelRoomInfo->room_name);
				uidStage = pSelRoomInfo->uidStage;
			}

			SetPrivateStageUID(uidStage);

			// 비밀방
			ZApplication::GetGameInterface()->ShowPrivateStageJoinFrame(szStageName);
		}
		else
		{
			ZPostRequestStageJoin(uidChar, GetSelRoomUID());	// 공개방
			ZApplication::GetGameInterface()->EnableLobbyInterface(false);
		}
	}
}
Пример #9
0
bool MMatchChannel::Create(const MUID& uid, const char* pszName, const char* pszRuleName, 
						MCHANNEL_TYPE nType, int nMaxPlayers, int nLevelMin, int nLevelMax)
{
	m_nEmptyPeriod = 0;
	m_nMaxStages = DEFAULT_CHANNEL_MAXSTAGES;
	m_uidChannel = uid;
	strcpy_safe(m_szChannelName, pszName);
	strcpy_safe(m_szRuleName, pszRuleName);
	m_nChannelType = nType;
	m_nMaxPlayers = nMaxPlayers;
	m_nLevelMin = nLevelMin;
	m_nLevelMax = nLevelMax;
	m_nRuleType = MCHANNEL_RULE_NOVICE;

	//// Paged UserList and SmartRefreshing ////
	m_UserArray.Reserve(NUM_PLAYERLIST_NODE, nMaxPlayers);
	int nMaxPage = (int)ceil((float)nMaxPlayers/(float)NUM_PLAYERLIST_NODE);
	for (int i=0; i<nMaxPage; i++) {
		m_SmartRefresh.AddCategory(new MRefreshCategoryChannelImpl(this, i));
	}

	for (int i = 0; i < m_nMaxStages; i++)
	{
		m_UnusedStageIndexList.push_back(i);
	}

	memset(m_pStages, 0, sizeof(MMatchStage*) * MAX_CHANNEL_MAXSTAGES);


	// 채널룰에 대한 특성들 정의
	if (nType == MCHANNEL_TYPE_PRESET)
	{
		if (!_stricmp(m_szRuleName, MCHANNEL_RULE_NOVICE_STR))		m_nRuleType = MCHANNEL_RULE_NOVICE;
		else if (!_stricmp(m_szRuleName, MCHANNEL_RULE_NEWBIE_STR))	m_nRuleType = MCHANNEL_RULE_NEWBIE;
		else if (!_stricmp(m_szRuleName, MCHANNEL_RULE_ROOKIE_STR))	m_nRuleType = MCHANNEL_RULE_ROOKIE;
		else if (!_stricmp(m_szRuleName, MCHANNEL_RULE_MASTERY_STR)) m_nRuleType = MCHANNEL_RULE_MASTERY;
		else if (!_stricmp(m_szRuleName, MCHANNEL_RULE_ELITE_STR))	m_nRuleType = MCHANNEL_RULE_ELITE;
	}

	// 룰이름이 "newbie"이면 뉴비채널
//	if ((nType == MCHANNEL_TYPE_PRESET) && (!_stricmp(m_szRuleName, MCHANNEL_RULE_NEWBIE_STR)))
//	{
//		m_bNewbieChannel = true;
//	}

	return true;
}
bool MAsyncDBJob_InsertConnLog::Input(u32 nAID, char* szIP, const string& strCountryCode3 )
{
	m_nAID = nAID;
	strcpy_safe(m_szIP, szIP);
	m_strCountryCode3 = strCountryCode3;

	return true;
}
Пример #11
0
void MMatchClan::Create(int nCLID, const char* szClanName)
{
	m_nCLID = nCLID;
	strcpy_safe(m_szClanName, szClanName);


	m_SmartRefresh.AddCategory(new MRefreshCategoryClanMemberImpl(this, 0));	// Category 0 로 전체목록 모두 담당
}
Пример #12
0
static void CopyFileData(FileData& dest, const _finddata_t& src)
{
	dest.Attributes = src.attrib;
	dest.CreationTime = src.time_create;
	dest.LastAccessTime = src.time_access;
	dest.LastModifiedTime = src.time_write;
	dest.Size = src.size;
	strcpy_safe(dest.Name, src.name);
}
Пример #13
0
void ZRoomListBox::SetRoom(const _RoomInfoArg* pRoomInfo)
{
	int nIndex = pRoomInfo->nIndex; 

	if ((pRoomInfo->nIndex < 0) || (pRoomInfo->nIndex >= NUM_DISPLAY_ROOM)) return;

	m_pMapInfo[nIndex].IsEmpty = false;
	m_pMapInfo[nIndex].uidStage = pRoomInfo->uidStage;
	
	strcpy_safe(m_pMapInfo[nIndex].map_name, pRoomInfo->szMapName);
	strcpy_safe(m_pMapInfo[nIndex].room_name, pRoomInfo->szRoomName);
	m_pMapInfo[nIndex].nMaxPeople = pRoomInfo->nMaxPlayers;
	m_pMapInfo[nIndex].nPeople = pRoomInfo->nCurrPlayers;
	m_pMapInfo[nIndex].RoomNumber = pRoomInfo->nRoomNumber;
	m_pMapInfo[nIndex].nGame_Type	= pRoomInfo->nGameType;
	m_pMapInfo[nIndex].bForcedEnter = pRoomInfo->bForcedEntry;
	m_pMapInfo[nIndex].bLimitLevel	=	pRoomInfo->bLimitLevel;
	m_pMapInfo[nIndex].nMasterLevel = pRoomInfo->nMasterLevel;
	m_pMapInfo[nIndex].nLimitLevel = pRoomInfo->nLimitLevel;
	m_pMapInfo[nIndex].bPrivate = pRoomInfo->bPrivate;

 	if( pRoomInfo->nStageState == STAGE_STATE_STANDBY )
	{
		m_pMapInfo[nIndex].roomState = GAME_WAITING; // 대기중
	}
	//else if(	pRoomInfo->nStageState == STAGE_STATE_CLOSE && !pRoomInfo->bForcedEntry )
	//{
	//	m_pMapInfo[nIndex].roomState	= GMAE_CLOSED; // 난입 불가
	//}
	else if( pRoomInfo->nStageState == STAGE_STATE_RUN && pRoomInfo->bForcedEntry)
	{
		//m_pMapInfo[nIndex].roomState	= GAME_WAITING;
		m_pMapInfo[nIndex].roomState	= GAME_PLAYING	; // 난입 가능
	}
	else
	{
		m_pMapInfo[nIndex].roomState	= GMAE_CLOSED; // 난입 불가
	}

}
Пример #14
0
MCommandParameterString::MCommandParameterString(const char* Value)
 : MCommandParameter(MPT_STR)
{
	int nLen = (int)strlen(Value) + 2;

	if (nLen > (USHRT_MAX-2))
	{
		m_Value = 0;
		return;
	}

	m_Value = new char[nLen];
	strcpy_safe(m_Value, nLen, Value);
}
Пример #15
0
bool UPnP::GetIp()
{
	char HostName[256];
	hostent * Host;
	MSocket::sockaddr_in Addr;

	auto ret = gethostname(HostName, 256);

	if(ret != 0)
	{
#ifdef MFC
		TRACE("UPnP: gethostname failed\n");
#endif
		return false;
	}else{
#ifdef MFC
		TRACE("UPnP: HostName: %s\n", HostName);
#endif
	}
#pragma warning(push)
#pragma warning(disable: 4996)
	Host = gethostbyname(HostName);
#pragma warning(pop)
	if(Host == NULL)
	{
#ifdef MFC
		TRACE("UPnP: gethostbyname failed\n");
#endif
		return false;
	}
	Addr.sin_addr.s_addr = ((MSocket::in_addr *)Host->h_addr)->s_addr;
	auto Address = GetIPv4String(Addr.sin_addr);

	if(Address.empty())
	{
#ifdef MFC
		TRACE("UPnP: inet_ntoa failed\n");
#endif
		return false;
	}

	strcpy_safe(m_Address, Address.c_str());

#ifdef MFC
	TRACE("UPnP: Local Ip: %s\n", m_Address);
#endif

	return true;
}
Пример #16
0
bool MEmblemMgr::InitDefaut()
{
	if(GetMyDocumentsPath(m_szEmblemBaseDir)) {
		// EmblemBaseFolder
		strcat_safe(m_szEmblemBaseDir, GUNZ_FOLDER);
		strcat_safe(m_szEmblemBaseDir, MPATH_EMBLEMFOLDER);
		
		// EmblemDataFile
		strcpy_safe(m_szEmblemDataFile, m_szEmblemBaseDir);
		strcat_safe(m_szEmblemDataFile, MPATH_EMBLEMFILE);
		return true;
	} else {
		return false;
	}
}
Пример #17
0
RC mdb_Init(const char *filename)
{
    static int ready = 0;
    if (ready) {
        return RC_ALREADYINITIALISED;
    }
    ready = 1;
    atexit(call_exit);
    masterTable = calloc(1, sizeof(*masterTable));
    masterTable->rec.reclen = sizeof(recMASTER_t);
    strcpy_safe(masterfilename, filename);
    if (idb_TabGetFileSize(masterTable) == 0) {
        idb_TabCreateInDisk(masterTable);
    }
    return RC_OK;
}
Пример #18
0
void MMatchServer::AdminTerminalOutput(const MUID& uidAdmin, const char* szText)
{
	MMatchObject* pObj = GetObject(uidAdmin);
	if (pObj == NULL) return;

	// 관리자 권한을 가진 사람이 아니면 연결을 끊는다.
	if (pObj->GetAccountInfo()->m_nUGrade != MMUG_ADMIN)
	{
//		DisconnectObject(uidAdmin);		
		return;
	}

	char szMsg[65535];
	strcpy_safe(szMsg, szText);

	MCommand* pCmd = CreateCommand(MC_ADMIN_TERMINAL, MUID(0,0));
	pCmd->AddParameter(new MCmdParamUID(uidAdmin));
	pCmd->AddParameter(new MCmdParamStr(szMsg));

	RouteToListener(pObj, pCmd);
}
Пример #19
0
void ZRoomListBox::RequestSelPrivateStageJoin()
{
	MUID uidChar = ZGetGameClient()->GetPlayerUID();
	ZIDLResource* pResource = ZApplication::GetGameInterface()->GetIDLResource();

	MUID uidStageUID = GetSelectedPrivateStageUID();

	if (uidStageUID == MUID(0,0)) uidStageUID = GetSelRoomUID();

	if (uidStageUID != MUID(0,0))
	{
		MEdit* pPassEdit = (MEdit*)pResource->FindWidget("PrivateStagePassword");
		if (pPassEdit!=NULL)
		{
			char szPassword[256];
			strcpy_safe(szPassword, pPassEdit->GetText());

			ZPostRequestPrivateStageJoin(uidChar, uidStageUID, szPassword);
			ZApplication::GetGameInterface()->EnableLobbyInterface(false);
		}
	}
}
Пример #20
0
static void MBMatchServerLog(unsigned int LogLevel, const char* Msg, bool Newline)
{
	static std::mutex LogMutex;
	std::lock_guard<std::mutex> Lock(LogMutex);

	char Str[1024 * 16];
	ArrayView<char> Remaining = Str;
	auto Consumed = strftime(Str, sizeof(Str), "%FT%T%z", localtime(&unmove(time(0))));
	if (!Consumed)
	{
		assert(false);
		return;
	}
	Remaining.remove_prefix(Consumed);
	auto Append = [&](const char* a) {
		auto Zero = strcpy_safe(Remaining, a);
		Remaining.remove_prefix(Zero - Remaining.data());
	};
	Append(" | ");
	Append(Msg);
	Append(Newline ? "\n" : "");

	fputs(Str, stdout);

	if (LogLevel & MMatchServer::LOG_FILE)
		MLogFile(Str);

#ifdef _DEBUG
	if (LogLevel & MMatchServer::LOG_DEBUG)
	{
		OutputDebugString(Msg);
		if (Newline)
			OutputDebugString("\n");
	}
#endif

}
Пример #21
0
ZActor::ZActor() : m_nFlags(0), m_nNPCType(NPC_GOBLIN_KING), m_pNPCInfo(NULL),
m_pModule_Skills(NULL), m_fSpeed(0.0f), m_pBrain(NULL)
{
	m_bIsNPC = true;

	memset(m_nLastTime, 0, sizeof(m_nLastTime));

	m_Position = rvector(0.0f, 0.0f, 0.0f);
	m_Direction = rvector(1.0f, 0.0f, 0.0f);
	m_TargetDir = rvector(1.0f, 0.0f, 0.0f);
	m_Accel = rvector(0.0f, 0.0f, 0.0f);

	m_Animation.Init(this);

	SetVisible(true);

	m_bInitialized = true;

	m_fDelayTime = 0.0f;
	m_fTC = 1.0f;
	m_nQL = 0;

	SetFlag(AF_LAND, true);

	m_bTestControl = false;

	m_TempBackupTime = -1;

	m_vAddBlastVel = rvector(0.f,0.f,0.f);
	m_fAddBlastVelTime = 0.f;

	strcpy_safe(m_szOwner,"unknown");

	m_TaskManager.SetOnFinishedCallback(OnTaskFinishedCallback);

	m_nDamageCount = 0;
}
Пример #22
0
bool CreateParentDirs(StringView PathArgument)
{
	auto Sep = "/\\"_sv;
	auto FirstIndex = PathArgument.find_first_of(Sep);
	if (FirstIndex == PathArgument.npos)
		return true; // No directories.

	// Create our own copy so we can add zeroes.
	char Path[MFile::MaxPath];
	strcpy_safe(Path, PathArgument);
	auto End = Path + PathArgument.size();

	char* p = Path + FirstIndex;
	while (true)
	{
		// Set the current slash to zero, and revert this change before the next loop iteration.
		auto OldValue = *p;
		*p = 0;
		// Capture by value to ignore the change to p at the end.
		DEFER([=] { *p = OldValue; });

		if (!MFile::IsDir(Path))
		{
			if (!MFile::CreateDir(Path))
			{
				return false;
			}
		}

		p = std::find_first_of(p + 1, End, Sep.begin(), Sep.end());
		if (p == End)
			break;
	}

	return true;
}
Пример #23
0
bool MMatchServer::OnAdminExecute(MAdminArgvInfo* pAI, char* szOut, int maxlen)
{
	szOut[0] = 0;

	if (pAI->cargc <= 0) return false;

	// wall
	if (!_stricmp(pAI->cargv[0], "wall"))
	{
		if (pAI->cargc < 3)
		{
			sprintf_safe(szOut, maxlen, "인자가 부족합니다.");
			return true;
		}

		char szMsg[256];
		int nMsgType = 0;

		strcpy_safe(szMsg, pAI->cargv[1]);
		nMsgType = atoi(pAI->cargv[2]);


		MCommand* pCmd = CreateCommand(MC_ADMIN_ANNOUNCE, MUID(0,0));
		pCmd->AddParameter(new MCmdParamUID(MUID(0,0)));
		pCmd->AddParameter(new MCmdParamStr(szMsg));
		pCmd->AddParameter(new MCmdParamUInt(nMsgType));

		RouteToAllClient(pCmd);
	}
	else
	{
		sprintf_safe(szOut, maxlen, "%s: no such command", pAI->cargv[0]);
	}
	
	return true;
}
Пример #24
0
void ZRoomListBox::OnDraw( MDrawContext* pDC )
{
	MBitmap* pBitmap;
	MRECT		rect;
	map<string, MBitmap*>::iterator iter;
	map<MMATCH_GAMETYPE, MBitmap*>::iterator iterIcon;
	int pressed_reposition = 0;

 	int index = 0;
	
	for( int i = 0; i < NUM_DISPLAY_ROOM; ++i )
	{
		bool	bRoomFull = false;

		if( m_Selection == i )			pressed_reposition = 1; 
		else							pressed_reposition = 0;

		const char*	mapName = MGetBannerName( m_pMapInfo[i].map_name);
		if( m_pMapInfo[i].IsEmpty )
		{
			continue;
		}
		rect = GetInitialClientRect();
		
		int width  = (int)( m_iGapWidth + ( m_RoomWidth + m_iGapWidth*2 + m_iGapCenter ) * ( index%2 ) );
		int height = (int)( m_iGapHeight + ( m_RoomHeight + m_iGapHeight ) * (int)(index*0.5f));
 		
 		if( m_pMapInfo[i].nPeople >= m_pMapInfo[i].nMaxPeople )
		{
			bRoomFull = true;
		}
		
		iter = find_if( m_pMapImage.begin(), m_pMapImage.end(), string_key_equal<string, MBitmap*>(mapName));
		if( iter != m_pMapImage.end() )
		{
			pBitmap	= iter->second;
			if( pBitmap != 0 )
			{
				if( ( m_pMapInfo[i].roomState == GMAE_CLOSED ) || bRoomFull )	
 					pDC->SetBitmapColor(125,125,125,255);
				else					
 					pDC->SetBitmapColor(255,255,255,255);

				pDC->SetBitmap( pBitmap ); 
				pDC->Draw( width + pressed_reposition, height + pressed_reposition, m_RoomWidth, m_RoomHeight );
			}

			if(m_pRoomFrame!=0)
			{
				pDC->SetBitmap(m_pRoomFrame);
 				pDC->Draw(width + pressed_reposition, height + pressed_reposition, m_RoomWidth * 0.75, m_RoomHeight, 0, 0, 512, 32 );
			}
		}

		char szBuf[128];
		MRECT r;

 		r.x = width + m_RoomWidth*0.01f	+ pressed_reposition;
		r.y = height + m_RoomHeight*0.1f + pressed_reposition;
		r.w = m_RoomWidth*0.1;
		r.h = m_RoomHeight *0.5;
     	sprintf_safe(szBuf,"%03d", m_pMapInfo[i].RoomNumber);

		pDC->SetFont( MFontManager::Get("FONTc8b") );
		pDC->SetColor( 0,0,0);
		pDC->Text( MRECT( r.x+1, r.y+1, r.w, r.h), szBuf);
		if(  m_pMapInfo[i].roomState == GMAE_CLOSED || bRoomFull )
			pDC->SetColor( 115,146,173 );
		else
			pDC->SetColor( 181, 247, 66 );
		pDC->Text( r, szBuf );

		r.x = width + m_RoomWidth*0.01f + pressed_reposition;
		r.y = height + m_RoomHeight*0.5f + pressed_reposition;
		r.w = m_RoomWidth*0.1f;
		r.h = m_RoomHeight*0.5f;
		sprintf_safe(szBuf,"%d/%d", m_pMapInfo[i].nPeople, m_pMapInfo[i].nMaxPeople );

		pDC->SetColor( 0,0,0);
		pDC->Text( MRECT( r.x+1, r.y+1, r.w, r.h), szBuf);
		if(  m_pMapInfo[i].roomState == GMAE_CLOSED || bRoomFull )
			pDC->SetColor( 115,146,173 );
		else
			pDC->SetColor( 181, 247, 66 );
		pDC->Text( r, szBuf );

		pDC->SetFont( MFontManager::Get("FONTc8b") );
 		r.x = width + m_RoomWidth*0.12 + pressed_reposition;
 		r.y = height + pressed_reposition;
  		r.w = m_RoomWidth*0.75;
		r.h = m_RoomHeight;
 		
		MFont * pFont  = pDC->GetFont();
		char szBufTemp[SMI_MAPNAME_LENGTH];
		int strLength = 0;
		int RoomWidth = pFont->GetWidth(m_pMapInfo[i].room_name);
		if( RoomWidth > m_RoomWidth*0.7 )
		{
			while( strLength < 29 )
			{
				if( m_pMapInfo[i].map_name[strLength] == '0' )
					strcpy_safe( szBufTemp, m_pMapInfo[i].room_name );
				if( ((unsigned char)m_pMapInfo[i].room_name[strLength]) > 127 )
					strLength += 2;
				else
					++strLength;
			}
			strncpy_safe( szBufTemp, m_pMapInfo[i].room_name, strLength*sizeof(char) );
			szBufTemp[strLength] = '\0';
			strcat_safe( szBufTemp, "..."	);

			pDC->SetColor( 0,0,0);
			pDC->Text( MRECT( r.x+1, r.y+1, r.w, r.h), szBufTemp, MAM_LEFT);
			if(  m_pMapInfo[i].roomState == GMAE_CLOSED || bRoomFull )
				pDC->SetColor( 115,146,173 );
			else
				pDC->SetColor( 255, 255, 255 );
			pDC->Text(r, szBufTemp, MAM_LEFT );
		}
		else
		{
			pDC->SetColor( 0,0,0);
			pDC->Text( MRECT( r.x+1, r.y+1, r.w, r.h), m_pMapInfo[i].room_name, MAM_LEFT);
			if(  m_pMapInfo[i].roomState == GMAE_CLOSED || bRoomFull )
				pDC->SetColor( 115,146,173 );
			else
				pDC->SetColor( 255, 255, 255 );
			pDC->Text(r, m_pMapInfo[i].room_name, MAM_LEFT );
		}

		r.x = width + m_RoomWidth*0.75f + pressed_reposition;
		r.y = height + pressed_reposition;
		r.w = m_RoomWidth * 0.2f ;
		r.h = m_RoomHeight;

		if( m_pMapInfo[i].bLimitLevel )
		{
			char szBufTemp[64];
			sprintf_safe( szBufTemp, "%d~%d", max(m_pMapInfo[i].nMasterLevel - m_pMapInfo[i].nLimitLevel,1), m_pMapInfo[i].nMasterLevel + m_pMapInfo[i].nLimitLevel);

			pDC->SetColor( 0,0,0);
			pDC->Text( MRECT( r.x+1, r.y+1, r.w, r.h), szBufTemp);
			if( m_pMapInfo[i].roomState == GMAE_CLOSED || bRoomFull )
				pDC->SetColor( 100, 100, 100 );
			else
				pDC->SetColor( 181, 247, 66 );
			pDC->Text( r, szBufTemp );
		}
		
		if (m_pMapInfo[i].bPrivate)
		{
			// 비밀방이면 게임모드 아이콘대신 열쇠아이콘이 나온다.
			// 열쇠아이콘은 하드코드됨. 나중에 일반화해서 xml로 빼놔야할 듯..

			#define FN_ROOMLIST_PRIVATE_KEY		"in_key.png"
			pBitmap = MBitmapManager::Get(FN_ROOMLIST_PRIVATE_KEY);
			if (pBitmap != NULL) 
			{
				float x, y;
				x = width + m_RoomWidth*0.9 + pressed_reposition;
				y = height + pressed_reposition + ((m_RoomHeight-pBitmap->GetHeight())/2);
				pDC->SetBitmap( pBitmap );
				pDC->Draw(x, y, pBitmap->GetWidth(), pBitmap->GetHeight());
			}
		}
		else
		{
			iterIcon = m_pIconImage.find( m_pMapInfo[i].nGame_Type );
			if( iterIcon != m_pIconImage.end() )
			{
				pBitmap = iterIcon->second;
				if( pBitmap != 0)
				{
 					r.x = width + m_RoomWidth*0.9 + pressed_reposition;
					r.y = height + m_RoomHeight/4.7 + pressed_reposition;

					// 아이콘
					if( m_pMapInfo[i].roomState == GMAE_CLOSED || bRoomFull )
					{
						pDC->SetBitmapColor(100,100,100,100);
					}
					else
					{
  						pDC->SetBitmapColor(255,255,255,255);
					}

					pDC->SetBitmap( pBitmap );
					pDC->Draw(r.x, height + pressed_reposition, m_RoomHeight, m_RoomHeight);
				}			
			}
		}


		// 플레이 중이면 플레이 아이콘을 표시한다.
		if ( m_pMapInfo[i].roomState == GAME_PLAYING)
		{
			// 역시 플레이 아이콘도 하드코딩... -_-;
			#define FN_ROOMLIST_PLAYICON		"icon_play.tga"
			pBitmap = MBitmapManager::Get( FN_ROOMLIST_PLAYICON);
			if (pBitmap != NULL) 
			{
				float x, y;
				x = width  + (m_RoomWidth  * 0.955) + pressed_reposition;
				y = height + (m_RoomHeight * 0.54)  + pressed_reposition;
				pDC->SetBitmap( pBitmap );
				pDC->Draw(x, y, (m_RoomHeight * 0.5), (m_RoomHeight * 0.5));
			}
		}

		//왓구(테두리)
		if( i == m_Selection)
		{
			if( m_pMapInfo[i].roomState == GMAE_CLOSED || bRoomFull) pDC->SetColor(115,146,173);
			else pDC->SetColor( 181, 247, 66 );
		}
		else pDC->SetColor(128,128,128,255);
		pDC->Rectangle(width+pressed_reposition, height+pressed_reposition, m_RoomWidth, m_RoomHeight );

		++index;
	}
	pDC->SetOpacity( 255 );
	pDC->SetBitmapColor(255,255,255,255);
}
Пример #25
0
/* <40e38> ../engine/info.c:72 */
void Info_RemoveKey(char *s, const char *key)
{
	char pkey[MAX_KV_LEN];
	char value[MAX_KV_LEN];
	char *start;
	char *c;
	int cmpsize;
	int nCount;

	if (Q_strstr(key, "\\"))
	{
		Con_Printf("Can't use a key with a \\\n");
		return;
	}

	cmpsize = Q_strlen(key);
	if (cmpsize > MAX_KV_LEN - 1)
		cmpsize = MAX_KV_LEN - 1;

	while (*s)
	{
		start = s;

		if (*s == '\\')
		{
			s++;	// skip the slash
		}

		// Copy a key
		nCount = 0;
		c = pkey;
		while (*s != '\\')
		{
			if (!*s)
			{
				break;		// key should end with a \, not a NULL, but allow to remove it
			}
			if (nCount >= MAX_KV_LEN)
			{
				s++;
				continue;	// skip oversized key chars till the slash or EOL
			}
			*c++ = *s++;
			nCount++;
		}
		*c = 0;
		if (*s)
			s++;	// skip the slash

		// Copy a value
		nCount = 0;
		c = value;
		while (*s != '\\')
		{
			if (!*s)
			{
				break;		// allow value to be ended with NULL
			}
			if (nCount >= MAX_KV_LEN)
			{
				s++;
				continue;	// skip oversized value chars till the slash or EOL
			}
			*c++ = *s++;
			nCount++;
		}
		*c = 0;

		// Compare keys
		if (!Q_strncmp(key, pkey, cmpsize))
		{
			strcpy_safe(start, s);	// remove this part
			s = start;	// continue searching
		}
	}
}
Пример #26
0
/* <40ecf> ../engine/info.c:136 */
void Info_RemovePrefixedKeys(char *s, const char prefix)
{
	char pkey[MAX_KV_LEN];
	char value[MAX_KV_LEN];
	char *start;
	char *c;
	int nCount;

	while (*s)
	{
		start = s;

		if (*s == '\\')
		{
			s++;	// skip the slash
		}

		// Copy a key
		nCount = 0;
		c = pkey;
		while (*s != '\\')
		{
			if (!*s)
			{
				break;		// key should end with a \, not a NULL, but allow to remove it
			}
			if (nCount >= MAX_KV_LEN)
			{
				s++;
				continue;	// skip oversized key chars till the slash or EOL
			}
			*c++ = *s++;
			nCount++;
		}
		*c = 0;
		if (*s)
			s++;	// skip the slash

		// Copy a value
		nCount = 0;
		c = value;
		while (*s != '\\')
		{
			if (!*s)
			{
				break;		// allow value to be ended with NULL
			}
			if (nCount >= MAX_KV_LEN)
			{
				s++;
				continue;	// skip oversized value chars till the slash or EOL
			}
			*c++ = *s++;
			nCount++;
		}
		*c = 0;

		if (pkey[0] == prefix)
		{
			strcpy_safe(start, s);	// remove this part
			s = start;	// continue searching
		}
	}
}
Пример #27
0
void MQuestScenarioCatalogue::ParseStandardScenario(MXmlElement& element)
{
	char szTemp[256]="";
	int n = 0;
	char szAttrValue[256];
	char szAttrName[64];
	char szTagName[128];

	MQuestScenarioInfo* pScenarioInfo = new MQuestScenarioInfo();
	pScenarioInfo->bSpecialScenario = false;

	int nAttrCount = element.GetAttributeCount();
	for (int i = 0; i < nAttrCount; i++)
	{
		element.GetAttribute(i, szAttrName, szAttrValue);
		if (!_stricmp(szAttrName, MTOK_SCENARIO_TITLE))
		{
			strcpy_safe(pScenarioInfo->szTitle, szAttrValue);
		}
		else if (!_stricmp(szAttrName, MTOK_SCENARIO_QL))
		{
			pScenarioInfo->nQL = atoi(szAttrValue);
		}
		else if (!_stricmp(szAttrName, MTOK_SCENARIO_DC))
		{
			pScenarioInfo->fDC = (float)atof(szAttrValue);
		}
		else if (!_stricmp(szAttrName, MTOK_SCENARIO_MAPSET))
		{
			pScenarioInfo->nMapSet = QuestMapNameToID(szAttrValue);
		}
		else if (!_stricmp(szAttrName, MTOK_SCENARIO_XP))
		{
			pScenarioInfo->nXPReward = atoi(szAttrValue);
		}
		else if (!_stricmp(szAttrName, MTOK_SCENARIO_BP))
		{
			pScenarioInfo->nBPReward = atoi(szAttrValue);
		}
		else if (!_stricmp(szAttrName, MTOK_SCENARIO_SECTOR_XP))
		{
			pScenarioInfo->nSectorXP = atoi(szAttrValue);
		}
		else if (!_stricmp(szAttrName, MTOK_SCENARIO_SECTOR_BP))
		{
			pScenarioInfo->nSectorBP = atoi(szAttrValue);
		}
	}

	int iChildCount = element.GetChildNodeCount();

	MXmlElement chrElement;
	for (int i = 0; i < iChildCount; i++)
	{
		chrElement = element.GetChildNode(i);
		chrElement.GetTagName(szTagName);
		if (szTagName[0] == '#') continue;

		if (!_stricmp(szTagName, MTOK_SCENARIO_SACRI_ITEM))
		{
			ParseSacriItem(chrElement, pScenarioInfo);
		}
		else if (!_stricmp(szTagName, MTOK_SCENARIO_REWARD_ITEM))
		{
			ParseRewardItem(chrElement, pScenarioInfo);
		}
		else if (!_stricmp(szTagName, MTOK_SCENARIO_MAP))
		{
			ParseMap(chrElement, pScenarioInfo);
		}

	}

	pScenarioInfo->nID = CalcStandardScenarioID(pScenarioInfo->nMapSet, pScenarioInfo->nQL);
	Insert(pScenarioInfo);
}
Пример #28
0
void MCommandProfiler::PrintCmdItems(FILE* fp)
{
	// send: 개수(비율), byte(비율), byte/sec

	fputs("----------------------------------------------------------------------------------------------------------------------------------------\n", fp);
	fputs("  ID     |  Size ||  구분  ||   Count(Rate)  |  Count/Sec  |  Bytes/Sec(Rate)  |  AvgTime(Rate)  |  MinTime  |  MaxTime  |  설명\n", fp);
	fputs("----------------------------------------------------------------------------------------------------------------------------------------\n", fp);

	// 측정시간(초)
	unsigned int nTotalTimeSec = (unsigned int)(floor((m_nLastTime - m_nFirstTime) / 1000.0f));
	if (nTotalTimeSec == 0) nTotalTimeSec=1;

	char text[512];
	for (int i = 0; i < MAX_COMMANDPROFILER_CMD_COUNT; i++)
	{
		if ((m_Items[i].nSendCount <= 0) && (m_Items[i].nRecvCount <= 0)) continue;

		int nID = i;
		char szDesc[256] = "";
		if (m_pCM)
		{
			MCommandDesc* pDesc = m_pCM->GetCommandDescByID(i);
			if (pDesc)
				strcpy_safe(szDesc, pDesc->GetName());
		}
		
		int nAvgSize = (m_Items[i].nSendBytes + m_Items[i].nRecvBytes) / (m_Items[i].nSendCount + m_Items[i].nRecvCount);


		float fSendCountRate=0.0f, fRecvCountRate=0.0f;
		float fSendBytesRate=0.0f, fRecvBytesRate=0.0f;

		// Count Rate
		if (m_nTotalSendCmdCount != 0)
			fSendCountRate = (m_Items[i].nSendCount / (float)m_nTotalSendCmdCount) * 100.0f;
		if (m_nTotalRecvCmdCount != 0)
			fRecvCountRate = (m_Items[i].nRecvCount / (float)m_nTotalRecvCmdCount) * 100.0f;

		// Count/Sec
		float fSendCountPerSec=0.0f, fRecvCountPerSec=0.0f;
		fSendCountPerSec = m_Items[i].nSendCount / (float)nTotalTimeSec;
		fRecvCountPerSec = m_Items[i].nRecvCount / (float)nTotalTimeSec;

		// Bytes/Sec
		float fSendBytesPerSec=0.0f, fRecvBytesPerSec=0.0f;
		fSendBytesPerSec = m_Items[i].nSendBytes / (float)nTotalTimeSec;
		fRecvBytesPerSec = m_Items[i].nRecvBytes / (float)nTotalTimeSec;

		// Bytes Rate
		if (m_nTotalSendBytes != 0)
			fSendBytesRate = (m_Items[i].nSendBytes / (float)m_nTotalSendBytes) * 100.0f;
		if (m_nTotalRecvBytes != 0)
			fRecvBytesRate = (m_Items[i].nRecvBytes / (float)m_nTotalRecvBytes) * 100.0f;


		unsigned int nAvgTime = 0;
		unsigned int nMinTime = 0;
		unsigned int nMaxTime = 0;
		unsigned int nTotalTime = 0;
		float fTimeRate = 0.0f;

		if (m_Items[i].nRecvCount != 0)
			nAvgTime = m_Items[i].nTotalTime / m_Items[i].nRecvCount;
		nMinTime = m_Items[i].nMinTime;
		nMaxTime = m_Items[i].nMaxTime;

		nTotalTime = m_Items[i].nTotalTime / 1000;

		if (m_nTotalOnProcessTime != 0)
			fTimeRate = (m_Items[i].nTotalTime / (float)(m_nTotalOnProcessTime)) * 100.0f;


		if (m_Items[i].nSendCount != 0)
		{
			sprintf_safe(text, "  %5d  |  %3d  ||  Send  || %6d(%4.1f%%)  |     %4.1f    |    %6.1f(%4.1f%%)  |                 |           |           |  %s\n",
				nID, 
				nAvgSize, 
				m_Items[i].nSendCount, 
				fSendCountRate, 
				fSendCountPerSec,
				fSendBytesPerSec, 
				fSendBytesRate, 
				szDesc);
		}
		else
		{
			sprintf_safe(text, "  %5d  |  %3d  ||   --   ||      -         |       -     |         -         |        -        |       -   |       -   |  %s\n",
				nID, 
				nAvgSize,
				szDesc);
		}
		fputs(text, fp);

		if (m_Items[i].nRecvCount != 0)
		{
			sprintf_safe(text, "\t\t ||  Recv  || %6d(%4.1f%%)  |     %4.1f    |    %6.1f(%4.1f%%)  |   %6u(%4.1f%%) |  %6u   |  %6u   |\n",
				m_Items[i].nRecvCount, 
				fRecvCountRate, 
				fRecvCountPerSec,
				fRecvBytesPerSec, 
				fRecvBytesRate,
				nAvgTime, 
				fTimeRate, 
				nMinTime, 
				nMaxTime);
		}
		else
		{
			sprintf_safe(text, "\t\t ||   --   ||      -         |       -     |         -         |        -        |       -   |       -   |    \n");
		}
		fputs(text, fp);
		fputs("----------------------------------------------------------------------------------------------------------------------------------------\n", fp);
	}

}
bool interface_keyPressed(unsigned char key, int x, int y)
{ // Returns true if the event was intercepted by the interface
	uint pos;
	uint len;

	if (!renameString)
		return false;

	if (!_curObject)
		return false;

	len = strlen(*renameString);
	pos = len;//renameStringCursor;

	if (key == 8)
	{ // Backspace
		if (len > 0)
		{
			(*renameString)[pos-1] = '\0';
			*renameString = (char*)mem_realloc(*renameString, sizeof(char)*(pos));
		}
	}
	else if (key == 13)
	{ // Enter
		if (len > 0)
		{
			if (_curObject->gen_component.type == COMP_TEXTFIELD)
			{
				textField_t *field = _curObject->gen_component.object.textField;
				updateFieldValue(field);
				_dropFocus();
				if (field->onDeselected) field->onDeselected(false);
			}
			else if (_curObject->gen_component.type == COMP_LIST)
			{
				list_t *list = _curObject->gen_component.object.list;
				int index = list->selectIndex;
				strcpy_safe(list->entries[index].dynValue ? *list->entries[index].dynValue : list->entries[index].value, *renameString);
				_dropFocus();
				list->onSelect(index); // Update it	
			}
		}
	}
	else if (key == 27)
	{ // Escape
		if (_curObject->gen_component.type == COMP_TEXTFIELD)
		{
			textField_t *field = _curObject->gen_component.object.textField;
			_dropFocus();
			if (field->onDeselected) field->onDeselected(true);
		}
		else
		{
			_dropFocus();
		}
	}
	else
	{ // Normal input
		if (_curObject->gen_component.type == COMP_TEXTFIELD && _curObject->gen_component.object.textField->type != FIELDTYPE_TEXT)
		{ // Apply rules to select what we can type
			textField_t *field = _curObject->gen_component.object.textField;
			if (field->type == FIELDTYPE_BINARY)
			{ // Only two choices here really
				if (key != '0' && key != '1')
				{
					return true;
				}
			}
			else
			{
				if (key < '0' || key > '9')
				{
					if (key == '.' && field->type != FIELDTYPE_FLOAT)
					{
						return true;
					}
				}

				if ((field->max > 0 && pos >= nbDigits(field->max)) || pos >= 8)
				{
					return true;
				}
			}
		}
		else
		{ // Take most things
			if ((key < 'a' || key > 'z') &&
				(key < 'A' || key > 'Z') &&
				(key < '0' || key > '9') &&
				!_isAcceptedSpecialChar(key) &&
				((key != ' ') || pos == 0)) // Can't start with a space
			{
				return true;
			}

			if (pos >= 15)
			{
				return true;
			}
		}
		
		*renameString = (char*)mem_realloc(*renameString, sizeof(char)*(pos+2));
		(*renameString)[pos] = key;
		(*renameString)[pos+1] = '\0';
	}

	return true;
}
Пример #30
0
bool file_utils::split_path(const char *p, dynamic_string *pDrive, dynamic_string *pDir, dynamic_string *pFilename, dynamic_string *pExt)
{
    VOGL_ASSERT(p);

#if defined(PLATFORM_WINDOWS)
    char drive_buf[_MAX_DRIVE];
    char dir_buf[_MAX_DIR];
    char fname_buf[_MAX_FNAME];
    char ext_buf[_MAX_EXT];

#if defined(COMPILER_MSVC)
    // Compiling with MSVC
    errno_t error = _splitpath_s(p,
                                 pDrive ? drive_buf : NULL, pDrive ? _MAX_DRIVE : 0,
                                 pDir ? dir_buf : NULL, pDir ? _MAX_DIR : 0,
                                 pFilename ? fname_buf : NULL, pFilename ? _MAX_FNAME : 0,
                                 pExt ? ext_buf : NULL, pExt ? _MAX_EXT : 0);
    if (error != 0)
        return false;
#elif defined(COMPILER_MINGW)
    // Compiling with MinGW
    _splitpath(p,
               pDrive ? drive_buf : NULL,
               pDir ? dir_buf : NULL,
               pFilename ? fname_buf : NULL,
               pExt ? ext_buf : NULL);
#else
#error "Need to provide splitpath functionality for this compiler / platform combo."
#endif

    if (pDrive)
        *pDrive = drive_buf;
    if (pDir)
        *pDir = dir_buf;
    if (pFilename)
        *pFilename = fname_buf;
    if (pExt)
        *pExt = ext_buf;
#else // !PLATFORM_WINDOWS
    char dirtmp[1024];
    char nametmp[1024];
    strcpy_safe(dirtmp, sizeof(dirtmp), p);
    strcpy_safe(nametmp, sizeof(nametmp), p);

    if (pDrive)
        pDrive->clear();

    const char *pDirName = dirname(dirtmp);
    if (!pDirName)
        return false;

    if (pDir)
    {
        pDir->set(pDirName);
        if ((!pDir->is_empty()) && (pDir->back() != '/'))
            pDir->append_char('/');
    }

    const char *pBaseName = basename(nametmp);
    if (!pBaseName)
        return false;

    if (pFilename)
    {
        pFilename->set(pBaseName);
        remove_extension(*pFilename);
    }

    if (pExt)
    {
        pExt->set(pBaseName);
        get_extension(*pExt);
        if (pExt->get_len())
            *pExt = "." + *pExt;
    }
#endif // #if defined(PLATFORM_WINDOWS)

    return true;
}