Example #1
0
CPet* CPlayerPet::CreateTestPet()
{
	
	DT_PET_DATA stData;
	memset(&stData, 0, sizeof(DT_PET_DATA));
	stData.wPetId = 0;
	stData.byStarLv = 1;
	stData.wLv = 1;
	stData.byPetState = ePS_FIGHT;
	stData.wPetCfgId = 42;
	AddPet(stData);
	return NULL;
}
void addpet(Tree * pt) {
	Pet * ppet = (Pet *) malloc(sizeof(Pet));
	if (ppet == NULL) {
		fprintf(stderr, "Could not allocate memory.\n");
		return;
	}

	if (TreeIsFull(pt)) {
		puts("No room in the club!");
	}
	else {
		puts("Please enter name of pet:");
		get(ppet->name, STRLEN);
		puts("Please enter pet kind:");
		get(ppet->type, STRLEN);
		uppercase(ppet->name);
		uppercase(ppet->type);
		ppet->next = NULL;
		AddPet(ppet, pt);
	}
}
Example #3
0
void PetStash::RecvPetStashMessage(CNetworkMessage* istr)
{
	CUIManager* pUImanager = CUIManager::getSingleton();

	CUIPetStash* pStash = pUImanager->GetPetStash();
	CUIPetStashSelectEffect* pEffect = pUImanager->GetPetStashSelectEffect();

	pTypeBase* pBase = reinterpret_cast<pTypeBase*>(istr->GetBuffer());

	switch (pBase->subType)
	{
	case MSG_PET_STASH_LIST_UPDATE:
		{
			UpdateClient::PetStashList* pRecv = reinterpret_cast<UpdateClient::PetStashList*>(istr->GetBuffer());

			if (m_nPetCount != 0)
			{
				// 팻 창고 클리어
				ClearPetList();
				// UI 클리어
				if (pStash)
					pStash->ClearUI();
			}

			m_nProxyPetIndex = pRecv->proxyPetItemVIndex;
			m_nPetCount = pRecv->count;
						
			if ( m_nPetCount <= 0 )
			{
				// 펫 창고 클리어
				ClearPetList();
				// UI 클리어
				if (pStash)
					pStash->ClearUI();
			}
			else
			{
				PetStashData* pPetStashList = new PetStashData[m_nPetCount];
				memcpy( pPetStashList, &pRecv->petStashData[0], sizeof(PetStashData) * m_nPetCount );

				for (int i = 0; i < pRecv->count; i++)
				{
					m_vecPetStashList.push_back(&pPetStashList[i]);
				}
				UpdatePetInfo();
			}
		}
		break;

	case MSG_PET_STASH_PET_UPDATE:
		{
			UpdateClient::PetStashPetData* pRecv = reinterpret_cast<UpdateClient::PetStashPetData*>(istr->GetBuffer());

			PetStashData* pPetData = new PetStashData;
			memcpy( pPetData, &pRecv->petStashData, sizeof(PetStashData) );
			_UpdatePet(pPetData);

			SAFE_DELETE(pPetData);
		}
		break;

	case MSG_PET_STASH_TAKE:
		{
			ResponseClient::PetStashTake* pRecv = reinterpret_cast<ResponseClient::PetStashTake*>(istr->GetBuffer());

			if (pRecv->result != ERROR_PET_STASH_TAKE_SUCCESS)
			{
				_PetErrorSystemMessage(pRecv->result);
			}
		}
		break;

	case MSG_PET_STASH_TAKE_UPDATE:
		{
			UpdateClient::PetStashTake* pRecv = reinterpret_cast<UpdateClient::PetStashTake*>(istr->GetBuffer());
			DeletePet(pRecv->petItemVIndex);
		}
		break;

	case MSG_PET_STASH_KEEP:
		{
			ResponseClient::PetStashKeep* pRecv = reinterpret_cast<ResponseClient::PetStashKeep*>(istr->GetBuffer());

			if (pRecv->result != ERROR_PET_STASH_KEEP_SUCCESS)
			{
				_PetErrorSystemMessage(pRecv->result);
			}
		}
		break;

	case MSG_PET_STASH_KEEP_UPDATE:
		{
			UpdateClient::PetStashKeep* pRecv = reinterpret_cast<UpdateClient::PetStashKeep*>(istr->GetBuffer());

			PetStashData* pPetData = new PetStashData;
			memcpy( pPetData, &pRecv->petStashData, sizeof(PetStashData) );
			AddPet(pPetData);
		}
		break;

	case MSG_PET_STASH_PROXY:
		{
			ResponseClient::PetStashProxyReg* pRecv = reinterpret_cast<ResponseClient::PetStashProxyReg*>(istr->GetBuffer());
			
			if (pRecv->result != ERROR_PET_STASH_PROXY_SUCCESS)
			{
				_PetErrorSystemMessage(pRecv->result);
			}
		}
		break;

	case MSG_PET_STASH_PROXY_CANCEL:
		{
			ResponseClient::PetStashProxyCancel* pRecv = reinterpret_cast<ResponseClient::PetStashProxyCancel*>(istr->GetBuffer());

			if (pRecv->result != ERROR_PET_STASH_PROXY_CANCEL_SUCCESS)
			{
				_PetErrorSystemMessage(pRecv->result);
			}
		}
		break;

	case MSG_PET_STASH_EFFECT:
		{
			UpdateClient::PetStashEffect* pRecv = reinterpret_cast<UpdateClient::PetStashEffect*>(istr->GetBuffer());
			
			m_nEffectModelNo = pRecv->effectNo;
			
			if (pRecv->effectNo >= 0)
			{
				pUImanager->GetPetStashSelectEffect()->OpenPetStashSelectEffect();
			}
		}
		break;

	case MSG_PET_STASH_EFFECT_BY_INMAP: // 인맵, 기간만료시 제거
		{
			UpdateClient::PetStashEffectByInMap* pRecv = reinterpret_cast<UpdateClient::PetStashEffectByInMap*>(istr->GetBuffer());

			SetEffectModelNo(pRecv->effectNo);
		}
		break;

	case MSG_PET_STASH_EFFECT_BROAD_CAST:
		{
			UpdateClient::PetStashEffectBr* pRecv = reinterpret_cast<UpdateClient::PetStashEffectBr*>(istr->GetBuffer());

			int charIndex = pRecv->charIndex;
			int EffectNo = pRecv->effectNo;

			if (charIndex == _pNetwork->MyCharacterInfo.index)
				return;

			ObjectBase* pObject = ACTORMGR()->GetObject(eOBJ_CHARACTER, charIndex);

			if (pObject != NULL)
			{
				CCharacterTarget* pTarget = static_cast< CCharacterTarget* >(pObject);

				pTarget->cha_itemEffect.AddPetStashEffect( EffectNo, &(pTarget->m_pEntity->en_pmiModelInstance->m_tmSkaTagManager) );
			}
		}
		break;

	case MSG_PET_STASH_ERROR:
		{
			ResponseClient::PetStashError* pRecv = reinterpret_cast<ResponseClient::PetStashError*>(istr->GetBuffer());
			int errorCode = pRecv->errorCode;
						
			_PetErrorSystemMessage(errorCode);
		}
		break;

	case MSG_PET_STASH_PROXY_UPDATE:
		{
			UpdateClient::PetStashProxyReg* pRecv = reinterpret_cast<UpdateClient::PetStashProxyReg*>(istr->GetBuffer());
			m_nProxyPetIndex = pRecv->virtualIndex;
		}
		break;

	case MSG_PET_STASH_PROXY_CANCEL_UPDATE:
		{
			UpdateClient::PetStashProxyCancel* pRecv = reinterpret_cast<UpdateClient::PetStashProxyCancel*>(istr->GetBuffer());
			m_nProxyPetIndex = pRecv->virtualIndex;
		}
		break;
	}

	if (pStash->IsVisible() != FALSE)
		pStash->UpdateUI();
}