www.pudn.com > loseserver.rar > CharMap.cpp


/* 
Copyright (C) 2004  freeplay.dk 
 
This program is free software; you can redistribute it and/or 
modify it under the terms of the GNU General Public License 
as published by the Free Software Foundation; either version 2 
of the License, or (at your option) any later version. 
 
This program is distributed in the hope that it will be useful, 
but WITHOUT ANY WARRANTY; without even the implied warranty of 
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
GNU General Public License for more details. 
 
You should have received a copy of the GNU General Public License 
along with this program; if not, write to the Free Software 
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. 
 
You may contact me for further information on admin@freeplay.dk 
*/ 
 
#define WIN32_LEAN_AND_MEAN 
 
// disable map warnings for std::map 
#pragma warning (disable: 4786) 
#pragma warning (disable: 4788) 
 
#include  
#include  
#include  
#include  
#include "CharMap.h" 
#include "Types.h" 
#include "GameServer.h" 
#include "ObjectsMultimap.h" 
#include "Logging.h" 
#include "GS_Attack.h" 
#include "OpCodes.h" 
#include "CConnection.h" 
 
using namespace std; 
 
extern GameServer gs; 
extern objects obj; 
extern GS_Attack Attack; 
 
int charmap::Sendtimenow(DWORD ptr) 
{ 
	gs.SendTime(ptr); 
	return 0;	 
} 
 
int charmap::checkknown(DWORD myptr, DWORD ptr, unsigned int key, unsigned int cp, unsigned long OtherObj, unsigned long MyObj) 
{ 
	obj.checkknownobject(myptr, ptr, key, cp, OtherObj, MyObj); 
	return 0; 
} 
 
void charmap::removeuserobj(unsigned int cp, DWORD ptr, unsigned long ObjectId) 
{ 
	char bufremobj[8]; 
	char* buf_ptr = bufremobj; 
	int8 opcode = g_sc_deleteuserobject; 
 
	unsigned char unk[] = { 0x02, 0x00, 0xDF }; 
 
	memcpy(buf_ptr,(char*)&opcode,1); 
	buf_ptr+=1; 
	memcpy(buf_ptr,(char*)&ObjectId,4); 
	buf_ptr+=4; 
	memcpy(buf_ptr,(char*)&unk,3); 
 
	sendpacket( bufremobj, 8, ptr ); 
	obj.removeknownobject(cp, ObjectId); 
} 
 
int charmap::sendatkpack(DWORD ptr, unsigned int cp, unsigned long oobj, unsigned long myobj) 
{ 
	Attack.sendAttackToAll(ptr, cp, myobj, oobj); 
	return 0; 
} 
 
void charmap::sendskillpack(DWORD ptr, unsigned int cp, unsigned long myobj, unsigned long tobj, int8 type, int16 typez) 
{ 
	int8 opcode = g_sc_chareffect; 
	unsigned char unknown[] = { 0x00, 0x00 }; 
 
	char buftime[8]; 
	char* buf_ptr = buftime; 
	memcpy(buf_ptr,(char*)&opcode,1); 
	buf_ptr+=1; 
	memcpy(buf_ptr,(char*)&myobj,4); 
	buf_ptr+=4; 
	memcpy(buf_ptr,(char*)&type,1); 
	buf_ptr+=1; 
	memcpy(buf_ptr,(char*)&unknown,2); 
	sendpacket( buftime, 8, ptr ); 
 
	opcode = g_sc_skilleffect; 
	unsigned char unknownz[] = { 0x00 }; 
 
	char buftimez[8]; 
	char* buf_ptrz = buftimez; 
	memcpy(buf_ptrz,(char*)&opcode,1); 
	buf_ptrz+=1; 
	memcpy(buf_ptrz,(char*)&tobj,4); 
	buf_ptrz+=4; 
	memcpy(buf_ptrz,(char*)&typez,2); 
	buf_ptrz+=2; 
	memcpy(buf_ptrz,(char*)&unknownz,1); 
	sendpacket( buftimez, 8, ptr ); 
}