Small progress with vehicles

This commit is contained in:
tomrus88 2008-11-12 00:49:19 +03:00
parent 204b61c220
commit 871d5f8c99
18 changed files with 175 additions and 21 deletions

View file

@ -31,6 +31,7 @@
#include "Language.h"
#include "MapManager.h"
#include <fstream>
#include "ObjectMgr.h"
bool ChatHandler::HandleDebugInArcCommand(const char* /*args*/)
{
@ -518,3 +519,45 @@ bool ChatHandler::HandleGetItemState(const char* args)
return true;
}
bool ChatHandler::HandleSpawnVehicle(const char* args)
{
if(!args)
return false;
char* e = strtok((char*)args, " ");
char* i = strtok(NULL, " ");
if (!e || !i)
return false;
uint32 entry = (uint32)atoi(e);
uint32 id = (uint32)atoi(i);
// TODO: check entry, id...
Vehicle *v = new Vehicle;
Map *map = m_session->GetPlayer()->GetMap();
if(!v->Create(objmgr.GenerateLowGuid(HIGHGUID_VEHICLE), map, entry, id, m_session->GetPlayer()->GetTeam()))
{
delete v;
return false;
}
float px, py, pz;
m_session->GetPlayer()->GetClosePoint(px, py, pz, m_session->GetPlayer()->GetObjectSize());
v->Relocate(px, py, pz, m_session->GetPlayer()->GetOrientation());
if(!v->IsPositionValid())
{
sLog.outError("ERROR: Vehicle (guidlow %d, entry %d) not created. Suggested coordinates isn't valid (X: %f Y: %f)",
v->GetGUIDLow(), v->GetEntry(), v->GetPositionX(), v->GetPositionY());
delete v;
return false;
}
map->Add((Creature*)v);
return true;
}