示例#1
0
int CJewelMixSystem::GetJewelCountPerLevel(int iJewelType, int iJewelLevel)
{
	if ( !CHECK_LIMIT(iJewelLevel, 3) )
		return -1;

	if ( !CHECK_LIMIT(iJewelType, 10) )
		return -1;

	return g_JewelMixInfo[iJewelType][iJewelLevel].m_iJewelCount;
}
示例#2
0
int scheme_generate_alloc_retry(mz_jit_state *jitter, int i)
{
  GC_CAN_IGNORE jit_insn *refr;

#ifdef JIT_USE_FP_OPS
  if (i == 2) {
    (void)mz_tl_sti_d_fppop(tl_scheme_jit_save_fp, JIT_FPR1, JIT_R2);
  }
#endif
  JIT_UPDATE_THREAD_RSPTR();
  jit_prepare(2);
  CHECK_LIMIT();
  if (i == 1) {
    jit_pusharg_p(JIT_R1);
    jit_pusharg_p(JIT_R0);
  } else {
    (void)jit_movi_p(JIT_R0, NULL);
    jit_pusharg_p(JIT_R0);
    jit_pusharg_p(JIT_R0);
  }
  (void)mz_finish_lwe(ts_prepare_retry_alloc, refr);
  jit_retval(JIT_R0);
  if (i == 1) {
    mz_tl_ldi_l(JIT_R1, tl_retry_alloc_r1);
  }
#ifdef JIT_USE_FP_OPS
  if (i == 2) {
    (void)mz_tl_ldi_d_fppush(JIT_FPR1, tl_scheme_jit_save_fp, JIT_R2);
  }
#endif
  return 1;
}
BYTE CIllusionTempleEvent::IncSkillPoint(int nIndex, BYTE btMapNumber, BYTE btObjectType)
{
if( OBJMAX_RANGE(nIndex) == FALSE )
	{
		return FALSE;
	}

	if( CHECK_LIMIT( (btMapNumber - 45), MAX_ILLUSIONTEMPLE_TEMPLE_COUNT) == FALSE )
	{
		return FALSE;
	}

	BYTE btPoint = 0;

	if(btObjectType == 1)
	{
		this->m_cIllusionTempleProc[btMapNumber - 45].IncUserKillCount(nIndex);
		btPoint = 5;
	}
	else
	{
		this->m_cIllusionTempleProc[btMapNumber - 45].IncMonsterKillCount(nIndex);
		btPoint = 2;
	}

	return this->m_cIllusionTempleProc[btMapNumber - 45].IncSkillPoint(nIndex, btPoint);
}
BOOL CIllusionTempleEvent::LeaveIllusionTemple(int aIndex, BYTE btMapNumber)
{
	if(!CHECK_LIMIT((btMapNumber-MAP_INDEX_ILLUSION_TEMPLE1), MAX_ILLUSIONTEMPLE_TEMPLE_COUNT)) return FALSE;

	m_cIllusionTempleProc[btMapNumber-MAP_INDEX_ILLUSION_TEMPLE1].LeaveUserIllusionTemple(aIndex);
	SendIllusionTempleUserCount();	
	return TRUE;
}
示例#5
0
void CCrywolf::SetState_END()
{
	this->m_dwCrywolfStartProcTick = 0;
	this->m_bChangeAI = FALSE;

	LogAddC(4, "[ Crywolf ] State (%d) -> END", this->m_iCrywolfState);

	if ( this->m_bTurnUpBoss != FALSE && CHECK_LIMIT(this->m_iBossIndex, OBJ_MAXMONSTER) )
	{
		if ( gObj[this->m_iBossIndex].Live != FALSE )
		{
			UTIL.SendCrywolfUserAnyMsg(2, lMsg.Get(MSGGET(12, 233)));
			this->SetOccupationState(1);
		}
	}

	this->m_bTurnUpBoss = FALSE;
	this->SetCrywolfBossIndex(-1);

	if ( this->GetOccupationState() == 1 )
	{
		UTIL.SendMapServerGroupMsg(lMsg.Get(MSGGET(12, 234)));
		this->SetOccupationState(1);

		LogAddTD("[ Crywolf ][MVP] FAIL.......!!");
	}
	else
	{
		UTIL.SendMapServerGroupMsg(lMsg.Get(MSGGET(12, 235)));
		this->SetOccupationState(0);

		LogAddTD("[ Crywolf ][MVP] SUCCESS.......!!");
	}

	this->SetCrywolfState(CRYWOLF_STATE_END);
	this->SetCrywolfStateAppliedTime(CRYWOLF_STATE_END);
	this->NotifyCrywolfCurrentState();
	this->ChangeAI(0);
	
	for ( int iAltar = 205 ; iAltar <= 209 ; iAltar++)
	{
		int iUserIndex = g_CrywolfNPC_Altar.GetAltarUserIndex(iAltar);

		if ( iUserIndex != -1 )
		{
			this->CalcGettingScore(iUserIndex, -1, 6);

			if ( this->GetOccupationState() != 1 )
			{
				this->MakeRewardForAltarElf(iUserIndex);
			}
		}
	}

	g_CrywolfNPC_Altar.ResetAllAltar();
	this->NotifyCrywolfPersonalRank();
}
示例#6
0
void CCrywolf::SetState_END()
{
	this->m_dwCrywolfStartProcTick = 0;
	this->m_bChangeAI = FALSE;

	LogAdd( "[ Crywolf ] State (%d) -> END", this->m_iCrywolfState);

	if ( this->m_bTurnUpBoss != FALSE && CHECK_LIMIT(this->m_iBossIndex, OBJ_MAXMONSTER) )
	{
		if ( gObj[this->m_iBossIndex].Live != FALSE )
		{
			UTIL.SendCrywolfUserAnyMsg(2, "Balgass will be alive till the end of the battle");
			this->SetOccupationState(1);
		}
	}

	this->m_bTurnUpBoss = FALSE;
	this->SetCrywolfBossIndex(-1);

	if ( this->GetOccupationState() == 1 )
	{
		UTIL.SendMapServerGroupMsg("Defending has failed! The statue of holy wolf has been taken over by Balgass");
		this->SetOccupationState(1);

		LogAdd("[ Crywolf ][MVP] FAIL.......!!");
	}
	else
	{
		UTIL.SendMapServerGroupMsg("Defending has been successful! The statue of holy wolf has been protected.");
		this->SetOccupationState(0);

		LogAdd("[ Crywolf ][MVP] SUCCESS.......!!");
	}

	this->SetCrywolfState(CRYWOLF_STATE_END);
	this->SetCrywolfStateAppliedTime(CRYWOLF_STATE_END);
	this->NotifyCrywolfCurrentState();
	this->ChangeAI(0);
	
	for ( int iAltar = 205 ; iAltar <= 209 ; iAltar++)
	{
		int iUserIndex = g_CrywolfNPC_Altar.GetAltarUserIndex(iAltar);

		if ( iUserIndex != -1 )
		{
			this->CalcGettingScore(iUserIndex, -1, 6);

			if ( this->GetOccupationState() != 1 )
			{
				this->MakeRewardForAltarElf(iUserIndex);
			}
		}
	}

	g_CrywolfNPC_Altar.ResetAllAltar();
	this->NotifyCrywolfPersonalRank();
}
示例#7
0
int gObjDel(int index)
{
    if( !CHECK_LIMIT( index, MAX_CONNECTOBJECT ) )
    {
        printf("Error : index error %s %d",__FILE__, __LINE__);
        return FALSE;
    }

    gObj[index].Connected = 0;

    return TRUE;
}
示例#8
0
void CCrywolf::ProcState_START()
{
	if ( g_CrywolfNPC_Altar.GetContractedAltarCount() == 0 )
	{
		UTIL.SendCrywolfUserAnyMsg(2, lMsg.Get(MSGGET(12, 240)));

		this->SetOccupationState(1);
		this->SetState(CRYWOLF_STATE_END);

		return;
	}

	this->NotifyCrywolfStatueAndAltarInfo();
	this->NotifyCrywolfBossMonsterInfo();
	this->NotifyCrywolfStateLeftTime();

	// VERIFICAR
	if ( (int)(GetTickCount() - this->m_dwCrywolfStartProcTick) > (this->m_iBossTurnUpTime * 1000) &&
		 !this->m_bTurnUpBoss )
	{
		this->m_bTurnUpBoss = TRUE;
		
		UTIL.SendCrywolfUserAnyMsg(2, lMsg.Get(MSGGET(12, 241)));

		this->TurnUpBoss();
		
		LogAddTD("[ Crywolf ][MVP] Barlgars TurnUp !!!");
	}

	// VERIFICAR
	if ( (int)(GetTickCount() - this->m_dwCrywolfStartProcTick) > (this->m_iMonsterGroupChangeAITime * 1000) &&
		 !this->m_bChangeAI )
	{
		this->m_bChangeAI = TRUE;
		
		UTIL.SendCrywolfUserAnyMsg(2, lMsg.Get(MSGGET(12, 242)));

		this->ChangeAI(2);
		
		LogAddTD("[ Crywolf ][MVP] Start Monster Rush !!!");
	}

	if ( this->m_bTurnUpBoss != FALSE && CHECK_LIMIT(this->m_iBossIndex, OBJ_MAXMONSTER) != FALSE )
	{
		if ( gObj[this->m_iBossIndex].Live == FALSE )
		{
			UTIL.SendCrywolfUserAnyMsg(2, lMsg.Get(MSGGET(12, 243)));	

			this->SetOccupationState(0);
			this->SetState(CRYWOLF_STATE_END);
		}
	}
}
示例#9
0
void CCrywolf::ProcState_START()
{
	if ( g_CrywolfNPC_Altar.GetContractedAltarCount() == 0 )
	{
		UTIL.SendCrywolfUserAnyMsg(2, "Without the protection of the Muses, the statue of holy wolf will be stolen");

		this->SetOccupationState(1);
		this->SetState(CRYWOLF_STATE_END);

		return;
	}

	this->NotifyCrywolfStatueAndAltarInfo();
	this->NotifyCrywolfBossMonsterInfo();
	this->NotifyCrywolfStateLeftTime();

	if ( int(GetTickCount() - this->m_dwCrywolfStartProcTick) > (this->m_iBossTurnUpTime * 1000) &&
		 !this->m_bTurnUpBoss )
	{
		this->m_bTurnUpBoss = TRUE;
		
		UTIL.SendCrywolfUserAnyMsg(2, "Balgass is coming! Protect the statue of holy wolf");

		this->TurnUpBoss();
		
		LogAdd("[ Crywolf ][MVP] Balgass TurnUp !!!");
	}

	if ( int(GetTickCount() - this->m_dwCrywolfStartProcTick) > (this->m_iMonsterGroupChangeAITime * 1000) &&
		 !this->m_bChangeAI )
	{
		this->m_bChangeAI = TRUE;
		
		UTIL.SendCrywolfUserAnyMsg(2, "Balgass's army starts attacking the statue of holy wolf");

		this->ChangeAI(2);
		
		LogAdd("[ Crywolf ][MVP] Start Monster Rush !!!");
	}

	if ( this->m_bTurnUpBoss != FALSE && CHECK_LIMIT(this->m_iBossIndex, OBJ_MAXMONSTER) != FALSE )
	{
		if ( gObj[this->m_iBossIndex].Live == FALSE )
		{
			UTIL.SendCrywolfUserAnyMsg(2, "Balgass has been defeated with the help of heroes");	

			this->SetOccupationState(0);
			this->SetState(CRYWOLF_STATE_END);
		}
	}
}
示例#10
0
void CCrywolf::SetState_START()
{
	UTIL.SendMapServerGroupMsg(lMsg.Get(MSGGET(12, 231)));
	LogAddC(4, "[ Crywolf ] State (%d) -> START", this->m_iCrywolfState);

	this->SetCrywolfState(CRYWOLF_STATE_START);
	this->SetCrywolfStateAppliedTime(CRYWOLF_STATE_START);

	if ( g_CrywolfNPC_Altar.GetContractedAltarCount() == 0 )
	{
		UTIL.SendCrywolfUserAnyMsg(2, lMsg.Get(MSGGET(12, 232)));
		this->SetOccupationState(1);
		this->SetState(CRYWOLF_STATE_END);

		return;
	}

	for ( int n=0;n<this->m_iMonsterGroupNumberCount;n++)
	{
		int iLeaderIndex = TMonsterAIGroup::FindGroupLeader(this->m_iMonsterGroupNumberArray[n]);

		if ( !CHECK_LIMIT(iLeaderIndex, OBJ_MAXMONSTER) )
			continue;

		if ( gObj[iLeaderIndex].Class != 340 )
			continue;

		LPOBJ lpObj = &gObj[iLeaderIndex];

		for ( int i=0;i<MAX_VIEWPORT_MONSTER;i++)
		{
			if ( lpObj->VpPlayer2[i].state )
			{
				int number = lpObj->VpPlayer2[i].number;

				if ( OBJMAX_RANGE(number) != FALSE )
				{
					if ( gObj[number].Type == OBJ_USER )
					{
						gObjBackSpring2(&gObj[number], lpObj, 3);
					}
				}
			}
		}
	}

	this->ChangeAI(1);
	this->m_dwCrywolfStartProcTick = GetTickCount();
	this->m_bTurnUpBoss = FALSE;
	this->m_bChangeAI = FALSE;
}
示例#11
0
void CCrywolf::SetState_START()
{
	UTIL.SendMapServerGroupMsg("The army of Balgass is marching towards Crywolf Fortress");
	LogAdd( "[ Crywolf ] State (%d) -> START", this->m_iCrywolfState);

	this->SetCrywolfState(CRYWOLF_STATE_START);
	this->SetCrywolfStateAppliedTime(CRYWOLF_STATE_START);

	if ( g_CrywolfNPC_Altar.GetContractedAltarCount() == 0 )
	{
		UTIL.SendCrywolfUserAnyMsg(2, "Without the protection of the Muses, the statue of holy wolf will be stolen");
		this->SetOccupationState(1);
		this->SetState(CRYWOLF_STATE_END);

		return;
	}

	for ( int n=0;n<this->m_iMonsterGroupNumberCount;n++)
	{
		int iLeaderIndex = TMonsterAIGroup::FindGroupLeader(this->m_iMonsterGroupNumberArray[n]);

		if ( !CHECK_LIMIT(iLeaderIndex, OBJ_MAXMONSTER) )
			continue;

		if ( gObj[iLeaderIndex].Class != 340 )
			continue;

		LPOBJ lpObj = &gObj[iLeaderIndex];

		for ( int i=0;i<MAX_VIEWPORT_MONSTER;i++)
		{
			if ( lpObj->VpPlayer2[i].state )
			{
				int number = lpObj->VpPlayer2[i].number;

				if ( OBJMAX_RANGE(number) != FALSE )
				{
					if ( gObj[number].Type == OBJ_USER )
					{
						gObjBackSpring2(&gObj[number], lpObj, 3);
					}
				}
			}
		}
	}

	this->ChangeAI(1);
	this->m_dwCrywolfStartProcTick = GetTickCount();
	this->m_bTurnUpBoss = FALSE;
	this->m_bChangeAI = FALSE;
}
BYTE CIllusionTempleEvent::DecSkillPoint(int nIndex, BYTE btMapNumber, BYTE btDecPoint)
{
	if( OBJMAX_RANGE(nIndex) == FALSE )
	{
		return FALSE;
	}

	if( CHECK_LIMIT( (btMapNumber - 45), MAX_ILLUSIONTEMPLE_TEMPLE_COUNT) == FALSE )
	{
		return FALSE;
	}

	return this->m_cIllusionTempleProc[btMapNumber - 45].DecSkillPoint(nIndex, btDecPoint);
}
示例#13
0
int CCrywolf::CalcGettingRewardExp(int iUserIndex, int iMVPRank)
{
	if ( !gObjIsConnected(iUserIndex))
		return 0;

	if ( CHECK_LIMIT(iMVPRank, 5) == FALSE )
		return 0;

	int iRewardExp = this->m_iMVPRankExpTable[iMVPRank];

	if ( this->GetOccupationState() == 1 )
	{
		iRewardExp = (iRewardExp * 10) / 100;
	}

	return iRewardExp;
}
示例#14
0
int CCrywolf::CalcGettingScore(int iUserIndex, int iMonIndex, int iScoreType)
{
	if ( !gObjIsConnected(iUserIndex))
		return -1;

	int iAddMVPScore = 0;

	if ( CHECK_LIMIT(iMonIndex, OBJ_MAXMONSTER) != FALSE )
	{
		switch ( gObj[iMonIndex].Class )
		{
			case 349:
				iAddMVPScore = this->m_iMVPScoreTable[0];
				break;
			case 340:
				iAddMVPScore = this->m_iMVPScoreTable[1];
				break;
			case 344:
				iAddMVPScore = this->m_iMVPScoreTable[2];
				break;
			case 341:
				iAddMVPScore = this->m_iMVPScoreTable[3];
				break;
			case 345:
				iAddMVPScore = this->m_iMVPScoreTable[4];
				break;
			case 348:
				iAddMVPScore = this->m_iMVPScoreTable[5];
				break;
		}
	}

	if ( iScoreType == 6 )
	{
		iAddMVPScore = this->m_iMVPScoreTable[6];
	}

	gObj[iUserIndex].m_iCrywolfMVPScore += iAddMVPScore;

	LogAdd("[ Crywolf ][MVP] Plus MVP Score : %d, Accumulated : %d [%s][%s]",
		iAddMVPScore, gObj[iUserIndex].m_iCrywolfMVPScore,
		gObj[iUserIndex].AccountID, gObj[iUserIndex].Name);

	return gObj[iUserIndex].m_iCrywolfMVPScore;
}
示例#15
0
int CJewelMixSystem::GetJewelCountPerLevel(int iJewelType, int iJewelLevel)
{
	if ( !CHECK_LIMIT(iJewelLevel, 3) )
		return -1;

	int iJewelCount = 0;

	switch ( iJewelType )
	{
		case 0:
			iJewelCount = g_JewelMixInfo[0][iJewelLevel].m_iJewelCount;
			break;
		case 1:
			iJewelCount = g_JewelMixInfo[1][iJewelLevel].m_iJewelCount;
			break;
		default:
			return -1;
	}

	return iJewelCount;
}
BOOL CMapServerManager::LoadMapData(char* lpszFileName)
{
	if ( (lpszFileName == NULL) || ( strcmp(lpszFileName, "")== 0 ) ) 
	{
		//MsgBox("[MapServerMng] file load error - File Name Error");
		return FALSE;
	}

	EnterCriticalSection(&m_critSVRCODE_MAP);

	m_bMapDataLoadOk = FALSE;

	for ( int iGROUP_COUNT=0;iGROUP_COUNT<20;iGROUP_COUNT++)
	{
		m_iMAPSVR_GROUP_COUNT[iGROUP_COUNT] = 0;

		for ( int iSUB_GROUP_COUNT=0;iSUB_GROUP_COUNT<20;iSUB_GROUP_COUNT++)
		{
			m_MAPSVR_DATA[iGROUP_COUNT][iSUB_GROUP_COUNT].Clear(1);
		}
	}

	m_mapSVRCODE_MAP.clear();

	SMDFile = fopen(lpszFileName, "r");

	if ( SMDFile == NULL )
	{
		//MsgBox("[MapServerMng] file load error - fopen() : %s",	lpszFileName);
		return FALSE;
	}

	int type = -1;

	SMDToken Token;

	while ( true )
	{
		Token = GetToken();

		if ( Token == END )	break;

		type = TokenNumber;

		while ( true )
		{
			if ( type == 0 )
			{
				short sSVR_CODE = -1;
				short sMAPSVR_GROUP = -1;
				int iInitSetVal = 1;
				char szIpAddr[16]={0};
				WORD wPortNum = 0;
				
				Token = GetToken();

				if (strcmp("end", TokenString) == 0) break;

				sSVR_CODE = TokenNumber;

				Token = GetToken();
				sMAPSVR_GROUP = TokenNumber;

				Token = GetToken();
				iInitSetVal = TokenNumber;

				Token = GetToken();
				memcpy(szIpAddr, &TokenString[1], 16);
				szIpAddr[15] =0;

				Token = GetToken();
				wPortNum = TokenNumber;

				if ( sSVR_CODE < 0 )
				{
					//MsgBox("[MapServerMng] file load error - sSVR_CODE < 0 (SVR:%d) - 1",
//						sSVR_CODE);
					return FALSE;
				}

				if ( iInitSetVal != -1 && iInitSetVal != 0 && iInitSetVal != 1 )
				{
					//MsgBox("[MapServerMng] file load error - iInitSetting Value:%d (SVR:%d) - 1",
	//					iInitSetVal, sSVR_CODE);
					return FALSE;
				}

				if ( !strcmp(szIpAddr, ""))
				{
					//MsgBox("[MapServerMng] file load error - No IpAddress (SVR:%d)",
		//				sSVR_CODE);
					return FALSE;
				}

				if ( CHECK_LIMIT(sMAPSVR_GROUP, 20) == FALSE )
				{
					//MsgBox("[MapServerMng] file load error - Map Server Group Index (IDX:%d)",
				//		sMAPSVR_GROUP);
					return FALSE;
				}

				if ( m_iMAPSVR_GROUP_COUNT[sMAPSVR_GROUP] >= 20 )
				{
					//MsgBox("[MapServerMng] file load error - No Space to Save SvrInfo (SVR:%d)",
					//	sSVR_CODE);
					return FALSE;
				}

				_MAPSVR_DATA * lpMapSvrData = NULL;

				lpMapSvrData= &m_MAPSVR_DATA[sMAPSVR_GROUP][m_iMAPSVR_GROUP_COUNT[sMAPSVR_GROUP]];

				lpMapSvrData->Clear(iInitSetVal);
				lpMapSvrData->m_bIN_USE = TRUE;
				lpMapSvrData->m_sSVR_CODE = sSVR_CODE;
				lpMapSvrData->m_btMAPSVR_GROUP = sMAPSVR_GROUP;
				lpMapSvrData->m_wPORT = wPortNum;

				memcpy(lpMapSvrData->m_cIPADDR, szIpAddr, 16);
				lpMapSvrData->m_cIPADDR[15] = 0;
				
				//#fix-me
				m_mapSVRCODE_MAP.insert(std::pair<int,_MAPSVR_DATA *>(sSVR_CODE, lpMapSvrData));

				m_iMAPSVR_GROUP_COUNT[sMAPSVR_GROUP]++;
			}
			else if ( type == 1 )
			{
				short sSVR_CODE = -1;
				BYTE btNotMoveOption = 0;
				WORD wMapNum = 0;
				short sDEST_SVR_CODE = -1;

				_MAPSVR_DATA * lpMapSvrData = NULL;

				Token = GetToken();

				if ( strcmp("end", TokenString) == 0) break;

				sSVR_CODE = TokenNumber;

				Token = GetToken();
				btNotMoveOption = TokenNumber;

				Token = GetToken();
				wMapNum = TokenNumber;

				Token = GetToken();
				sDEST_SVR_CODE = TokenNumber;

				if ( sSVR_CODE < 0 )
				{
					//MsgBox("[MapServerMng] file load error - sSVR_CODE < 0 (SVR:%d) - 2",
					//	sSVR_CODE);
					return FALSE;
				}

				if ( sDEST_SVR_CODE < -2 )
				{
					//MsgBox("[MapServerMng] file load error - sDEST_SVR_CODE < -1 (SVR:%d, DEST_SVR:%d) - 2",
					//	sSVR_CODE, sDEST_SVR_CODE);
					return FALSE;
				}

				std::map<int, _MAPSVR_DATA*>::iterator it = m_mapSVRCODE_MAP.find(sSVR_CODE);

				if ( it == m_mapSVRCODE_MAP.end() )
				{
					//MsgBox("[MapServerMng] file load error - sSVR_CODE wasn't registered (SVR:%d)",
					//	sSVR_CODE);
					return FALSE;
				}

				lpMapSvrData = it->second;

				if ( lpMapSvrData == NULL )
				{
					//MsgBox("[MapServerMng] file load error - lpMapSvrData == NULL (SVR:%d)",
					//	sSVR_CODE);
					return FALSE;
				}

				if ( lpMapSvrData->m_bIN_USE == FALSE )
				{
					//MsgBox("[MapServerMng] file load error - lpMapSvrData->m_bIN_USE == FALSE (SVR:%d)",
					//	sSVR_CODE);
					return FALSE;
				}

				if ( lpMapSvrData->m_sSVR_CODE != sSVR_CODE )
				{
					//MsgBox("[MapServerMng] file load error - lpMapSvrData->m_sSVR_CODE != sSVR_CODE (SVR:%d)",
					//	sSVR_CODE);
					return FALSE;
				}

				if ( btNotMoveOption != 0 && btNotMoveOption != 1 )
				{
					//MsgBox("[MapServerMng] file load error - lpMapSvrData->m_sSVR_CODE != sSVR_CODE (SVR:%d, OPT:%d)",
					//	sSVR_CODE, btNotMoveOption);
					return FALSE;
				}

				if ( CHECK_LIMIT(wMapNum, MAX_MAP) == FALSE )
				{
					//MsgBox("[MapServerMng] file load error - Map Number is out of bound (SVR:%d, MAP:%d)",
					//	sSVR_CODE, wMapNum);
					return FALSE;
				}

				switch ( btNotMoveOption )
				{
					case 0:
						lpMapSvrData->m_sMAP_MOVE[wMapNum] = sDEST_SVR_CODE;
						break;
					case 1:
						lpMapSvrData->m_sMAP_MOVE[wMapNum] = -3;
						break;
					default:
						//MsgBox("[MapServerMng] file load error - lpMapSvrData->m_sSVR_CODE != sSVR_CODE (SVR:%d, OPT:%d)",
						//	sSVR_CODE, btNotMoveOption);
						break;
				}
			}
		}
	}

	fclose(SMDFile);

	m_bMapDataLoadOk = TRUE;
	LeaveCriticalSection(&m_critSVRCODE_MAP);	
	return TRUE;
}
int scheme_inline_alloc(mz_jit_state *jitter, int amt, Scheme_Type ty, int flags,
			int keep_r0_r1, int keep_fpr1, int inline_retry,
                        int keep_extfpr1)
/* Puts allocated result at JIT_V1; first word is GC tag.
   Uses JIT_R2 as temporary. The allocated memory is "dirty" (i.e., not 0ed).
   Save FP0 when FP ops are enabled. */
{
  GC_CAN_IGNORE jit_insn *ref, *reffail;
#ifdef MZ_GC_STRESS_TESTING
  GC_CAN_IGNORE jit_insn *refstress;
#endif
  intptr_t a_word, sz, algn;

  sz = GC_compute_alloc_size(amt);
  algn = GC_alloc_alignment();

  __START_TINY_JUMPS__(1);
#ifdef MZ_GC_STRESS_TESTING
  refstress = jit_jmpi(jit_forward());
#endif
  reffail = jit_get_ip();
  mz_tl_ldi_p(JIT_V1, tl_GC_gen0_alloc_page_ptr);
  jit_subi_l(JIT_R2, JIT_V1, 1);
  jit_andi_l(JIT_R2, JIT_R2, (algn - 1));
  ref = jit_blti_l(jit_forward(), JIT_R2, (algn - sz));
#ifdef MZ_GC_STRESS_TESTING
  mz_patch_ucbranch(refstress);
#endif
  CHECK_LIMIT();
  __END_TINY_JUMPS__(1);

  /* Failure handling */
  if (inline_retry) {
    int mode;
    if (keep_r0_r1)
      mode = 1;
    else if (keep_fpr1)
      mode = 2;
    else if (keep_extfpr1)
      mode = 3;
    else
      mode = 0;
    scheme_generate_alloc_retry(jitter, mode);
    CHECK_LIMIT();
  } else {
    if (keep_r0_r1) {
      (void)jit_calli(sjc.retry_alloc_code_keep_r0_r1);
    } else if (keep_fpr1) {
      (void)jit_calli(sjc.retry_alloc_code_keep_fpr1);
#ifdef MZ_LONG_DOUBLE
    } else if (keep_extfpr1) {
      (void)jit_calli(sjc.retry_alloc_code_keep_extfpr1);
#endif
    } else {
      (void)jit_calli(sjc.retry_alloc_code);
    }
  }
  __START_TINY_JUMPS__(1);
  (void)jit_jmpi(reffail);
  __END_SHORT_JUMPS__(1);
  
  __START_TINY_JUMPS__(1);
  mz_patch_branch(ref);
  jit_addi_ul(JIT_R2, JIT_V1, sz);
  (void)mz_tl_sti_l(tl_GC_gen0_alloc_page_ptr, JIT_R2, JIT_R0);

  /* GC header: */
  if (ty >= 0) {
    if ((ty == scheme_pair_type)
        || (ty == scheme_mutable_pair_type)
        || (ty == scheme_raw_pair_type))
      a_word = GC_pair_initial_word(amt);
    else
      a_word = GC_initial_word(amt);
    jit_stir_l(JIT_V1, a_word);
    
    /* Scheme_Object header: */
    a_word = initial_tag_word(ty, flags);
    jit_stixi_l(sizeof(intptr_t), JIT_V1, a_word);
  } else {
    /* an array of pointers */
    a_word = GC_array_initial_word(amt);
    jit_stir_l(JIT_V1, a_word);
  }

  CHECK_LIMIT();
  __END_TINY_JUMPS__(1);

  return 1;
}
void CIllusionTempleEvent::PlatformMirageAct(LPOBJECTSTRUCT lpNpc, LPOBJECTSTRUCT lpObj)
{
	if( lpObj->m_IfState.use && lpObj->m_IfState.type != 12 )
	{
		return;
	}
	// ----
	if( lpObj->m_PK_Level >= 4 )
	{
		GCServerMsgStringSend(lMsg.Get(3400), lpObj->m_Index, 1);
		return;
	}
	// ----
	int nIllusionTempleNumber = -1;
	// ----
	if( lpObj->Level < 220 )
	{
		nIllusionTempleNumber = -1;
	}
	else if( lpObj->Level < 271 )
	{
		nIllusionTempleNumber = 0;
	}
	else if( lpObj->Level < 321 )
	{
		nIllusionTempleNumber = 1;
	}
	else if( lpObj->Level < 351 )
	{
		nIllusionTempleNumber = 2;
	}
	else if( lpObj->Level < 381 )
	{
		nIllusionTempleNumber = 3;
	}
	else if( lpObj->Level < 400 )
	{
		nIllusionTempleNumber = 4;
	}
	else if( lpObj->Level == 400 && !lpObj->ThirdChangeUp )
	{
		nIllusionTempleNumber = 4;
	}
	else if( lpObj->Level == 400 && lpObj->ThirdChangeUp )
	{
		if( g_bUseMaxLevelIllusionTemple )
		{
			nIllusionTempleNumber = 5;
		}
		else 
		{
			nIllusionTempleNumber = 4;
		}
	}
	else
	{
		nIllusionTempleNumber = -1;
	}
	// ----
	if( !CHECK_LIMIT(nIllusionTempleNumber, MAX_ILLUSIONTEMPLE_TEMPLE_COUNT) )
	{
		GCServerMsgStringSend(lMsg.Get(3401), lpObj->m_Index, 1);
		return;
	}
	// ----
	int nItempos = m_cIllusionTempleProc[nIllusionTempleNumber].SearchTicketItem(lpObj->m_Index);
	// ----
	if( nItempos == -1 )
	{
		GCServerMsgStringSend(lMsg.Get(3402), lpObj->m_Index, 1);
		return;
	}
	// ----
	if( m_cIllusionTempleProc[nIllusionTempleNumber].GetIllusionTempleState() != 0 )
	{
		GCServerMsgStringSend(lMsg.Get(3403), lpObj->m_Index, 1);
		return;
	}
	// ----
	if( m_cIllusionTempleProc[nIllusionTempleNumber].GetIllusionTempleState() != 0 
		|| m_cIllusionTempleProc[nIllusionTempleNumber].GetEntrance() == FALSE )
	{
		GCServerMsgStringSend(lMsg.Get(3404), lpObj->m_Index, 1);
		return;
	}
	// ----
	PMSG_TALKRESULT pMsg;
	// ----
	pMsg.h.c		= PMHCE_BYTE;
	pMsg.h.headcode = 0x30;
	pMsg.h.size		= sizeof(pMsg);
	pMsg.result		= 0x14;
	pMsg.level1		= this->m_cIllusionTempleProc[nIllusionTempleNumber].GetRemainTimeMin();
	pMsg.level2		= this->m_cIllusionTempleProc[nIllusionTempleNumber].GetUserCount();
	// ----
	DataSend(lpObj->m_Index,(LPBYTE)&pMsg,pMsg.h.size);
}
void CIllusionTempleEvent::AddMonsterPosNum(BYTE btMapNumber, int nClass, int nPosNum)
{
	if(!CHECK_LIMIT((btMapNumber-MAP_INDEX_ILLUSION_TEMPLE1), MAX_ILLUSIONTEMPLE_TEMPLE_COUNT)) return;
	m_cIllusionTempleProc[btMapNumber-MAP_INDEX_ILLUSION_TEMPLE1].AddMonsterPosNum(nClass, nPosNum);
}
示例#20
0
BOOL NpcAngelKing(LPOBJ lpNpc, LPOBJ lpObj)
{
	int iITEM_LEVEL = 0;

	if ( (  (lpObj->m_cBloodCastleIndex < 0)?FALSE:(lpObj->m_cBloodCastleIndex > MAX_BLOOD_CASTLE_LEVEL-1)?FALSE:TRUE ) == FALSE )
	{
		GCServerCmd(lpObj->m_Index, 1, 0x18, 0);
		return FALSE;
	}

	LogAddTD("[Blood Castle] (%d) [%s][%s] Talk to Angel King",
		lpObj->m_cBloodCastleIndex+1, lpObj->AccountID, lpObj->Name);

	if ( g_BloodCastle.m_BridgeData[lpObj->m_cBloodCastleIndex].m_bBC_REWARDED != false )
	{
		GCServerCmd(lpObj->m_Index, 1, 0x2E, 0);
		return FALSE;
	}

	if ( g_BloodCastle.GetCurrentState(lpObj->m_cBloodCastleIndex) != 2 || g_BloodCastle.CheckPlayStart(lpObj->m_cBloodCastleIndex) == false)
	{
		GCServerCmd(lpObj->m_Index, 1, 0x18, 0);
		return FALSE;
	}

	if ( lpObj->m_bBloodCastleComplete == true)
	{
		GCServerCmd(lpObj->m_Index, 1, 0x2E, 0);
		return FALSE;
	}

	if ( iITEM_LEVEL = iITEM_LEVEL = CHECK_LIMIT( g_BloodCastle.CheckQuestItem(lpObj->m_Index), 3)  )
	{
		if ( lpNpc->m_cBloodCastleIndex != lpObj->m_cBloodCastleIndex )
		{
			GCServerCmd(lpObj->m_Index, 1, 0x18, 0);
			return FALSE;
		}

		if ( g_BloodCastle.CheckUserBridgeMember(lpObj->m_cBloodCastleIndex, lpObj->m_Index) == false )
		{
			GCServerCmd(lpObj->m_Index, 1, 0x18, 0);
			return FALSE;
		}

		g_BloodCastle.SetUserState(lpObj->m_Index, 2);
		g_BloodCastle.m_BridgeData[lpObj->m_cBloodCastleIndex].m_iExtraEXP_Win_Quest_Party = lpObj->PartyNumber;
		g_BloodCastle.m_BridgeData[lpObj->m_cBloodCastleIndex].m_iExtraEXP_Win_Quest_Index = lpObj->m_Index;
		memcpy(g_BloodCastle.m_BridgeData[lpObj->m_cBloodCastleIndex].m_szWin_Quest_CharName, lpObj->Name, 10);
		memcpy(g_BloodCastle.m_BridgeData[lpObj->m_cBloodCastleIndex].m_szWin_Quest_AccountID, lpObj->AccountID, 10);
		g_BloodCastle.m_BridgeData[lpObj->m_cBloodCastleIndex].m_szWin_Quest_CharName[10] = 0;	// Zero String terminated
		g_BloodCastle.m_BridgeData[lpObj->m_cBloodCastleIndex].m_szWin_Quest_AccountID[10] = 0;	// Zero String Terminated
		
		LogAddTD("[Blood Castle] (%d) Blood Castle Quest Succeed Result -> Destroy Castle Door [%s][%s]",
			lpObj->m_cBloodCastleIndex+1, g_BloodCastle.m_BridgeData[lpObj->m_cBloodCastleIndex].m_szKill_Door_AccountID,
			g_BloodCastle.m_BridgeData[lpObj->m_cBloodCastleIndex].m_szKill_Door_CharName);
		LogAddTD("[Blood Castle] (%d) Blood Castle Quest Succeed Result -> Destroy Saint Status [%s][%s]",
			lpObj->m_cBloodCastleIndex+1, g_BloodCastle.m_BridgeData[lpObj->m_cBloodCastleIndex].m_szKill_Door_AccountID,	// #error Correct this
			g_BloodCastle.m_BridgeData[lpObj->m_cBloodCastleIndex].m_szKill_Status_CharName);
		LogAddTD("[Blood Castle] (%d) Blood Castle Quest Succeed Result -> Win Quest [%s][%s]",
			lpObj->m_cBloodCastleIndex+1, g_BloodCastle.m_BridgeData[lpObj->m_cBloodCastleIndex].m_szWin_Quest_AccountID,
			g_BloodCastle.m_BridgeData[lpObj->m_cBloodCastleIndex].m_szWin_Quest_CharName);

		if ( g_BloodCastle.SetBridgeWinner(lpObj->m_cBloodCastleIndex, lpObj->m_Index) == TRUE )
		{
			lpObj->m_bBloodCastleComplete = true;

			if ( g_BloodCastle.CheckPartyExist(lpObj->m_Index) == FALSE )
			{
				GCServerCmd(lpObj->m_Index, 1, 0x17, 0);

				LogAddTD("[Blood Castle] (%d) (Account:%s, Name:%s) Succeed Blood Castle Quest",
					lpNpc->MapNumber-10, lpObj->AccountID, lpObj->Name);
			}
			else
			{
				GCServerCmd(lpObj->m_Index, 1, 0x17, 0);
				LogAddTD("[Blood Castle] (%d) (Account:%s, Name:%s) Succeed Blood Castle Quest - More Party to register",
					lpNpc->MapNumber-10, lpObj->AccountID, lpObj->Name);
			}
		}
		else
		{
			LogAddTD("[Blood Castle] (%d) (Account:%s, Name:%s) Winner Already Exist !!",
				lpNpc->MapNumber-10, lpObj->AccountID, lpObj->Name);

			return FALSE;
		}

		g_BloodCastle.SearchUserDeleteQuestItem(lpObj->m_Index);
	}
	else
	{
		if ( g_BloodCastle.CheckUserWinnerParty(lpObj->m_cBloodCastleIndex, lpObj->m_Index) == TRUE )
		{
			lpObj->m_bBloodCastleComplete = true;

			if ( g_BloodCastle.CheckPartyExist(lpObj->m_Index) == FALSE )
			{
				GCServerCmd(lpObj->m_Index, 1, 0x17, 0);

				LogAddTD("[Blood Castle] (%d) (Account:%s, Name:%s) Succeed Blood Castle Quest",
					lpNpc->MapNumber-10, lpObj->AccountID, lpObj->Name);
			}
			else
			{
				GCServerCmd(lpObj->m_Index, 1, 0x17, 0);
				LogAddTD("[Blood Castle] (%d) (Account:%s, Name:%s) Succeed Blood Castle Quest - More Party to register",
					lpNpc->MapNumber-10, lpObj->AccountID, lpObj->Name);
			}

			return FALSE;
		}

		GCServerCmd(lpObj->m_Index, 1, 0x18, 0);
	}
	
	return FALSE;
}
void CIllusionTempleEvent::DeleteRelicsItem(BYTE btMapNumber, LPOBJECTSTRUCT lpObj)
{
	if(!CHECK_LIMIT((btMapNumber-MAP_INDEX_ILLUSION_TEMPLE1), MAX_ILLUSIONTEMPLE_TEMPLE_COUNT)) return;
	m_cIllusionTempleProc[btMapNumber-MAP_INDEX_ILLUSION_TEMPLE1].DeleteRelicsItem(lpObj);
}
示例#22
0
void GJReqMapSvrAuth(LPMSG_REQ_MAPSVRAUTH aRecv,int aIndex)
{
	char szAccountID[MAX_IDSTRING+1];
	szAccountID[MAX_IDSTRING] = 0;
	memcpy(szAccountID, aRecv->szAccountID, MAX_IDSTRING);

	int result = 0;

	PMSG_ANS_MAPSVRAUTH pResult;

	pResult.h.c		= PMHC_BYTE;
	pResult.h.size		= sizeof( pResult );
	pResult.h.headcode = 0x7B;

	memcpy(pResult.szAccountID, aRecv->szAccountID, MAX_IDSTRING);
	memcpy(pResult.szCharName, aRecv->szCharName, MAX_IDSTRING);
	pResult.iIndex = aRecv->iIndex;

	int UserIndex = gObjSearchUser(szAccountID);

	if(UserIndex == -1)
	{
		result = 0x01;
	}
	else if(gObj[UserIndex].m_bMoveReq == TRUE && gObj[UserIndex].pMoveInfo != NULL)
	{
		LPMSG_ANS_MAPSVRMOVE pMoveInfo = gObj[UserIndex].pMoveInfo;

		if ( CHECK_LIMIT(pMoveInfo->wCurMapSvrCode, MAX_SERVEROBJECT) &&
			 CHECK_LIMIT(pMoveInfo->wDstMapSvrCode, MAX_SERVEROBJECT) )
		{
			if ( aRecv->iJoinAuthCode1 == pMoveInfo->iJoinAuthCode1 &&
				 aRecv->iJoinAuthCode2 == pMoveInfo->iJoinAuthCode2 &&
				 aRecv->iJoinAuthCode3 == pMoveInfo->iJoinAuthCode3 &&
				 aRecv->iJoinAuthCode4 == pMoveInfo->iJoinAuthCode4 )
			{
				gObj[UserIndex].m_bMoveReq = FALSE;
				pResult.btX = pMoveInfo->btX;
				pResult.btY = pMoveInfo->btY;
				pResult.wPrevMapSvrCode = pMoveInfo->wCurMapSvrCode;
				pResult.wMapNumber = pMoveInfo->wMapNumber;

				pResult.iUserNumber = UserIndex;
				pResult.iDBNumber = gObj[UserIndex].DBNumber;
				memcpy(pResult.cJoominNumber,gObj[UserIndex].JoomingNumber,20);
				pResult.btBlockCode = gObj[UserIndex].bloc_code;
			}
			else
			{
				result = 0x02;
			}
		}
		else
		{
			result = 0x03;
		}
	}
	else
	{
		result = 0x04;
	}

	pResult.iResult = result;

	DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);

	g_Window.ServerLogAdd(ST_JOINSERVER,"GJReqMapSvrAuth() -> User(%s) Character(%s) result(%d)",
		pResult.szAccountID,pResult.szAccountID,pResult.iResult);
}
BYTE CIllusionTempleEvent::GetUserTeam(BYTE btMapNumber, int nIndex)
{
	if(!CHECK_LIMIT((btMapNumber-MAP_INDEX_ILLUSION_TEMPLE1), MAX_ILLUSIONTEMPLE_TEMPLE_COUNT)) return 0xFF;
	return m_cIllusionTempleProc[btMapNumber-MAP_INDEX_ILLUSION_TEMPLE1].GetUserTeam(nIndex);
}
void CIllusionTempleEvent::HolyRelicsBoxIllusionAct(BYTE btMapNumber, LPOBJECTSTRUCT lpNpc, LPOBJECTSTRUCT lpObj)
{
	if(!CHECK_LIMIT((btMapNumber-MAP_INDEX_ILLUSION_TEMPLE1), MAX_ILLUSIONTEMPLE_TEMPLE_COUNT)) return;
	m_cIllusionTempleProc[btMapNumber-MAP_INDEX_ILLUSION_TEMPLE1].HolyRelicsBoxIllusionAct(lpNpc, lpObj);
}
示例#25
0
BOOL CJewelMixSystem::UnMixJewel(int iIndex, int iJewelType, int iJewelLevel, int iInventoryPos)
{
	if ( !gObjIsConnected(iIndex))
		return FALSE;

	if ( gObjCheckInventorySerial0Item(&gObj[iIndex]))
	{
		MsgOutput(iIndex, lMsg.Get(MSGGET(13,26)));
		GCAnsJewelUnMix(iIndex, 0);

		LogAddTD("[ANTI-HACK][Serial 0 Item] [UnMix Jewel] (%s)(%s)",
			gObj[iIndex].AccountID, gObj[iIndex].Name);

		return FALSE;
	}

	if ( gObj[iIndex].m_IfState.type == 1 )
	{
		LogAddTD("[JewelMix] [%s][%s] Attempted ItemCopy using Trade Window",
			gObj[iIndex].AccountID, gObj[iIndex].Name);
		return FALSE;
	}

	if ( gObj[iIndex].ChaosLock == TRUE )
	{
		LogAddTD("[JewelMix] [%s][%s] Chaos Mix is already working",
			gObj[iIndex].AccountID, gObj[iIndex].Name);

		GCAnsJewelUnMix(iIndex, 0);
		return FALSE;
	}

	gObj[iIndex].ChaosLock = TRUE;

	if ( !CHECK_LIMIT(iJewelType, 10) )
	{
		LogAddTD("[JewelMix] [%s][%s] UnMix iJewelType is out of bound : %d",
			gObj[iIndex].AccountID, gObj[iIndex].Name, iJewelType);

		gObj[iIndex].ChaosLock = FALSE;
		GCAnsJewelUnMix(iIndex, 2);
		return FALSE;
	}

	if ( !CHECK_LIMIT(iInventoryPos, MAIN_INVENTORY_SIZE))
	{
		LogAddTD("[JewelMix] [%s][%s] iInventoryPos is out of bound : %d",
			gObj[iIndex].AccountID, gObj[iIndex].Name, iInventoryPos);

		gObj[iIndex].ChaosLock = FALSE;
		GCAnsJewelUnMix(iIndex, 5);
		return FALSE;
	}

	int iInventoryItemType;
	int iInventoryItemLevel;

	if ( gObj[iIndex].pInventory[iInventoryPos].IsItem() == TRUE )
	{
		if ( gObj[iIndex].pInventory[iInventoryPos].m_Level == iJewelLevel )
		{
			iInventoryItemType = gObj[iIndex].pInventory[iInventoryPos].m_Type;
			iInventoryItemLevel = gObj[iIndex].pInventory[iInventoryPos].m_Level;
		}
		else
		{
			LogAddTD("[JewelMix] [%s][%s] iJewelLevel is different from request : %d / %d",
				gObj[iIndex].AccountID, gObj[iIndex].Name,
				gObj[iIndex].pInventory[iInventoryPos].m_Level, iJewelLevel);

			gObj[iIndex].ChaosLock = FALSE;
			GCAnsJewelUnMix(iIndex, 3);
			return FALSE;
		}
	}
	else
	{
		LogAddTD("[JewelMix] [%s][%s] Item to unmix is not exist",
			gObj[iIndex].AccountID, gObj[iIndex].Name);
	
		gObj[iIndex].ChaosLock = FALSE;
		GCAnsJewelUnMix(iIndex, 4);
		return FALSE;
	}

	if ( !CHECK_LIMIT(iInventoryItemLevel, 3))
	{
		LogAddTD("[JewelMix] [%s][%s] iInventoryItemLevel is out of bound : %d",
			gObj[iIndex].AccountID, gObj[iIndex].Name, iInventoryItemLevel);

		gObj[iIndex].ChaosLock = FALSE;
		GCAnsJewelUnMix(iIndex, 3);
		return FALSE;
	}

	int iItemType = g_JewelMixInfo[iJewelType][iInventoryItemLevel].m_iChangeType;
	int iJewelCount = g_JewelMixInfo[iJewelType][iInventoryItemLevel].m_iJewelCount;
	int iChangeType = g_JewelMixInfo[iJewelType][iInventoryItemLevel].m_iSourceType;
	int iMixMoney = 1000000;

	if ( iInventoryItemType != iItemType )
	{
		LogAddTD("[JewelMix] [%s][%s] iItemType is different from request : %d / %d",
			gObj[iIndex].AccountID, gObj[iIndex].Name,
			iInventoryItemType, iItemType);

		gObj[iIndex].ChaosLock = FALSE;
		GCAnsJewelUnMix(iIndex, 6);
		return FALSE;
	}

	if ( iMixMoney > gObj[iIndex].Money )
	{
		LogAddTD("[JewelMix] [%s][%s] lack of money to unmix : %d / %d",
			gObj[iIndex].AccountID, gObj[iIndex].Name,
			gObj[iIndex].Money, iMixMoney);

		gObj[iIndex].ChaosLock = FALSE;
		GCAnsJewelUnMix(iIndex, 8);
		return FALSE;
	}

	int invSize = INVENTORY_MAP_SIZE-PSHOP_MAP_SIZE;

	if( gObj[iIndex].pInventoryExtend <= 4 )	{
		invSize = (INVENTORY_MAP_SIZE-PSHOP_MAP_SIZE)-(32*(4-gObj[iIndex].pInventoryExtend));
	}

	int iEmptyCount = 0;

	int x;
	for ( x=0;x<invSize;x++)
	{
		if ( gObj[iIndex].pInventoryMap[x] == 0xFF )
		{
			iEmptyCount++;
		}
	}

	if ( iEmptyCount < iJewelCount )
	{
		LogAddTD("[JewelMix] [%s][%s] lack of empty slot to unmix : %d / %d",
			gObj[iIndex].AccountID, gObj[iIndex].Name,
			iEmptyCount, iJewelCount);

		gObj[iIndex].ChaosLock = FALSE;
		GCAnsJewelUnMix(iIndex, 7);
		return FALSE;
	}

	LogAddTD("[JewelMix] [%s][%s] UnMix - Delete Jewel, Type:%d, Level:%d, Serial:%d",
		gObj[iIndex].AccountID, gObj[iIndex].Name,
		gObj[iIndex].pInventory[iInventoryPos].m_Type,
		gObj[iIndex].pInventory[iInventoryPos].m_Level,
		gObj[iIndex].pInventory[iInventoryPos].m_Number);

	gObjInventoryItemSet(iIndex, iInventoryPos, 0xFF);
	gObjInventoryDeleteItem(iIndex, iInventoryPos);
	GCInventoryItemDeleteSend(iIndex, iInventoryPos, 1);

	int iCrtJewelCount = 0;
	BOOL bItemCrtOK = FALSE;

	for ( x=0;x<invSize;x++)
	{
		if ( gObj[iIndex].pInventoryMap[x] == 0xFF )
		{
			ItemSerialCreateSend(iIndex, 235, gObj[iIndex].X, gObj[iIndex].Y,
								iChangeType, 0, 0, 0, 0, 0,
								iIndex, 0, 0);

			iCrtJewelCount++;

			if ( iJewelCount <= iCrtJewelCount )
			{
				bItemCrtOK = TRUE;
				break;
			}
		}
	}

	gObj[iIndex].ChaosLock = FALSE;

	if ( bItemCrtOK == TRUE )
	{
		LogAddTD("[JewelMix] [%s][%s] jewel unmix succeed : ItemType:%d, JewelCount:%d",
			gObj[iIndex].AccountID, gObj[iIndex].Name,
			iItemType, iJewelCount);

		gObj[iIndex].Money -= iMixMoney;
		GCMoneySend(iIndex, gObj[iIndex].Money);
		GCAnsJewelUnMix(iIndex, 1);
	}
	else
	{
		LogAddTD("[JewelMix] [%s][%s] jewel unmix failed : ItemType:%d, JewelCount:%d",
			gObj[iIndex].AccountID, gObj[iIndex].Name,
			iItemType, iJewelCount);

		GCAnsJewelUnMix(iIndex, 0);
	}

	return TRUE;
}
void CIllusionTempleEvent::DropRelicsItem(BYTE btMapNumber, int nIndex)
{
	if(!CHECK_LIMIT((btMapNumber-MAP_INDEX_ILLUSION_TEMPLE1), MAX_ILLUSIONTEMPLE_TEMPLE_COUNT)) return;
	m_cIllusionTempleProc[btMapNumber-MAP_INDEX_ILLUSION_TEMPLE1].DropRelicsItem(nIndex);
}
示例#27
0
BOOL CMapServerManager::LoadData(char* lpszFileName)
{
	if ( (lpszFileName == NULL) || ( strcmp(lpszFileName, "")== 0 ) ) 
	{
		Log.LogAdd("[MapServerMng] CMapServerManager::LoadData() - file load error : File Name Error");
		return FALSE;
	}

	EnterCriticalSection(&this->m_critSVRCODE_MAP);

	//__try
	{
		this->Clear();

		SMDFile = fopen(lpszFileName, "r");

		if ( SMDFile == NULL )
		{
			Log.LogAdd("[MapServerMng] CMapServerManager::LoadData() - file load error : fopen() : %s",
				lpszFileName);

			return FALSE;
		}

		int type = -1;
		SMDToken Token;

		while ( true )
		{
			Token = GetToken();

			if ( Token == END )
				break;

			type = TokenNumber;

			while ( true )
			{
				if ( type == 0 )
				{
					short sSVR_CODE = -1;
					short sMAPSVR_GROUP = -1;
					int iInitSetVal = 1;
					char szIpAddr[16]={0};
					WORD wPortNum = 0;
					
					Token = GetToken();

					if ( !strcmp("end", TokenString))
						break;

					sSVR_CODE = TokenNumber;

					Token = GetToken();
					sMAPSVR_GROUP = TokenNumber;

					Token = GetToken();
					iInitSetVal = TokenNumber;

					Token = GetToken();
					memcpy(szIpAddr, &TokenString[1], 16);
					szIpAddr[15] =0;

					Token = GetToken();
					wPortNum = TokenNumber;

					if ( sSVR_CODE < 0 )
					{
						Log.LogAdd("[MapServerMng] CMapServerManager::LoadData() - file load error : sSVR_CODE < 0 (SVR:%d) - 1",
							sSVR_CODE);

						return FALSE;
					}

					if ( iInitSetVal != -1 && iInitSetVal != 0 && iInitSetVal != 1 )
					{
						Log.LogAdd("[MapServerMng] CMapServerManager::LoadData() - file load error : iInitSetting Value:%d (SVR:%d) - 1",
							iInitSetVal, sSVR_CODE);

						return FALSE;
					}

					if ( !strcmp(szIpAddr, ""))
					{
						Log.LogAdd("[MapServerMng] CMapServerManager::LoadData() - file load error : No IpAddress (SVR:%d)",
							sSVR_CODE);

						return FALSE;
					}

					if ( CHECK_LIMIT(sMAPSVR_GROUP, MAX_MAP_GROUPS) == FALSE )
					{
						Log.LogAdd("[MapServerMng] CMapServerManager::LoadData() - file load error : Map Server Group Index (IDX:%d)",
							sMAPSVR_GROUP);

						return FALSE;
					}

					if ( this->m_iMAPSVR_GROUP_COUNT[sMAPSVR_GROUP] >= MAX_MAP_SUBGROUPS )
					{
						Log.LogAdd("[MapServerMng] CMapServerManager::LoadData() - file load error : No Space to Save SvrInfo (SVR:%d)",
							sSVR_CODE);

						return FALSE;
					}

					_MAPSVR_DATA * lpMapSvrData = NULL;

					lpMapSvrData= &this->m_MAPSVR_DATA[sMAPSVR_GROUP][this->m_iMAPSVR_GROUP_COUNT[sMAPSVR_GROUP]];

					lpMapSvrData->Clear(iInitSetVal);
					lpMapSvrData->m_bIN_USE = TRUE;
					lpMapSvrData->m_sSVR_CODE = sSVR_CODE;
					lpMapSvrData->m_btMAPSVR_GROUP = sMAPSVR_GROUP;
					lpMapSvrData->m_wPORT = wPortNum;
					memcpy(lpMapSvrData->m_cIPADDR, szIpAddr, 16);
					lpMapSvrData->m_cIPADDR[15] = 0;
					
					this->m_mapSVRCODE_MAP.insert(std::pair<int,_MAPSVR_DATA *>(sSVR_CODE, lpMapSvrData));
					this->m_iMAPSVR_GROUP_COUNT[sMAPSVR_GROUP]++;
				}
				else if ( type == 1 )
				{
					short sSVR_CODE = -1;
					BYTE btNotMoveOption = 0;
					WORD wMapNum = 0;
					short sDEST_SVR_CODE = -1;
					_MAPSVR_DATA * lpMapSvrData = NULL;

					Token = GetToken();

					if ( !strcmp("end", TokenString))
						break;

					sSVR_CODE = TokenNumber;

					Token = GetToken();
					btNotMoveOption = TokenNumber;

					Token = GetToken();
					wMapNum = TokenNumber;

					Token = GetToken();
					sDEST_SVR_CODE = TokenNumber;

					if ( sSVR_CODE < 0 )
					{
						Log.LogAdd("[MapServerMng] CMapServerManager::LoadData() - file load error : sSVR_CODE < 0 (SVR:%d) - 2",
							sSVR_CODE);

						return FALSE;
					}

					if ( sDEST_SVR_CODE < -2 )
					{
						Log.LogAdd("[MapServerMng] CMapServerManager::LoadData() - file load error : sDEST_SVR_CODE < -1 (SVR:%d, DEST_SVR:%d) - 2",
							sSVR_CODE, sDEST_SVR_CODE);

						return FALSE;
					}

					std::map<int  ,_MAPSVR_DATA *>::iterator it = this->m_mapSVRCODE_MAP.find(sSVR_CODE);

					if ( it == this->m_mapSVRCODE_MAP.end() )
					{
						Log.LogAdd("[MapServerMng] CMapServerManager::LoadData() - file load error : sSVR_CODE wasn't registered (SVR:%d)",
							sSVR_CODE);

						return FALSE;
					}

					lpMapSvrData = it->second;

					if ( lpMapSvrData == NULL )
					{
						Log.LogAdd("[MapServerMng] CMapServerManager::LoadData() - file load error : lpMapSvrData == NULL (SVR:%d)",
							sSVR_CODE);

						return FALSE;
					}

					if ( lpMapSvrData->m_bIN_USE == FALSE )
					{
						Log.LogAdd("[MapServerMng] CMapServerManager::LoadData() - file load error : lpMapSvrData->m_bIN_USE == FALSE (SVR:%d)",
							sSVR_CODE);

						return FALSE;
					}

					if ( lpMapSvrData->m_sSVR_CODE != sSVR_CODE )
					{
						Log.LogAdd("[MapServerMng] CMapServerManager::LoadData() - file load error : lpMapSvrData->m_sSVR_CODE != sSVR_CODE (SVR:%d)",
							sSVR_CODE);

						return FALSE;
					}

					if ( btNotMoveOption != 0 && btNotMoveOption != 1 )
					{
						Log.LogAdd("[MapServerMng] CMapServerManager::LoadData() - file load error : lpMapSvrData->m_sSVR_CODE != sSVR_CODE (SVR:%d, OPT:%d)",
							sSVR_CODE, btNotMoveOption);

						return FALSE;
					}

					if ( CHECK_LIMIT(wMapNum, MAX_NUMBER_MAP) == FALSE )
					{
						Log.LogAdd("[MapServerMng] CMapServerManager::LoadData() - file load error : Map Number is out of bound (SVR:%d, MAP:%d)",
							sSVR_CODE, wMapNum);

						return FALSE;
					}

					switch ( btNotMoveOption )
					{
						case 0:
							lpMapSvrData->m_sMAP_MOVE[wMapNum] = sDEST_SVR_CODE;
							break;
						case 1:
							lpMapSvrData->m_sMAP_MOVE[wMapNum] = -3;
							break;
						default:
							Log.LogAdd("[MapServerMng] CMapServerManager::LoadData() - file load error : lpMapSvrData->m_sSVR_CODE != sSVR_CODE (SVR:%d, OPT:%d)",
								sSVR_CODE, btNotMoveOption);
							break;
					}
				}	// if type
			}	// while ( true )
		}	// while ( true )

		fclose(SMDFile);

		/*std::map<int  ,_MAPSVR_DATA *>::iterator it = this->m_mapSVRCODE_MAP.find(gGameServerCode);

		if ( it != this->m_mapSVRCODE_MAP.end() )
		{
			this->m_lpThisMapSvrData = it->second;
		}
		else
		{
			this->m_lpThisMapSvrData = NULL;
		}

		if ( this->m_lpThisMapSvrData == NULL )
		{
			Log.LogAdd("[MapServerMng] CMapServerManager::LoadData() - file load error : This GameServerCode (%d) doesn't Exist at file '%s' != sSVR_CODE",
				gGameServerCode, lpszFileName);

			return FALSE;
		}*/

		this->m_bMapDataLoadOk = TRUE;
	}
//	__finally
	{
		LeaveCriticalSection(&this->m_critSVRCODE_MAP);
	}

	return TRUE;
}
void CIllusionTempleEvent::SetStatusRegenTime(BYTE btMapNumber)
{
	if(!CHECK_LIMIT((btMapNumber-MAP_INDEX_ILLUSION_TEMPLE1), MAX_ILLUSIONTEMPLE_TEMPLE_COUNT)) return;
	m_cIllusionTempleProc[btMapNumber-MAP_INDEX_ILLUSION_TEMPLE1].SetStatusRegenTime();
}
示例#29
0
int scMakeInstanceImage (char *userId, char *imageId, char *imageURL, char *kernelId, char *kernelURL, char *ramdiskId, char *ramdiskURL, char *instanceId, char *keyName, char **instance_path, sem * s, int convert_to_disk, long long total_disk_limit_mb) 
{
    char image_path   [BUFSIZE]; long long image_size_b = 0L;
    char kernel_path  [BUFSIZE]; long long kernel_size_b = 0L;
    char ramdisk_path [BUFSIZE]; long long ramdisk_size_b = 0L;
    char config_path  [BUFSIZE];
    char rundir_path  [BUFSIZE];
    int e = ERROR;
    
    logprintfl (EUCAINFO, "retrieving images for instance %s (disk limit=%lldMB)...\n", instanceId, total_disk_limit_mb);
    
    /* get the necessary files from Walrus, caching them if possible */
    char * image_name;
    int mount_offset = 0;
    long long limit_mb = total_disk_limit_mb;
    if (convert_to_disk) {
        image_name = "disk";
        mount_offset = 32256; /* 1st partition offset in the disk image */
    } else {
        image_name = "root";
        limit_mb -= swap_size_mb; /* account for swap, which will be a separate file */
    } 

#define CHECK_LIMIT(WHAT) \
    if (limit_mb < 1L) { \
        logprintfl (EUCAFATAL, "error: insufficient disk capacity remaining (%lldMB) in VM Type of instance %s for component %s\n", limit_mb, instanceId, WHAT); \
        return e; \
    }
    CHECK_LIMIT("swap");

    /* do kernel & ramdisk first, since either the disk or the ephemeral partition will take up the rest */
    if ((kernel_size_b=get_cached_file (userId, kernelURL, kernelId, instanceId, "kernel", kernel_path, s, 0, limit_mb))<1L) return e;
    limit_mb -= kernel_size_b/MEGABYTE;
    CHECK_LIMIT("kernel")
    if (ramdiskId && strnlen (ramdiskId, CHAR_BUFFER_SIZE) ) {
        if ((ramdisk_size_b=get_cached_file (userId, ramdiskURL, ramdiskId, instanceId, "ramdisk", ramdisk_path, s, 0, limit_mb))<1L) return e;
        limit_mb -= ramdisk_size_b/MEGABYTE;
        CHECK_LIMIT("ramdisk")
    }

    if ((image_size_b=get_cached_file (userId, imageURL, imageId, instanceId, image_name, image_path, s, convert_to_disk, limit_mb))<1L) return e;
    limit_mb -= image_size_b/MEGABYTE;

    snprintf (rundir_path, BUFSIZE, "%s/%s/%s", sc_instance_path, userId, instanceId);
   
    logprintfl (EUCAINFO, "preparing images for instance %s...\n", instanceId);
    
    /* embed the key, which is contained in keyName */
    char *key_template = NULL;
    if (keyName && strlen(keyName)) {
        int key_len = strlen(keyName);
        int fd = -1;
        int ret;
        
        key_template = strdup("/tmp/sckey.XXXXXX");
        
        if (((fd = mkstemp(key_template)) < 0)) {
            logprintfl (EUCAERROR, "failed to create a temporary key file\n"); 
        } else if ((ret = write (fd, keyName, key_len))<key_len) {
            logprintfl (EUCAERROR, "failed to write to key file %s write()=%d\n", key_template, ret);
        } else {
            close (fd);
            logprintfl (EUCAINFO, "adding key%s to the root file system at %s using (%s)\n", key_template, image_path, add_key_command_path);
        }
    } else { /* if no key was given, add_key just does tune2fs to up the filesystem mount date */
        key_template = "";
        logprintfl (EUCAINFO, "running tune2fs on the root file system at %s using (%s)\n", key_template, image_path, add_key_command_path);
    }

    /* do the key injection and/or tune2fs */
    sem_p (s);
    if (vrun("%s %d %s %s", add_key_command_path, mount_offset, image_path, key_template)!=0) {
        logprintfl (EUCAERROR, "ERROR: key injection / tune2fs command failed\n");
        /* we proceed despite the failure since maybe user embedded the key
         * into the image; also tune2fs may fail on uncrecognized but valid
         * filesystems */
    }
    sem_v (s);
    
    if (strlen(key_template)) {
        if (unlink(key_template) != 0) {
            logprintfl (EUCAWARN, "WARNING: failed to remove temporary key file %s\n", key_template);
        }
        free (key_template);
    }
    
    /* if the image is a root partition... */
    if (!convert_to_disk) {
        /* create swap partition */
        if (swap_size_mb>0) { 
            if ((e=vrun ("dd bs=1M count=%lld if=/dev/zero of=%s/swap 2>/dev/null", swap_size_mb, rundir_path)) != 0) { 
                logprintfl (EUCAINFO, "creation of swap (dd) at %s/swap failed\n", rundir_path);
                return e;
            }
            if ((e=vrun ("mkswap %s/swap >/dev/null", rundir_path)) != 0) {
                logprintfl (EUCAINFO, "initialization of swap (mkswap) at %s/swap failed\n", rundir_path);
                return e;		
            }
        }
        /* create ephemeral partition */
        if (limit_mb>0) {
            if ((e=vrun ("dd bs=1M count=%lld if=/dev/zero of=%s/ephemeral 2>/dev/null", limit_mb, rundir_path )) != 0) {
                logprintfl (EUCAINFO, "creation of ephemeral disk (dd) at %s/ephemeral failed\n", rundir_path);
                return e;
            }
            if ((e=vrun ("mkfs.ext3 -F %s/ephemeral >/dev/null 2>&1", rundir_path)) != 0) {
                logprintfl (EUCAINFO, "initialization of ephemeral disk (mkfs.ext3) at %s/ephemeral failed\n", rundir_path);
                return e;		
            }
        }
    }
    
    * instance_path = strdup (rundir_path);
    if (*instance_path==NULL) return errno;
    return 0;
}
示例#30
0
BOOL CJewelMixSystem::MixJewel( int iIndex, int iJewelType, int iMixType)
{
	if ( !gObjIsConnected(iIndex))
		return FALSE;

	if ( gObjCheckInventorySerial0Item(&gObj[iIndex]))
	{
		MsgOutput(iIndex, lMsg.Get(MSGGET(13,26)));
		GCAnsJewelMix(iIndex, 4);

		LogAddTD("[ANTI-HACK][Serial 0 Item] [Mix Jewel] (%s)(%s)",
			gObj[iIndex].AccountID, gObj[iIndex].Name);

		return FALSE;
	}

	if ( gObj[iIndex].m_IfState.type == 1 )
	{
		LogAddTD("[JewelMix] [%s][%s] Attempted ItemCopy using Trade Window",
			gObj[iIndex].AccountID, gObj[iIndex].Name);
		return FALSE;
	}

	if ( gObj[iIndex].ChaosLock == TRUE )
	{
		LogAddTD("[JewelMix] [%s][%s] Chaos Mix is already working",
			gObj[iIndex].AccountID, gObj[iIndex].Name);

		GCAnsJewelMix(iIndex, 0);
		return FALSE;
	}

	gObj[iIndex].ChaosLock = TRUE;

	if ( !CHECK_LIMIT(iJewelType, 10) )
	{
		LogAddTD("[JewelMix] [%s][%s] Mix iJewelType is out of bound : %d",
			gObj[iIndex].AccountID, gObj[iIndex].Name, iJewelType);

		gObj[iIndex].ChaosLock = FALSE;
		GCAnsJewelMix(iIndex, 2);
		return FALSE;
	}

	if ( !CHECK_LIMIT(iMixType, 3))
	{
		LogAddTD("[JewelMix] [%s][%s] iMixType is out of bound : %d",
			gObj[iIndex].AccountID, gObj[iIndex].Name, iMixType);

		gObj[iIndex].ChaosLock = FALSE;
		GCAnsJewelMix(iIndex, 3);
		return FALSE;
	}

	int iItemType = g_JewelMixInfo[iJewelType][iMixType].m_iSourceType;
	int iJewelCount = g_JewelMixInfo[iJewelType][iMixType].m_iJewelCount;
	int iMixMoney = g_JewelMixInfo[iJewelType][iMixType].m_iMixMoney;
	int iChangeType = g_JewelMixInfo[iJewelType][iMixType].m_iChangeType;

	if ( iJewelCount <= 0 )
	{
		gObj[iIndex].ChaosLock = FALSE;
		GCAnsJewelMix(iIndex, 0);
		return FALSE;
	}

	int iUserJewelCount = gObjGetItemCountInIventory(iIndex, iItemType);

	if ( iJewelCount > iUserJewelCount )
	{
		LogAddTD("[JewelMix] [%s][%s] lack of jewel to mix : %d / %d",
			gObj[iIndex].AccountID, gObj[iIndex].Name,
			iUserJewelCount, iJewelCount);

		gObj[iIndex].ChaosLock = FALSE;
		GCAnsJewelMix(iIndex, 4);
		return FALSE;
	}

	if ( iMixMoney > gObj[iIndex].Money )
	{
		LogAddTD("[JewelMix] [%s][%s] lack of money to mix : %d / %d",
			gObj[iIndex].AccountID, gObj[iIndex].Name,
			gObj[iIndex].Money, iMixMoney);

		gObj[iIndex].ChaosLock = FALSE;
		GCAnsJewelMix(iIndex, 5);
		return FALSE;
	}

	int iDelJewelCount = 0;
	BOOL bItemDelOK = FALSE;


	int invSize = MAIN_INVENTORY_SIZE;

	if( gObj[iIndex].pInventoryExtend <= 4 )	{
		invSize = (MAIN_INVENTORY_SIZE)-(32*(4-gObj[iIndex].pInventoryExtend));
	}

	for ( int x= INVETORY_WEAR_SIZE ; x< invSize; x++)
	{
		if ( gObj[iIndex].pInventory[x].IsItem() == TRUE )
		{
			if ( gObj[iIndex].pInventory[x].m_Type == iItemType )
			{
				LogAddTD("[JewelMix] [%s][%s] Mix - Delete Jewel, Type:%d, Level:%d, Serial:%d",
					gObj[iIndex].AccountID, gObj[iIndex].Name,
					gObj[iIndex].pInventory[x].m_Type,
					gObj[iIndex].pInventory[x].m_Level,
					gObj[iIndex].pInventory[x].m_Number);

				gObjInventoryItemSet(iIndex, x, 0xFF);
				gObj[iIndex].pInventory[x].Clear();
				iDelJewelCount++;

				if ( iJewelCount <= iDelJewelCount )
				{
					bItemDelOK = TRUE;
					break;
				}
			}
		}
	}

	GCItemListSend(iIndex);

	if ( bItemDelOK == FALSE )
	{
		LogAddTD("[JewelMix] [%s][%s] lack of jewel to mix (in deleting) : %d / %d",
			gObj[iIndex].AccountID, gObj[iIndex].Name,
			iDelJewelCount, iJewelCount);

		gObj[iIndex].ChaosLock = FALSE;
		GCAnsJewelMix(iIndex, 0);
		return FALSE;
	}

	ItemSerialCreateSend(iIndex, 235, gObj[iIndex].X,
						gObj[iIndex].Y, iChangeType,
						iMixType, 0, 0, 0, 0,
						iIndex, 0, 0);

	gObj[iIndex].ChaosLock = FALSE;
	gObj[iIndex].Money -= iMixMoney;
	GCMoneySend(iIndex, gObj[iIndex].Money);
	GCAnsJewelMix(iIndex, 1);

	LogAddTD("[JewelMix] [%s][%s] jewel mix succeed : ItemType:%d, JewelCount:%d",
		gObj[iIndex].AccountID, gObj[iIndex].Name,
		iItemType, iJewelCount);

	return TRUE;
}