init
This commit is contained in:
4183
server/LogicServer/script/export/ActorExportFun.cpp
Normal file
4183
server/LogicServer/script/export/ActorExportFun.cpp
Normal file
File diff suppressed because it is too large
Load Diff
388
server/LogicServer/script/export/CScriptDataPacket.cpp
Normal file
388
server/LogicServer/script/export/CScriptDataPacket.cpp
Normal file
@@ -0,0 +1,388 @@
|
||||
#include "StdAfx.h"
|
||||
namespace DataPack
|
||||
{
|
||||
static CBufferAllocator g_DataPackAllocator;
|
||||
|
||||
void * allocPacket(void* pEntity,int nSystemID,int nCmdID)
|
||||
{
|
||||
|
||||
if(pEntity == NULL || ((CEntity *)pEntity)->GetType() != enActor) return NULL ;
|
||||
CActorPacket &pack = ((CActor*)pEntity)->GetFastPacket();
|
||||
//if(pack.packet != NULL) return NULL;
|
||||
((CActor*)pEntity)->AllocPacket(pack); // 把网关协议头写进去
|
||||
|
||||
/*
|
||||
保存指针以便在角色申请数据包后出现脚本错误从而无法flush数据包的时候回收数据包,
|
||||
如果脚本出错且数据包没有被回收,则会导致整个游戏引擎就此不能正常工作
|
||||
*/
|
||||
CLogicScript::ScriptActorPacket = &pack;
|
||||
|
||||
pack.packet->operator << ((BYTE)nSystemID);
|
||||
pack.packet->operator << ((BYTE)nCmdID);
|
||||
return &pack;
|
||||
}
|
||||
|
||||
void* allocPacketEx()
|
||||
{
|
||||
CDataPacket *pPack = (CDataPacket *)g_DataPackAllocator.AllocBuffer(sizeof(CDataPacket));
|
||||
if (pPack)
|
||||
new (pPack)CDataPacket(CEnvirConfig::m_pAllocator);
|
||||
|
||||
CActorPacket* pActorPack = (CActorPacket *)g_DataPackAllocator.AllocBuffer(sizeof(CActorPacket));
|
||||
pActorPack->packet = pPack;
|
||||
return pActorPack;
|
||||
}
|
||||
|
||||
void freePacketEx(void* pack)
|
||||
{
|
||||
CActorPacket* pActorPacket = (CActorPacket *)pack;
|
||||
if (!pActorPacket) return;
|
||||
CDataPacket* pPack = pActorPacket->packet;
|
||||
if (pPack)
|
||||
{
|
||||
pPack->~CDataPacket();
|
||||
g_DataPackAllocator.FreeBuffer(pPack);
|
||||
}
|
||||
pActorPacket->packet = NULL;
|
||||
g_DataPackAllocator.FreeBuffer(pActorPacket);
|
||||
}
|
||||
|
||||
void flush(void* pActorPacket)
|
||||
{
|
||||
if(pActorPacket ==NULL) return;
|
||||
((CActorPacket*)pActorPacket)->flush();
|
||||
((CActorPacket*)pActorPacket)->packet = NULL;
|
||||
//标记逻辑脚本申请的数据包已回收!
|
||||
CLogicScript::ScriptActorPacket = NULL;
|
||||
}
|
||||
|
||||
void flushCs(void *packet)
|
||||
{
|
||||
if (packet == NULL) return;
|
||||
CLogicSSClient *pSSClient = GetLogicServer()->GetSessionClient();
|
||||
CDataPacket &data = pSSClient->allocProtoPacket(jxInterSrvComm::SessionServerProto::cSendGroupMessage);
|
||||
data << (WORD)jxInterSrvComm::SessionServerProto::fcScriptData;
|
||||
CActorPacket *pPacket = (CActorPacket *)packet;
|
||||
data.writeBuf(pPacket->packet->getMemoryPtr(), pPacket->packet->getLength());
|
||||
pSSClient->flushProtoPacket(data);
|
||||
}
|
||||
|
||||
int broadcastScene(void* pActorPacket, unsigned int fbHandle, int nSceneId)
|
||||
{
|
||||
if(pActorPacket ==NULL) return 0;
|
||||
if(((CActorPacket*)pActorPacket)->packet == NULL) return 0;
|
||||
CDataPacket& data = *((CActorPacket*)pActorPacket)->packet;
|
||||
|
||||
if (CFuBen *pFb = CFuBenManager::m_FuBenMgr->GetDataPtr(fbHandle))
|
||||
{
|
||||
if(CScene *pScene = pFb->GetScene(nSceneId))
|
||||
pScene->Broadcast(data.getMemoryPtr(),data.getPosition());
|
||||
}
|
||||
}
|
||||
|
||||
void broadcasetWorld(void* packet, int nLevel, int nCircle)
|
||||
{
|
||||
if (packet)
|
||||
{
|
||||
CActorPacket* pPack = (CActorPacket *)packet;
|
||||
GetGlobalLogicEngine()->GetEntityMgr()->BroadCast(pPack->packet->getMemoryPtr(), pPack->packet->getPosition(), nLevel, nCircle);
|
||||
}
|
||||
}
|
||||
|
||||
void writeString(void * pActorPacket,const char *str)
|
||||
{
|
||||
if(pActorPacket ==NULL) return;
|
||||
const char* sResutl = str;
|
||||
if ( str == NULL )
|
||||
{
|
||||
sResutl = "";
|
||||
}
|
||||
*((CActorPacket*)pActorPacket)->packet << sResutl;
|
||||
}
|
||||
char* readString(void * pPack)
|
||||
{
|
||||
if(pPack ==NULL) return NULL;
|
||||
LPCSTR result;
|
||||
*((CDataPacket*)pPack) >> result;
|
||||
return (char*)result;
|
||||
}
|
||||
unsigned char readByte(void * pPack)
|
||||
{
|
||||
unsigned char bResult = 0;
|
||||
if(pPack ==NULL) return 0;
|
||||
((CDataPacket*)pPack)->operator >> (bResult);
|
||||
return bResult;
|
||||
}
|
||||
|
||||
|
||||
char readChar(void * pPack)
|
||||
{
|
||||
char cResult = 0;
|
||||
if(pPack ==NULL) return 0;
|
||||
((CDataPacket*)pPack)->operator >> (cResult);
|
||||
return cResult;
|
||||
}
|
||||
|
||||
unsigned short readWord(void * pPack)
|
||||
{
|
||||
unsigned short wValue = 0;
|
||||
if(pPack ==NULL) return wValue;
|
||||
((CDataPacket*)pPack)->operator >> (wValue);
|
||||
return wValue;
|
||||
}
|
||||
short readShort(void * pPack)
|
||||
{
|
||||
short wValue = 0;
|
||||
if(pPack ==NULL) return wValue;
|
||||
((CDataPacket*)pPack)->operator >> (wValue);
|
||||
return wValue;
|
||||
}
|
||||
int readInt(void * pPack)
|
||||
{
|
||||
int nValue = 0;
|
||||
if(pPack ==NULL) return nValue;
|
||||
((CDataPacket*)pPack)->operator >> (nValue);
|
||||
return nValue;
|
||||
}
|
||||
unsigned int readUInt(void * pPack)
|
||||
{
|
||||
unsigned int uValue = 0;
|
||||
if(pPack ==NULL) return uValue;
|
||||
((CDataPacket*)pPack)->operator >> (uValue);
|
||||
return uValue;
|
||||
}
|
||||
double readUint64(void * pPack)
|
||||
{
|
||||
unsigned long long lValue = 0;
|
||||
double d=0;
|
||||
if(pPack ==NULL) return d;
|
||||
((CDataPacket*)pPack)->operator >> (lValue);
|
||||
|
||||
memcpy(&d,&lValue,sizeof(lValue));
|
||||
return d;
|
||||
}
|
||||
double readInt64(void * pPack)
|
||||
{
|
||||
long long lValue = 0;
|
||||
double d=0;
|
||||
if(pPack ==NULL) return d;
|
||||
((CDataPacket*)pPack)->operator >> (lValue);
|
||||
memcpy(&d,&lValue,sizeof(lValue));
|
||||
return d;
|
||||
}
|
||||
|
||||
int readData( lua_State *L )
|
||||
{
|
||||
CDataPacket* pack = (CDataPacket*)lua_touserdata(L,1);
|
||||
if (!pack) return 0;
|
||||
int nParamCount = (int)lua_tointeger(L,2);
|
||||
for (int i = 0,index=3; i < nParamCount; i++,index++)
|
||||
{
|
||||
int dt = (int)lua_tointeger(L,index);
|
||||
switch (dt)
|
||||
{
|
||||
case dtByte:
|
||||
{
|
||||
BYTE b = 0;
|
||||
(*pack) >> b;
|
||||
lua_pushinteger(L,b);
|
||||
break;
|
||||
}
|
||||
case dtChar:
|
||||
{
|
||||
char b = 0;
|
||||
(*pack) >> b;
|
||||
lua_pushinteger(L,b);
|
||||
break;
|
||||
}
|
||||
case dtWord:
|
||||
{
|
||||
WORD b = 0;
|
||||
(*pack) >> b;
|
||||
lua_pushinteger(L,b);
|
||||
break;
|
||||
}
|
||||
case dtShort:
|
||||
{
|
||||
short b = 0;
|
||||
(*pack) >> b;
|
||||
lua_pushinteger(L,b);
|
||||
break;
|
||||
}
|
||||
case dtInt:
|
||||
{
|
||||
int b = 0;
|
||||
(*pack) >> b;
|
||||
lua_pushinteger(L,b);
|
||||
break;
|
||||
}
|
||||
case dtUint:
|
||||
{
|
||||
unsigned int b = 0;
|
||||
(*pack) >> b;
|
||||
lua_pushinteger(L,b);
|
||||
break;
|
||||
}
|
||||
case dtString:
|
||||
{
|
||||
const char* b = NULL;
|
||||
(*pack) >> b;
|
||||
lua_pushstring(L,b);
|
||||
break;
|
||||
}
|
||||
case dtInt64:
|
||||
{
|
||||
long long b = 0;
|
||||
(*pack) >> b;
|
||||
double d = 0;
|
||||
memcpy(&d,&b,sizeof(b));
|
||||
lua_pushnumber(L,d);
|
||||
break;
|
||||
}
|
||||
case dtUint64:
|
||||
{
|
||||
unsigned long long b = 0;
|
||||
(*pack) >> b;
|
||||
double d = 0;
|
||||
memcpy(&d,&b,sizeof(b));
|
||||
lua_pushnumber(L,d);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return nParamCount;
|
||||
}
|
||||
|
||||
void writeByte(void * pActorPacket, unsigned char btValue)
|
||||
{
|
||||
if(pActorPacket ==NULL) return;
|
||||
((CActorPacket*)pActorPacket)->packet->operator << (btValue);
|
||||
}
|
||||
void writeChar(void * pActorPacket , char cValue)
|
||||
{
|
||||
if(pActorPacket ==NULL) return;
|
||||
((CActorPacket*)pActorPacket)->packet->operator << (cValue);
|
||||
}
|
||||
void writeWord(void * pActorPacket,unsigned short wValue)
|
||||
{
|
||||
if(pActorPacket ==NULL) return;
|
||||
((CActorPacket*)pActorPacket)->packet->operator << (wValue);
|
||||
}
|
||||
void writeShort(void * pActorPacket, short wValue)
|
||||
{
|
||||
if(pActorPacket ==NULL) return;
|
||||
((CActorPacket*)pActorPacket)->packet->operator << (wValue);
|
||||
}
|
||||
void writeInt(void * pActorPacket,int nValue)
|
||||
{
|
||||
if(pActorPacket ==NULL) return;
|
||||
((CActorPacket*)pActorPacket)->packet->operator << (nValue);
|
||||
}
|
||||
void writeUInt(void * pActorPacket,unsigned int uValue)
|
||||
{
|
||||
if(pActorPacket ==NULL) return;
|
||||
((CActorPacket*)pActorPacket)->packet->operator << (uValue);
|
||||
}
|
||||
void writeUint64(void * pActorPacket,double d)
|
||||
{
|
||||
if(pActorPacket ==NULL) return;
|
||||
unsigned long long lValue = 0;
|
||||
// lValue = static_cast<unsigned long long>(d);
|
||||
memcpy(&lValue,&d,sizeof(d));
|
||||
((CActorPacket*)pActorPacket)->packet->operator << (lValue);
|
||||
}
|
||||
void writeInt64(void * pActorPacket,double d )
|
||||
{
|
||||
if(pActorPacket ==NULL) return;
|
||||
long long lValue = 0;
|
||||
memcpy(&lValue,&d,sizeof(d));
|
||||
// lValue = static_cast<long long>(d);
|
||||
((CActorPacket*)pActorPacket)->packet->operator << (lValue);
|
||||
}
|
||||
|
||||
int writeData( lua_State *L )
|
||||
{
|
||||
CActorPacket* packet = (CActorPacket*)lua_touserdata(L,1);
|
||||
if (!packet) return 0;
|
||||
int nParamCount = (int)lua_tointeger(L,2);
|
||||
for (int i = 0,index=3; i < nParamCount; i++,index+=2)
|
||||
{
|
||||
int dt = (int)lua_tointeger(L,index);
|
||||
switch (dt)
|
||||
{
|
||||
case dtByte:
|
||||
{
|
||||
int b = (int)lua_tointeger(L,index+1);
|
||||
(*packet) << (BYTE)b;
|
||||
break;
|
||||
}
|
||||
case dtChar:
|
||||
{
|
||||
int b = (int)lua_tointeger(L,index+1);
|
||||
(*packet) << (char)b;
|
||||
break;
|
||||
}
|
||||
case dtWord:
|
||||
{
|
||||
int b = (int)lua_tointeger(L,index+1);
|
||||
(*packet) << (WORD)b;
|
||||
break;
|
||||
}
|
||||
case dtShort:
|
||||
{
|
||||
int b = (int)lua_tointeger(L,index+1);
|
||||
(*packet) << (short)b;
|
||||
break;
|
||||
}
|
||||
case dtInt:
|
||||
{
|
||||
int b = (int)lua_tointeger(L,index+1);
|
||||
(*packet) << (int)b;
|
||||
break;
|
||||
}
|
||||
case dtUint:
|
||||
{
|
||||
int b = (int)lua_tointeger(L,index+1);
|
||||
(*packet) << (unsigned int)b;
|
||||
break;
|
||||
}
|
||||
case dtString:
|
||||
{
|
||||
const char* b = lua_tostring(L,index+1);
|
||||
packet->packet->writeString(b);
|
||||
break;
|
||||
}
|
||||
case dtInt64:
|
||||
{
|
||||
double d = (double)lua_tonumber(L,index+1);
|
||||
long long b = 0;
|
||||
memcpy(&b,&d,sizeof(d));
|
||||
(*packet) << (long long)b;
|
||||
break;
|
||||
}
|
||||
case dtUint64:
|
||||
{
|
||||
double d = (double)lua_tonumber(L,index+1);
|
||||
long long b = 0;
|
||||
memcpy(&b,&d,sizeof(d));
|
||||
(*packet) << (unsigned long long)b;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void broadGuild(void* packet, int nGuildId)
|
||||
{
|
||||
if (packet)
|
||||
{
|
||||
CActorPacket* pPack = (CActorPacket *)packet;
|
||||
CGuild* pGuild = GetGlobalLogicEngine()->GetGuildMgr().FindGuild(nGuildId);
|
||||
if (pGuild)
|
||||
{
|
||||
pGuild->SendData(pPack->packet->getMemoryPtr(), pPack->packet->getPosition());
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
1197
server/LogicServer/script/export/FubenExportFun.cpp
Normal file
1197
server/LogicServer/script/export/FubenExportFun.cpp
Normal file
File diff suppressed because it is too large
Load Diff
483
server/LogicServer/script/export/GuildExportFun.cpp
Normal file
483
server/LogicServer/script/export/GuildExportFun.cpp
Normal file
@@ -0,0 +1,483 @@
|
||||
#include "StdAfx.h"
|
||||
#include "../interface/GuildExportFun.h"
|
||||
|
||||
namespace Guild
|
||||
{
|
||||
|
||||
char* getGuildName(unsigned int nGuidID)
|
||||
{
|
||||
CGuild * pGuild = GetGlobalLogicEngine()->GetGuildMgr().FindGuild(nGuidID);
|
||||
if(NULL ==pGuild )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
return pGuild->m_sGuildname;
|
||||
}
|
||||
}
|
||||
|
||||
void* getGuildLeader( unsigned int nGuildID )
|
||||
{
|
||||
// CGuild * pGuild = GetGlobalLogicEngine()->GetGuildMgr().FindGuild(nGuildID);
|
||||
// if(NULL ==pGuild )
|
||||
// {
|
||||
// return NULL;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// if (!pGuild->m_nLeaderId) return NULL;
|
||||
// CEntity* pEntity = GetGlobalLogicEngine()->GetEntityMgr()->GetEntity(pGuild->m_pLeader->hActorHandle);
|
||||
// if (pEntity && pEntity->GetType() == enActor)
|
||||
// {
|
||||
// return pEntity;
|
||||
// }
|
||||
// }
|
||||
return NULL;
|
||||
}
|
||||
|
||||
unsigned int getGuildLeaderId( unsigned int nGuildID )
|
||||
{
|
||||
CGuild * pGuild = GetGlobalLogicEngine()->GetGuildMgr().FindGuild(nGuildID);
|
||||
if(NULL ==pGuild )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return pGuild->m_nLeaderId;
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool changeGuildFr( unsigned int nGuildId, int nFrVar )
|
||||
{
|
||||
CGuild *pGuild = GetGlobalLogicEngine()->GetGuildMgr().FindGuild(nGuildId);
|
||||
if(pGuild)
|
||||
{
|
||||
pGuild->SetGuildFr(nFrVar);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool changeGuildCoin( unsigned int nGuildId, int nCoinVar, int nLogId,const char* pStr)
|
||||
{
|
||||
CGuild* pGuild = GetGlobalLogicEngine()->GetGuildMgr().FindGuild(nGuildId);
|
||||
if(pGuild)
|
||||
{
|
||||
pGuild->ChangeGuildCoin(nCoinVar, nLogId,pStr);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
const char* getGuildLeaderName( unsigned int nGuildId )
|
||||
{
|
||||
CGuild* pGuild = GetGlobalLogicEngine()->GetGuildMgr().FindGuild(nGuildId);
|
||||
if(pGuild)
|
||||
{
|
||||
if(pGuild->m_nLeaderId)
|
||||
{
|
||||
return pGuild->FindGuildMemberName(pGuild->m_nLeaderId);
|
||||
}
|
||||
else
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int getGuildMemberNum(unsigned int nGuildId)
|
||||
{
|
||||
CGuild* pGuild = GetGlobalLogicEngine()->GetGuildMgr().FindGuild(nGuildId);
|
||||
if(pGuild)
|
||||
{
|
||||
return (int)(pGuild->GetMemberCount());
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned int getCityOwnMasterId()
|
||||
{
|
||||
return GetGlobalLogicEngine()->GetGuildMgr().GetCityOwnMasterId();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// 震天龙弹
|
||||
unsigned int getThunderPower(unsigned int nGuildId)
|
||||
{
|
||||
CGuild* pGuild = GetGlobalLogicEngine()->GetGuildMgr().FindGuild(nGuildId);
|
||||
if(pGuild)
|
||||
{
|
||||
return pGuild->m_nThunderPower;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void setThunderPower(unsigned int nGuildId, unsigned int nValue)
|
||||
{
|
||||
CGuild* pGuild = GetGlobalLogicEngine()->GetGuildMgr().FindGuild(nGuildId);
|
||||
if(pGuild)
|
||||
{
|
||||
pGuild->m_nThunderPower = nValue;
|
||||
pGuild->m_boUpdateTime = true;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int getFillThunderTimes(unsigned int nGuildId)
|
||||
{
|
||||
CGuild* pGuild = GetGlobalLogicEngine()->GetGuildMgr().FindGuild(nGuildId);
|
||||
if(pGuild)
|
||||
{
|
||||
return pGuild->m_nFillThunderTimes;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void setFillThunderTimes(unsigned int nGuildId, unsigned int nValue)
|
||||
{
|
||||
CGuild* pGuild = GetGlobalLogicEngine()->GetGuildMgr().FindGuild(nGuildId);
|
||||
if(pGuild)
|
||||
{
|
||||
pGuild->m_nFillThunderTimes = nValue;
|
||||
pGuild->m_boUpdateTime = true;
|
||||
}
|
||||
}
|
||||
|
||||
bool isGuildSiegeStart()
|
||||
{
|
||||
return GetGlobalLogicEngine()->GetGuildMgr().IsGuildSiegeStart();
|
||||
}
|
||||
|
||||
void autoSignGuildSiege()
|
||||
{
|
||||
GetGlobalLogicEngine()->GetGuildMgr().AutoSignGuildSiege();
|
||||
}
|
||||
|
||||
//下发行会战指挥面板到全体参战的成员
|
||||
void sendGuildSiegeCmdPanel(unsigned char nFlag)
|
||||
{
|
||||
GetGlobalLogicEngine()->GetGuildMgr().SendGuildSiegeCmdPanel(nFlag);
|
||||
}
|
||||
|
||||
//会长下发指令
|
||||
void setGuildSiegeCommand(void* pEntity, int nGuildId, int nCmdIdx, int nCmdMsgIdx)
|
||||
{
|
||||
if (!pEntity || ((CEntity *)pEntity)->GetType() != enActor) return;
|
||||
CGuild* pGuild = GetGlobalLogicEngine()->GetGuildMgr().FindGuild(nGuildId);
|
||||
if(pGuild)
|
||||
{
|
||||
pGuild->SetGuildSiegeCommand((CActor*)pEntity, nCmdIdx, nCmdMsgIdx);
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int getGuildSiegeCommandTime(int nGuildId)
|
||||
{
|
||||
CGuild* pGuild = GetGlobalLogicEngine()->GetGuildMgr().FindGuild(nGuildId);
|
||||
if(pGuild)
|
||||
{
|
||||
return pGuild->GetGuildSiegeCommandTime();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void resetSignGuildsiege()
|
||||
{
|
||||
GetGlobalLogicEngine()->GetGuildMgr().ResetSignGuildsiege();
|
||||
}
|
||||
|
||||
void clearGuildSiegeCommand()
|
||||
{
|
||||
GetGlobalLogicEngine()->GetGuildMgr().ClearGuildSiegeCommand();
|
||||
}
|
||||
|
||||
bool isGuildSiegeTodayOpen()
|
||||
{
|
||||
return GetGlobalLogicEngine()->GetGuildMgr().IsGuildSiegeTodayOpen();
|
||||
}
|
||||
void startGuildSiege()
|
||||
{
|
||||
GetGlobalLogicEngine()->GetGuildMgr().StartGuildSiege();
|
||||
}
|
||||
void guildSiegeEnd(unsigned int nGuildId)
|
||||
{
|
||||
GetGlobalLogicEngine()->GetGuildMgr().GuildSiegeEnd(nGuildId);
|
||||
}
|
||||
|
||||
char* getCityPostionInfo(int nPos,int &nJob,int &nSex)
|
||||
{
|
||||
return GetGlobalLogicEngine()->GetGuildMgr().GetCityPostionInfo(nPos,nJob,nSex);
|
||||
}
|
||||
void clearGuildSiegeData()
|
||||
{
|
||||
GetGlobalLogicEngine()->GetGuildMgr().ClearGuildSiegeData();
|
||||
}
|
||||
|
||||
bool isLimitGuildCoin(unsigned int nGuildId)
|
||||
{
|
||||
CGuildComponent& guildMgr = GetGlobalLogicEngine()->GetGuildMgr();
|
||||
CGuild* pGuild = guildMgr.FindGuild(nGuildId);
|
||||
if (!pGuild)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void sendGuildMsg(unsigned int nGuildId, char* szMsg,int nLevel, int nCircle)
|
||||
{
|
||||
CGuild* pGuild = GetGlobalLogicEngine()->GetGuildMgr().FindGuild(nGuildId);
|
||||
if (!pGuild)
|
||||
{
|
||||
return;
|
||||
}
|
||||
pGuild->BroadCastMsgInGuildChannel(szMsg, nLevel, nCircle);
|
||||
}
|
||||
|
||||
|
||||
void getUpgradeItemCount(unsigned int nGuildId, int& nItemCount1,int& nItemCount2, int& nItemCount3)
|
||||
{
|
||||
CGuild* pGuild = GetGlobalLogicEngine()->GetGuildMgr().FindGuild(nGuildId);
|
||||
if (!pGuild)
|
||||
{
|
||||
nItemCount1 = -1;
|
||||
nItemCount2 = -1;
|
||||
nItemCount3 = -1;
|
||||
return;
|
||||
}
|
||||
return pGuild->GetUpgradeItemCount(nItemCount1, nItemCount2, nItemCount3);
|
||||
}
|
||||
|
||||
void setUpgradeItemCount(unsigned int nGuildId, int nItemCount1,int nItemCount2, int nItemCount3)
|
||||
{
|
||||
CGuild* pGuild = GetGlobalLogicEngine()->GetGuildMgr().FindGuild(nGuildId);
|
||||
if (!pGuild)
|
||||
{
|
||||
return;
|
||||
}
|
||||
pGuild->SetUpgradeItemCount(nItemCount1, nItemCount2, nItemCount3);
|
||||
}
|
||||
|
||||
void getGuildTreeData(unsigned int nGuildId, int &nTreeLevel, int &nTreeDegree)
|
||||
{
|
||||
CGuild* pGuild = GetGlobalLogicEngine()->GetGuildMgr().FindGuild(nGuildId);
|
||||
if (!pGuild)
|
||||
{
|
||||
return;
|
||||
}
|
||||
return pGuild->GetGuildTreeData(nTreeLevel, nTreeDegree);
|
||||
}
|
||||
|
||||
void setGuildTreeData(unsigned int nGuildId, int nTreeLevel, int nTreeDegree)
|
||||
{
|
||||
CGuild* pGuild = GetGlobalLogicEngine()->GetGuildMgr().FindGuild(nGuildId);
|
||||
if (!pGuild)
|
||||
{
|
||||
return;
|
||||
}
|
||||
pGuild->SetGuildTreeData(nTreeLevel, nTreeDegree);
|
||||
}
|
||||
|
||||
unsigned int getGuildTreeFruitTime(unsigned int nGuildId)
|
||||
{
|
||||
CGuild* pGuild = GetGlobalLogicEngine()->GetGuildMgr().FindGuild(nGuildId);
|
||||
if (!pGuild)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return pGuild->GetGuildTreeFruitTime();
|
||||
}
|
||||
|
||||
void setGuildTreeFruitTime(unsigned int nGuildId, unsigned int nFruitTime)
|
||||
{
|
||||
CGuild* pGuild = GetGlobalLogicEngine()->GetGuildMgr().FindGuild(nGuildId);
|
||||
if (!pGuild)
|
||||
{
|
||||
return;
|
||||
}
|
||||
pGuild->SetGuildTreeFruitTime(nFruitTime);
|
||||
}
|
||||
|
||||
void getGuildFruitData(unsigned int nGuildId, int &nGuildFruitLevel, int &nGuildFruitDegree, int &nGuildFruitNum)
|
||||
{
|
||||
CGuild* pGuild = GetGlobalLogicEngine()->GetGuildMgr().FindGuild(nGuildId);
|
||||
if (!pGuild)
|
||||
{
|
||||
return;
|
||||
}
|
||||
return pGuild->GetGuildFruitData(nGuildFruitLevel, nGuildFruitDegree, nGuildFruitNum);
|
||||
}
|
||||
|
||||
void setGuildFruitData(unsigned int nGuildId, int nGuildFruitLevel, int nGuildFruitDegree, int nGuildFruitNum)
|
||||
{
|
||||
CGuild* pGuild = GetGlobalLogicEngine()->GetGuildMgr().FindGuild(nGuildId);
|
||||
if (!pGuild)
|
||||
{
|
||||
return;
|
||||
}
|
||||
pGuild->SetGuildFruitData(nGuildFruitLevel, nGuildFruitDegree, nGuildFruitNum);
|
||||
}
|
||||
|
||||
|
||||
void* getGuildPtr(unsigned int nGuildId)
|
||||
{
|
||||
return GetGlobalLogicEngine()->GetGuildMgr().FindGuild(nGuildId);
|
||||
}
|
||||
void getGuildMemberBasicData(void* pGuild, unsigned int nActorId, int &nSex, int &nJob)
|
||||
{
|
||||
if (!pGuild)
|
||||
{
|
||||
return;
|
||||
}
|
||||
((CGuild*)pGuild)->GetGuildMemberBasicData(nActorId, nSex, nJob);
|
||||
}
|
||||
int getGuildMemberIdList(lua_State* L)
|
||||
{
|
||||
CGuild* pGuild = (CGuild*)lua_touserdata(L, 1);
|
||||
CVector<unsigned int> pIdList;
|
||||
pIdList.clear();
|
||||
if (pGuild)
|
||||
{
|
||||
int nSize = pGuild->m_ActorOffLine.size();
|
||||
for(int i = 0; i < nSize; i++)
|
||||
{
|
||||
ActorCommonNode& Node = pGuild->m_ActorOffLine[i];
|
||||
pIdList.add(Node.BasicData.nActorId);
|
||||
}
|
||||
if (pIdList.count() > 0)
|
||||
{
|
||||
LuaHelp::PushNumberVector(L,&(pIdList[0]),pIdList.count());
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
int getGuildOnlineMemberList( lua_State *L )
|
||||
{
|
||||
CGuild* pGuild = (CGuild*)lua_touserdata(L, 1);
|
||||
CVector<void*> pEntityList;
|
||||
pEntityList.clear();
|
||||
if (pGuild)
|
||||
{
|
||||
CEntityManager* pEntityMgr = GetGlobalLogicEngine()->GetEntityMgr();
|
||||
CLinkedNode<EntityHandle> *pNode;
|
||||
CLinkedListIterator<EntityHandle> it(pGuild->m_ActorOnLine);
|
||||
for (pNode = it.first(); pNode; pNode = it.next())
|
||||
{
|
||||
EntityHandle& hHandle = pNode->m_Data;
|
||||
CEntity* pEntity = pEntityMgr->GetEntity(hHandle);
|
||||
if (pEntity && pEntity->GetType() == enActor)
|
||||
{
|
||||
pEntityList.add((void*)pEntity);
|
||||
}
|
||||
}
|
||||
if (pEntityList.count() > 0)
|
||||
{
|
||||
LuaHelp::PushDataPointerToTable(L,(void**)pEntityList,pEntityList.count());
|
||||
}
|
||||
else
|
||||
{
|
||||
LuaHelp::PushDataPointerToTable(L,NULL,0);
|
||||
}
|
||||
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
void setCityOwnGuildId(unsigned int nGuildId)
|
||||
{
|
||||
GetGlobalLogicEngine()->GetGuildMgr().SetCityOwnGuildId(nGuildId);
|
||||
}
|
||||
|
||||
//获取皇城职位
|
||||
unsigned int getCityPostionById(unsigned int nActorId)
|
||||
{
|
||||
return GetGlobalLogicEngine()->GetGuildMgr().getCityPostionById(nActorId);
|
||||
}
|
||||
|
||||
unsigned int getCityOwnGuildId()
|
||||
{
|
||||
return GetGlobalLogicEngine()->GetGuildMgr().GetCityOwnGuildId();
|
||||
}
|
||||
unsigned int getPalaceOccoupyTime()
|
||||
{
|
||||
return 0;//GetGlobalLogicEngine()->GetGuildMgr().m_OccupyTime;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void procGuildTreeToSapling()
|
||||
{
|
||||
GetGlobalLogicEngine()->GetGuildMgr().ProcGuildTreeToSapling();
|
||||
}
|
||||
|
||||
void procGuildDailyData()
|
||||
{
|
||||
GetGlobalLogicEngine()->GetGuildMgr().ProcDailyData();
|
||||
}
|
||||
|
||||
|
||||
void getGuildTaskData(unsigned int nGuildId, int &nTaskId, int &nTaskSche)
|
||||
{
|
||||
CGuild* pGuild = GetGlobalLogicEngine()->GetGuildMgr().FindGuild(nGuildId);
|
||||
if (!pGuild)
|
||||
{
|
||||
return;
|
||||
}
|
||||
pGuild->GetGuildTaskData(nTaskId, nTaskSche);
|
||||
}
|
||||
|
||||
int getDailyGuildCoinDonated(unsigned int nGuildId)
|
||||
{
|
||||
CGuild* pGuild = GetGlobalLogicEngine()->GetGuildMgr().FindGuild(nGuildId);
|
||||
if (!pGuild)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return pGuild->GetDailyGuildCoinDonated();
|
||||
}
|
||||
|
||||
void addDailyGuildCoinDonated(unsigned int nGuildId, int nAddGuildCoin)
|
||||
{
|
||||
CGuild* pGuild = GetGlobalLogicEngine()->GetGuildMgr().FindGuild(nGuildId);
|
||||
if (!pGuild)
|
||||
{
|
||||
return;
|
||||
}
|
||||
pGuild->AddDailyGuildCoinDonated(nAddGuildCoin);
|
||||
}
|
||||
|
||||
void guildBroadCastMsg(void* packet, void* guildPtr, int nLevel, int nCircle)
|
||||
{
|
||||
if (packet && guildPtr)
|
||||
{
|
||||
CGuild* pGuild = (CGuild*)guildPtr;
|
||||
CActorPacket* pPack = (CActorPacket *)packet;
|
||||
pGuild->BroadCast(pPack->packet->getMemoryPtr(), pPack->packet->getPosition(), nLevel, nCircle);
|
||||
}
|
||||
}
|
||||
|
||||
void sendMemberList(void* pEntity, unsigned int nActorId)
|
||||
{
|
||||
if (!pEntity || ((CEntity *)pEntity)->GetType() != enActor) return;
|
||||
CActor* pActor = (CActor*)pEntity;
|
||||
pActor->GetGuildSystem()->SendMemberList(nActorId);
|
||||
}
|
||||
|
||||
void setSbkGuildId(unsigned int nGuildId)
|
||||
{
|
||||
int guildId = GetGlobalLogicEngine()->GetGuildMgr().GetCityOwnGuildId();
|
||||
if(guildId != nGuildId)
|
||||
GetGlobalLogicEngine()->GetGuildMgr().SetCityOwnGuildId(nGuildId);
|
||||
}
|
||||
};
|
||||
181
server/LogicServer/script/export/HeroExportFun.cpp
Normal file
181
server/LogicServer/script/export/HeroExportFun.cpp
Normal file
@@ -0,0 +1,181 @@
|
||||
#include "StdAfx.h"
|
||||
#include "../interface/HeroExportFun.h"
|
||||
namespace Hero
|
||||
{
|
||||
|
||||
int addHero(void* pEntity,int nHeroId, int nStage, int nLevel)
|
||||
{
|
||||
if(pEntity == NULL || ((CEntity *)pEntity)->GetType() != enActor) return -1;
|
||||
return ((CActor *)pEntity)->GetHeroSystem().AddHero(nHeroId,nStage, nLevel);
|
||||
}
|
||||
|
||||
bool canAddHero(void *pEntity, bool bWithTipmsg)
|
||||
{
|
||||
if(pEntity == NULL || ((CEntity *)pEntity)->GetType() != enActor) return false;
|
||||
return ((CActor *)pEntity)->GetHeroSystem().CanAddHero(bWithTipmsg);
|
||||
}
|
||||
|
||||
bool StageUp(void *pEntity, int nHeroId,int nStage, int nBless)
|
||||
{
|
||||
if(pEntity == NULL || ((CEntity *)pEntity)->GetType() != enActor) return false;
|
||||
return ((CActor *)pEntity)->GetHeroSystem().StageUp(nHeroId,nStage,nBless);
|
||||
}
|
||||
|
||||
unsigned int getHeroProperty(void *pEntity,int nHeroId, int nPropId)
|
||||
{
|
||||
if(pEntity == NULL || ((CEntity *)pEntity)->GetType() != enActor) return -1;
|
||||
const CHeroSystem::HERODATA * pHero = ((CActor *)pEntity)->GetHeroSystem().GetHeroData(nHeroId);
|
||||
if(pHero ==NULL)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
switch ( nPropId)
|
||||
{
|
||||
case enHeroStage:
|
||||
return pHero->data.bStage;
|
||||
case enHeroLevel:
|
||||
return pHero->data.bLevel;
|
||||
break;
|
||||
case enHeroExp:
|
||||
return (unsigned int)pHero->data.nExp;
|
||||
break;
|
||||
case enHeroBless:
|
||||
return pHero->data.nBless;
|
||||
case enHeroForce:
|
||||
return pHero->data.nBodyforce;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//设置英雄属性
|
||||
bool setHeroProperty(void *pEntity,int nHeroId, int nPropId,unsigned int nValue)
|
||||
{
|
||||
if(pEntity == NULL || ((CEntity *)pEntity)->GetType() != enActor) return false;
|
||||
CHeroSystem::HERODATA * pHero = ((CActor *)pEntity)->GetHeroSystem().GetHeroData(nHeroId);
|
||||
if(pHero ==NULL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
switch ( nPropId)
|
||||
{
|
||||
case enHeroStage:
|
||||
pHero->data.bStage = (BYTE)nValue;
|
||||
((CActor *)pEntity)->GetHeroSystem().SendHeroData(*pHero);
|
||||
((CActor *)pEntity)->GetHeroSystem(). SetHeroDataModifyFlag(0,true);
|
||||
return true;
|
||||
case enHeroLevel:
|
||||
pHero->data.bLevel = (BYTE)nValue;
|
||||
((CActor *)pEntity)->GetHeroSystem().SendHeroData(*pHero);
|
||||
((CActor *)pEntity)->GetHeroSystem(). SetHeroDataModifyFlag(0,true);
|
||||
return true;
|
||||
case enHeroExp:
|
||||
pHero->data.nExp = nValue;
|
||||
((CActor *)pEntity)->GetHeroSystem().SendHeroData(*pHero);
|
||||
((CActor *)pEntity)->GetHeroSystem(). SetHeroDataModifyFlag(0,true);
|
||||
return true;
|
||||
case enHeroBless:
|
||||
pHero->data.nBless = (int)nValue;
|
||||
((CActor *)pEntity)->GetHeroSystem().SendHeroData(*pHero);
|
||||
((CActor *)pEntity)->GetHeroSystem(). SetHeroDataModifyFlag(0,true);
|
||||
return true;
|
||||
case enHeroForce:
|
||||
pHero->data.nBodyforce = (int)nValue;
|
||||
((CActor *)pEntity)->GetHeroSystem().SendHeroData(*pHero);
|
||||
((CActor *)pEntity)->GetHeroSystem(). SetHeroDataModifyFlag(0,true);
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool learnSkill(void *pEntity,int nHeroID, int nSkillID)
|
||||
{
|
||||
if(pEntity == NULL || ((CEntity *)pEntity)->GetType() != enActor) return false;
|
||||
return ((CActor *)pEntity)->GetHeroSystem().LearnSkill(nHeroID,nSkillID);
|
||||
}
|
||||
|
||||
int getSkillLevel(void* pEntity,int nHeroId, int nSkillId)
|
||||
{
|
||||
if(pEntity == NULL || ((CEntity *)pEntity)->GetType() != enActor) return 0;
|
||||
return ((CActor *)pEntity)->GetHeroSystem().GetSkillLevel(nHeroId,nSkillId);
|
||||
}
|
||||
bool skillLevelUp(void *pEntity,int nHeroID, int nSkillID )
|
||||
{
|
||||
if(pEntity == NULL || ((CEntity *)pEntity)->GetType() != enActor) return false;
|
||||
return ((CActor *)pEntity)->GetHeroSystem().SkillLevelUp(nHeroID,nSkillID);
|
||||
}
|
||||
|
||||
int getBattleHeroId(void * pEntity)
|
||||
{
|
||||
if(pEntity == NULL || ((CEntity *)pEntity)->GetType() != enActor) return -1;
|
||||
return ((CActor *)pEntity)->GetHeroSystem().GetBattleHeroId();
|
||||
}
|
||||
|
||||
void sendHeroOpResult(void * pEntity,int nHeroId,int nOpId, bool result)
|
||||
{
|
||||
if(pEntity == NULL || ((CEntity *)pEntity)->GetType() != enActor) return ;
|
||||
CActor *pActor = (CActor *)pEntity;
|
||||
if( pActor &&pActor->IsInited() )
|
||||
{
|
||||
CActorPacket pack;
|
||||
pActor->AllocPacket(pack);
|
||||
pack << (BYTE)(enHeroSystemId)<< (BYTE) sHeroOpResult;
|
||||
pack << (BYTE)(nOpId) ;
|
||||
pack << (BYTE) nHeroId;
|
||||
if(result)
|
||||
{
|
||||
pack <<(BYTE)1;
|
||||
}
|
||||
else
|
||||
{
|
||||
pack <<(BYTE)0;
|
||||
}
|
||||
pack.flush();
|
||||
}
|
||||
}
|
||||
|
||||
void setHeroBattle(void* pEntity, int nHeroId)
|
||||
{
|
||||
if(pEntity == NULL || ((CEntity *)pEntity)->GetType() != enActor) return ;
|
||||
((CActor *)pEntity)->GetHeroSystem().SetHeroBattle(nHeroId);
|
||||
}
|
||||
|
||||
char * getHeroName(void * pEntity ,int nHeroId)
|
||||
{
|
||||
if(pEntity == NULL || ((CEntity *)pEntity)->GetType() != enActor) return NULL;
|
||||
const CHeroSystem::HERODATA * pHero = ((CActor *)pEntity)->GetHeroSystem().GetHeroData(nHeroId);
|
||||
if(pHero ==NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
return (char*)(pHero->data.name);
|
||||
}
|
||||
|
||||
int getHeroCount(void * pEntity)
|
||||
{
|
||||
if (pEntity == NULL || ((CEntity *)pEntity)->GetType() != enActor) return 0;
|
||||
return (int)((CActor *)pEntity)->GetHeroSystem().GetHeroCount();
|
||||
}
|
||||
|
||||
void addExp(void *pEntity, unsigned int nExp , int nHeroId )
|
||||
{
|
||||
if (pEntity == NULL || ((CEntity *)pEntity)->GetType() != enActor) return;
|
||||
((CActor *)pEntity)->GetHeroSystem().OnAddExp(nExp,false, nHeroId);
|
||||
}
|
||||
|
||||
void addExpByHeroId(void *pEntity, int nHeroId, unsigned int nExp)
|
||||
{
|
||||
if (pEntity == NULL || ((CEntity *)pEntity)->GetType() != enActor) return;
|
||||
INT_PTR nPos = ((CActor *)pEntity)->GetHeroSystem().GetHeroPos(nHeroId);
|
||||
((CActor *)pEntity)->GetHeroSystem().RealChangeExp(nPos,nExp);
|
||||
}
|
||||
|
||||
void CallBackHero(void *pEntity,bool boClient)
|
||||
{
|
||||
if (pEntity == NULL || ((CEntity *)pEntity)->GetType() != enActor) return;
|
||||
((CActor *)pEntity)->GetHeroSystem().CallbackBattleHero(boClient);
|
||||
}
|
||||
}
|
||||
59
server/LogicServer/script/export/IntMap.cpp
Normal file
59
server/LogicServer/script/export/IntMap.cpp
Normal file
@@ -0,0 +1,59 @@
|
||||
#include "StdAfx.h"
|
||||
#include "../interface/IntMap.h"
|
||||
|
||||
int IntMap::GetLen() const
|
||||
{
|
||||
return (int)m_vecData.size();
|
||||
}
|
||||
|
||||
void IntMap::Add( tagIntMapPair& Data )
|
||||
{
|
||||
m_vecData.push_back(Data);
|
||||
}
|
||||
|
||||
void IntMap::Add(int Key,int Value,int Value2)
|
||||
{
|
||||
tagIntMapPair data(Key, Value,Value2);
|
||||
Add(data);
|
||||
}
|
||||
|
||||
tagIntMapPair IntMap::GetData( unsigned int nIndex ) const
|
||||
{
|
||||
if(nIndex >= 0 && nIndex < m_vecData.size())
|
||||
return m_vecData[nIndex];
|
||||
return tagIntMapPair(-1,-1);
|
||||
}
|
||||
|
||||
|
||||
tagIntMapPair IntMap::operator[]( unsigned int nIndex ) const
|
||||
{
|
||||
if(nIndex >= 0 && nIndex < m_vecData.size())
|
||||
return m_vecData[nIndex];
|
||||
return tagIntMapPair(-1,-1);
|
||||
}
|
||||
|
||||
void IntMap::clear()
|
||||
{
|
||||
m_vecData.clear();
|
||||
}
|
||||
|
||||
tagIntMapPair IntMap::GetDataHead()
|
||||
{
|
||||
return m_vecData.front();
|
||||
}
|
||||
|
||||
void IntMap::SetData( unsigned int nIndex, tagIntMapPair& Data )
|
||||
{
|
||||
if(nIndex >= 0 && nIndex < m_vecData.size())
|
||||
m_vecData[nIndex] = Data;
|
||||
}
|
||||
|
||||
IntMap &IntMap::operator = ( const IntMap &intMap )
|
||||
{
|
||||
int len = intMap.GetLen();
|
||||
for(int i = 0; i < len; ++i)
|
||||
{
|
||||
m_vecData.push_back(intMap.GetData(i));
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
936
server/LogicServer/script/export/ItemExportFun.cpp
Normal file
936
server/LogicServer/script/export/ItemExportFun.cpp
Normal file
@@ -0,0 +1,936 @@
|
||||
#include "StdAfx.h"
|
||||
#include "../interface/ItemExportFun.h"
|
||||
namespace Item
|
||||
{
|
||||
void sendItemProcessResult(void * pEntity, void* pUserItem,int nProceccType,bool bResult,bool bAutoOperate)
|
||||
{
|
||||
/* if(pEntity == NULL || ((CEntity *)pEntity)->GetType() != enActor) return;
|
||||
|
||||
CUserItem::ItemSeries itemGuid;
|
||||
if (pUserItem != NULL)
|
||||
{
|
||||
itemGuid = ((CUserItem*) pUserItem)->series;
|
||||
}
|
||||
else
|
||||
{
|
||||
itemGuid.llId = 0;
|
||||
}
|
||||
|
||||
CActorPacket pack;
|
||||
CDataPacket & data = ((CActor*)pEntity)->AllocPacket(pack);
|
||||
data << (BYTE) enBagSystemID << (BYTE) sNotifyItemProcessResult << itemGuid << (BYTE)nProceccType;
|
||||
|
||||
if(bResult)
|
||||
{
|
||||
data << (BYTE)1;
|
||||
}
|
||||
else
|
||||
{
|
||||
data << (BYTE)0;
|
||||
}
|
||||
|
||||
if (bAutoOperate)
|
||||
{
|
||||
data << (BYTE)1;
|
||||
}
|
||||
else
|
||||
{
|
||||
data << (BYTE)0;
|
||||
}
|
||||
|
||||
pack.flush();*/
|
||||
}
|
||||
|
||||
double getItemGuid(void * pItem)
|
||||
{
|
||||
CUserItem * pUserItem = (CUserItem *) pItem;
|
||||
if(pUserItem ==NULL) return 0;
|
||||
double d;
|
||||
memcpy(&d,&pUserItem->series.llId,sizeof(d));
|
||||
return d;
|
||||
}
|
||||
|
||||
char* getItemGuidStr(void *pItem)
|
||||
{
|
||||
static char strGuid[32];
|
||||
CUserItem * pUserItem = (CUserItem *)pItem;
|
||||
if(pUserItem == NULL)
|
||||
{
|
||||
strGuid[0]= '\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(strGuid, "%llu", pUserItem->series.llId);
|
||||
}
|
||||
|
||||
return strGuid;
|
||||
}
|
||||
|
||||
void sendItemProcessConsume(void * pEntity,void * pUserItem, int nProcessType,int nItemID,int nCount, int nMoneyType,int nMoneyCount, int nProtectItemID, int nProtectCount)
|
||||
{
|
||||
/*if(pEntity == NULL || ((CEntity *)pEntity)->GetType() != enActor) return;
|
||||
CActorPacket pack;
|
||||
CDataPacket & data = ((CActor*)pEntity)->AllocPacket(pack);
|
||||
data << (BYTE) enBagSystemID << (BYTE) sNotifyItemProcessConsume ;
|
||||
data << ((CUserItem*)pUserItem)->series ;
|
||||
data<< (BYTE )nCount << (BYTE)nMoneyType << (int)nMoneyCount<<(WORD)(nItemID) << (WORD)(nProtectItemID)<< (BYTE)nProtectCount <<(BYTE) nProcessType;
|
||||
pack.flush();*/
|
||||
}
|
||||
|
||||
|
||||
bool setItemProperty(void * pEntity, void* pUserItem,int nPropertyID,int nValue)
|
||||
{
|
||||
if(pEntity == NULL || ((CEntity *)pEntity)->GetType() != enActor) return false;
|
||||
if(pUserItem ==NULL) return false;
|
||||
//int nAuxValue;
|
||||
//装备的锻造的属性是特殊处理的
|
||||
/*
|
||||
if(nPropertyID != Item::ipItemForge)
|
||||
{
|
||||
if(GetItemProperty(pEntity,pUserItem ,nPropertyID,nAuxValue) == nValue) return false;//没有改变
|
||||
}
|
||||
*/
|
||||
|
||||
return ((CActor *)pEntity)->GetBagSystem().SetItemProperty((CUserItem*)pUserItem,nPropertyID,nValue);
|
||||
}
|
||||
|
||||
int getItemProperty(void * pEntity,void * pItem, int propID,int &nAuxRetValue)
|
||||
{
|
||||
if(propID <0 || propID >=ipItemMaxProperty ) return 0;
|
||||
if(pItem ==NULL) return 0;
|
||||
nAuxRetValue =0;
|
||||
CUserItem * pUserItem = (CUserItem *) pItem;
|
||||
|
||||
if(pUserItem == NULL) return 0;
|
||||
const CStdItem * pStdItem;
|
||||
// const CStdItem::ItemUseCondition *pCond;
|
||||
//PACKEDGAMEATTR attr;
|
||||
//INT_PTR nValue;
|
||||
//是静态属性
|
||||
if(propID >= ipItemStaticPropStart && propID < ipItemMaxProperty)
|
||||
{
|
||||
return getItemPropertyById(pUserItem->wItemId,propID);
|
||||
}
|
||||
switch(propID)
|
||||
{
|
||||
case ipItemID:
|
||||
return pUserItem->wItemId;
|
||||
break;
|
||||
case ipItemCount:
|
||||
return pUserItem->wCount;
|
||||
break;
|
||||
case ipItemStrong:
|
||||
return pUserItem->btStrong;
|
||||
break;
|
||||
case ipItemQuality:
|
||||
return pUserItem->btQuality;
|
||||
break;
|
||||
|
||||
case ipItemBind:
|
||||
return pUserItem->btFlag;
|
||||
break;
|
||||
case ipItemType:
|
||||
pStdItem =GetLogicServer()->GetDataProvider()->GetStdItemProvider().GetStdItem(pUserItem->wItemId);
|
||||
if(pStdItem ==NULL) return 0;
|
||||
return pStdItem->m_btType;
|
||||
break;
|
||||
case ipItemHole1IsOpen://宝石槽位1是否开启
|
||||
return 0;
|
||||
break;
|
||||
|
||||
case ipItemHole2IsOpen: //宝石槽位2是否开启
|
||||
return 0;
|
||||
break;
|
||||
|
||||
case ipItemHole3IsOpen: //宝石槽位3是否开启
|
||||
return 0;
|
||||
break;
|
||||
case ipItemHole4IsOpen: //宝石槽位3是否开启
|
||||
return 0;
|
||||
break;
|
||||
|
||||
case ipItemHole1Item://宝石槽位1的物品
|
||||
return 0;
|
||||
break;
|
||||
case ipItemHole2Item://宝石槽位2的物品
|
||||
return 0;
|
||||
break;
|
||||
case ipItemHole3Item://宝石槽位3的物品
|
||||
return 0;
|
||||
break;
|
||||
case ipItemHole4Item://宝石槽位4的物品
|
||||
return 0;
|
||||
break;
|
||||
/*
|
||||
case ipItemForgeTimes:
|
||||
return pUserItem->btSmithCount;
|
||||
break;
|
||||
*/
|
||||
case ipItemForgeProperty1Value:
|
||||
return (int)pUserItem->smithAttrs[0].nValue;
|
||||
break;
|
||||
case ipItemForgeProperty2Value:
|
||||
return (int)pUserItem->smithAttrs[1].nValue;
|
||||
break;
|
||||
case ipItemForgeProperty3Value:
|
||||
return (int)pUserItem->smithAttrs[2].nValue;
|
||||
break;
|
||||
case ipItemDua:
|
||||
return 0;
|
||||
break;
|
||||
case ipItemDuaMax:
|
||||
return 0;
|
||||
break;
|
||||
//随机精锻
|
||||
case ipItemRandForge:
|
||||
return 1;
|
||||
break;
|
||||
case ipItemForgeProtect:
|
||||
return 1;
|
||||
case ipItemLuck:
|
||||
return (int)pUserItem->btLuck;
|
||||
case ipItemSharp:
|
||||
return (int)pUserItem->btSharp;
|
||||
case ipItemLostStar:
|
||||
return pUserItem->bLostStar;
|
||||
case ipItemStar:
|
||||
return pUserItem->wStar;
|
||||
case ipIdentifySlotNum: //鉴定属性槽被解锁的数量(默认为1)
|
||||
if( pUserItem->wIdentifySlotNum <= 0 )
|
||||
{
|
||||
pUserItem->wIdentifySlotNum = 1;
|
||||
}
|
||||
return pUserItem->wIdentifySlotNum;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void * createItem(int nItemID,int nCount,int nStar, int nLostStar, int bInSourceType, int nAreaId, int nBind, int ntime)
|
||||
{
|
||||
CUserItem* pUserItem = GetLogicServer()->GetLogicEngine()->AllocUserItem(true); //新的物品
|
||||
if(pUserItem ==NULL) return NULL;
|
||||
|
||||
|
||||
//通过物品ID查找物品配置对象
|
||||
const CStdItem *pStdItem = GetLogicServer()->GetDataProvider()->GetStdItemProvider().GetStdItem(nItemID);
|
||||
if ( !pStdItem )
|
||||
return NULL;
|
||||
pUserItem->wCount = (WORD)nCount;
|
||||
pUserItem->wItemId = (WORD) nItemID;
|
||||
pUserItem->btFlag =(BYTE) nBind;
|
||||
pUserItem->btQuality =(BYTE) 0;
|
||||
pUserItem->btStrong = (BYTE) 0;
|
||||
pUserItem->wStar = nStar;
|
||||
pUserItem->bLostStar = nLostStar;
|
||||
pUserItem->bInSourceType = bInSourceType;
|
||||
pUserItem->nAreaId = nAreaId;
|
||||
CStdItem::AssignInstance (pUserItem,pStdItem) ;
|
||||
if (ntime > 0)
|
||||
{
|
||||
pUserItem->nCreatetime = ntime;
|
||||
pUserItem->nCreatetime.startRecord(GetLogicServer()->GetLogicEngine()->getMiniDateTime());
|
||||
}
|
||||
//产生极品属性
|
||||
/* CUserItemContainer::ItemOPParam ItemPara;
|
||||
ItemPara.wItemId = (WORD) nItemID;
|
||||
ItemPara.btQuality =(BYTE) 0;
|
||||
ItemPara.wStar = (WORD) nStrong;
|
||||
ItemPara.wCount =(WORD)nCount;
|
||||
ItemPara.btBindFlag = (BYTE) nBind;
|
||||
ItemPara.nLeftTime = nLeftTime;*/
|
||||
//RandAttrSelector::InitSmithById(ItemPara.wItemId, ItemPara.btQuality, nQualityDataIndex, ItemPara.nSmith);
|
||||
|
||||
/*for (int i=0; i < ArrayCount(ItemPara.nSmith); i++)
|
||||
{
|
||||
pUserItem->smithAttrs[i].nValue = ItemPara.nSmith[i];
|
||||
}*/
|
||||
|
||||
return (void *)pUserItem;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int addItem(void *pEntity,void *pItem,char * comment,int nLogWay,int nItemCount,int bNotice)
|
||||
{
|
||||
if(pEntity == NULL || ((CEntity *)pEntity)->GetType() != enActor) return 0;
|
||||
CUserItem * pUserItem = (CUserItem * ) pItem;
|
||||
if(pUserItem == NULL ) return 0;
|
||||
if(nItemCount >0)
|
||||
{
|
||||
pUserItem->wCount = (WORD) nItemCount;
|
||||
}
|
||||
return (int)(((CActor *)pEntity)->GetBagSystem().AddItem((CUserItem*)pItem,comment,nLogWay, true, true, bNotice));
|
||||
}
|
||||
|
||||
int removeItem(void *pEntity,void *pItem,int nCount, char * sComment,int nLogID,bool bNeedFreeMemory)
|
||||
{
|
||||
if(pEntity == NULL || ((CEntity *)pEntity)->GetType() != enActor) return 0;
|
||||
if(pItem == NULL || pItem ==NULL) return 0;
|
||||
return (int)(((CActor *)pEntity)->GetBagSystem().DeleteItem((CUserItem*)pItem,nCount,sComment,nLogID,bNeedFreeMemory));
|
||||
}
|
||||
|
||||
int removeItemDura(void *pEntity,void *pItem,int nCount, char * sComment,int nLogID,bool bNeedFreeMemory)
|
||||
{
|
||||
if(pEntity == NULL || ((CEntity *)pEntity)->GetType() != enActor) return 0;
|
||||
if(pItem == NULL || pItem ==NULL) return 0;
|
||||
return (int)(((CActor *)pEntity)->GetBagSystem().RemoveItemDura((CUserItem*)pItem,nCount,sComment,nLogID,bNeedFreeMemory));
|
||||
}
|
||||
|
||||
int removeOtherItem(void *pEntity,void *pItem,int nCount, char * sComment,int nLogID,bool bNeedFreeMemory, bool bReqSB)
|
||||
{
|
||||
if(pEntity == NULL || ((CEntity *)pEntity)->GetType() != enActor) return 0;
|
||||
if(pItem == NULL || pItem ==NULL) return 0;
|
||||
return (int)(((CActor *)pEntity)->GetBagSystem().DeleteOtherItem((CUserItem*)pItem,nCount,sComment,nLogID,bNeedFreeMemory,bReqSB));
|
||||
}
|
||||
|
||||
int removeItemByType(void* pEntity, int nType, bool bIncEquipBar, char * sComment,int nLogID)
|
||||
{
|
||||
if (!pEntity || ((CEntity*)pEntity)->GetType() != enActor)
|
||||
return 0;
|
||||
|
||||
CActor* pActor = (CActor *)pEntity;
|
||||
INT_PTR nRemovedCnt = pActor->GetBagSystem().RemoveItemByType(nType, sComment, nLogID);
|
||||
if (bIncEquipBar)
|
||||
nRemovedCnt += pActor->GetEquipmentSystem().RemoveItemByType(nType, sComment, nLogID);
|
||||
return (int)nRemovedCnt;
|
||||
}
|
||||
|
||||
int removeEquip(void* pEntity, void* pItem, const char* sComment, int nLogId, bool bIncHero)
|
||||
{
|
||||
if (!pEntity || !pItem || ((CEntity*)pEntity)->GetType() != enActor)
|
||||
return 0;
|
||||
|
||||
CActor* pActor = (CActor *)pEntity;
|
||||
CUserEquipment &equipSys = pActor->GetEquipmentSystem();
|
||||
INT_PTR idx = equipSys.FindIndex(((CUserItem *)pItem)->series);
|
||||
int nResult = 0;
|
||||
if(idx >=0) //人物装备
|
||||
{
|
||||
nResult = equipSys.DeleteEquip((int)idx, sComment, nLogId);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bIncHero)
|
||||
{
|
||||
//遍历英雄
|
||||
CVector<CHeroSystem::HERODATA> &heros = pActor->GetHeroSystem().GetHeroList();
|
||||
for (INT_PTR i = 0; i < heros.count(); i++)
|
||||
{
|
||||
bool boResult = false;
|
||||
CHeroEquip *pEquips = &(heros[i].equips);
|
||||
CUserItem *pUserItem = pEquips->GetEquipByGuid(((CUserItem *)pItem)->series);
|
||||
if (pUserItem)
|
||||
{
|
||||
if (pEquips->DirectRemoveEquip(pActor,pUserItem,sComment,nLogId,true))
|
||||
{
|
||||
boResult = true;
|
||||
nResult++;
|
||||
}
|
||||
}
|
||||
if (boResult)
|
||||
{
|
||||
pActor->GetHeroSystem().ResetProperty(i, false,true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return nResult;
|
||||
|
||||
}
|
||||
|
||||
void* getItemByType(void* pEntity, int nType, bool bIncEquipBar, bool &bInEquipBar)
|
||||
{
|
||||
if (!pEntity || ((CEntity*)pEntity)->GetType() != enActor)
|
||||
return NULL;
|
||||
|
||||
CActor* pActor = (CActor *)pEntity;
|
||||
CUserItem* pItem = pActor->GetBagSystem().GetItemByType(nType);
|
||||
bInEquipBar = false;
|
||||
if (!pItem && bIncEquipBar)
|
||||
{
|
||||
pItem = pActor->GetEquipmentSystem().GetItemByType(nType);
|
||||
if (pItem)
|
||||
bInEquipBar = true;
|
||||
}
|
||||
|
||||
return pItem;
|
||||
}
|
||||
|
||||
const char* getItemLinkMsg( int nItemID,void * pUserItem )
|
||||
{
|
||||
return CUserBag::GetItemLink(nItemID,(CUserItem*)pUserItem);
|
||||
}
|
||||
|
||||
const char * getAwardDesc(int nAwardType,int nAwardId, bool useChatLink,void *pUserItem )
|
||||
{
|
||||
return CActor::GetAwardTypeDesc(nAwardType,nAwardId,useChatLink,(CUserItem*)pUserItem);
|
||||
}
|
||||
|
||||
int getItemPropertyById(int nItemID,int nPropID)
|
||||
{
|
||||
|
||||
const CStdItem *pStdItem =GetLogicServer()->GetDataProvider()->GetStdItemProvider().GetStdItem(nItemID);
|
||||
if(pStdItem ==NULL) return 0;
|
||||
|
||||
int nConditionID =0 ;
|
||||
switch(nPropID)
|
||||
{
|
||||
case ipItemType:
|
||||
return pStdItem->m_btType;
|
||||
break;
|
||||
case ipItemDealMoneyType://物品卖商店的金钱的类型
|
||||
return pStdItem->m_btDealType;
|
||||
break;
|
||||
case ipItemDealMoneyCount://物品卖商店的金钱的数量
|
||||
return pStdItem->m_nPrice;
|
||||
break;
|
||||
// case ipItemStaticDuaMax: //物品的最大耐久
|
||||
// return pStdItem->m_dwDura;
|
||||
// break;
|
||||
case ipItemSuitId: //套装ID
|
||||
return pStdItem->m_wSuitID;
|
||||
break;
|
||||
case ipItemBreakId:
|
||||
return pStdItem->m_nRecoverId;
|
||||
break;
|
||||
case ipItemForgeMaxTimes: //精锻的最大次数
|
||||
return 1;
|
||||
break;
|
||||
case ipItemDenyStorage: //是否禁止放仓库
|
||||
return pStdItem->m_Flags.denyStorage?1:0;
|
||||
break;
|
||||
case ipItemDenySell: //是否禁止放商店
|
||||
return pStdItem->m_Flags.denySell?1:0;
|
||||
break;
|
||||
// case ipItemInlayable: //是否能够镶嵌宝石
|
||||
// return pStdItem->m_Flags.inlayable?1:0;
|
||||
// break;
|
||||
// case ipItemNotConsumeForCircleForge: //转生锻造时不需要副装备
|
||||
// return pStdItem->m_Flags.notConsumeForCircleForge?1:0;
|
||||
// break;
|
||||
case ipItemNeedVocation: //需要的职业,0表示无职业要求
|
||||
nConditionID =CStdItem::ItemUseCondition::ucJob;
|
||||
break;
|
||||
//玩家的精锻的配置id
|
||||
// case ipItemSmithId:
|
||||
// return (int) pStdItem->m_btSmithId;
|
||||
// break;
|
||||
case ipItemShape:
|
||||
return (int)pStdItem->m_wShape;
|
||||
break;
|
||||
case ipItemNeedSex: //物品需要的性别
|
||||
nConditionID =CStdItem::ItemUseCondition::ucGender;
|
||||
break;
|
||||
case ipItemActorLevel:
|
||||
nConditionID =CStdItem::ItemUseCondition::ucLevel;
|
||||
break;
|
||||
case ipItemMatchAllSuite:
|
||||
return pStdItem->m_Flags.matchAllSuit?1:0;
|
||||
break;
|
||||
// case ipItemSpecialRingType:
|
||||
// return pStdItem->b_specRing;
|
||||
// break;
|
||||
// case ipItemStrongCount:
|
||||
// return (int)pStdItem->m_StrongCount;
|
||||
// break;
|
||||
case ipItemActorCircle:
|
||||
nConditionID = CStdItem::ItemUseCondition::ucMinCircle;
|
||||
break;
|
||||
case ipItemDenyGuildDepot: //是否禁止放行会仓库
|
||||
return pStdItem->m_Flags.denyGuildDepot?1:0;
|
||||
break;
|
||||
// case ipItemCanIdentify: //是否可以被鉴定
|
||||
// return pStdItem->m_Flags.bCanIdentify? 1:0;
|
||||
// break;
|
||||
}
|
||||
|
||||
|
||||
if( nConditionID)
|
||||
{
|
||||
for (INT_PTR i=pStdItem->m_Conditions.nCount-1; i>-1; --i)
|
||||
{
|
||||
CStdItem::ItemUseCondition& condit = pStdItem->m_Conditions.pConds[i];
|
||||
if(condit.btCond ==nConditionID)
|
||||
{
|
||||
return condit.nValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int getEquipCount(void * pEntity)
|
||||
{
|
||||
if(pEntity == NULL || ((CEntity *)pEntity)->GetType() != enActor) return 0;
|
||||
return (int)(((CActor*)pEntity)->GetEquipmentSystem().GetEquipCount());
|
||||
}
|
||||
|
||||
|
||||
void* getEquipBySortID(void * pEntity,int nSortID)
|
||||
{
|
||||
if(pEntity == NULL || ((CEntity *)pEntity)->GetType() != enActor) return NULL;
|
||||
return (void*) (((CActor*)pEntity)->GetEquipmentSystem().GetEquipBySortID(nSortID));
|
||||
}
|
||||
|
||||
int getBagItemCount(void * pEntity)
|
||||
{
|
||||
if(pEntity == NULL || ((CEntity *)pEntity)->GetType() != enActor) return 0;
|
||||
return (int)(((CActor*)pEntity)->GetBagSystem().count());
|
||||
}
|
||||
|
||||
|
||||
|
||||
void * getBagItemBySortID(void * pEntity,int nSortID)
|
||||
{
|
||||
if(pEntity == NULL || ((CEntity *)pEntity)->GetType() != enActor) return NULL;
|
||||
if(nSortID <=0 || nSortID > ((CActor*)pEntity)->GetBagSystem().count() )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
return (void*)((CActor*)pEntity)->GetBagSystem()[nSortID-1];
|
||||
}
|
||||
|
||||
void * getBagItemPtrById(void * pEntity,int lItemId, int nQuality , int nStrong)
|
||||
{
|
||||
if(pEntity == NULL || ((CEntity *)pEntity)->GetType() != enActor) return NULL;
|
||||
return (void*)((CActor*)pEntity)->GetBagSystem().FindItem(lItemId, nQuality, nStrong);
|
||||
}
|
||||
|
||||
void * getBagItemPtrByGuid(void * pEntity,double lItemGuid)
|
||||
{
|
||||
if(pEntity == NULL || ((CEntity *)pEntity)->GetType() != enActor) return NULL;
|
||||
CUserItem::ItemSeries series;
|
||||
|
||||
memcpy(&series.llId,&lItemGuid,sizeof(lItemGuid));
|
||||
//series.llId = lItemGuid;
|
||||
return (void*)((CActor*)pEntity)->GetBagSystem().FindItemByGuid(series);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void * getEquipPtrByGuid(void *pEntity, double lItemGuid)
|
||||
{
|
||||
if(pEntity == NULL || ((CEntity *)pEntity)->GetType() != enActor) return NULL;
|
||||
CUserItem::ItemSeries series;
|
||||
//series.llId = lItemGuid;
|
||||
memcpy(&series.llId,&lItemGuid,sizeof(lItemGuid));
|
||||
return (void*) (((CActor*)pEntity)->GetEquipmentSystem().GetEquipByGuid(series));
|
||||
}
|
||||
|
||||
void * getEquipItemPtr(void *pEntity, double lItemGuid, int &nItemPos, int &nHeroId, int nEntityId)
|
||||
{
|
||||
if(pEntity == NULL || ((CEntity *)pEntity)->GetType() != enActor) return NULL;
|
||||
CUserItem::ItemSeries series;
|
||||
//series.llId = lItemGuid;
|
||||
memcpy(&series.llId,&lItemGuid,sizeof(lItemGuid));
|
||||
|
||||
return (void*) (((CActor*)pEntity)->GetBagSystem().GetEquipItemPtr(series, nItemPos, nHeroId, nEntityId));
|
||||
}
|
||||
|
||||
void releaseItemPtr(void * pItem)
|
||||
{
|
||||
CUserItem * pUserItem = (CUserItem*)pItem;
|
||||
if(pUserItem ==NULL) return;
|
||||
GetGlobalLogicEngine()->DestroyUserItem(pUserItem);
|
||||
}
|
||||
|
||||
|
||||
int getBagEmptyGridCount(void *pEntity, int type)
|
||||
{
|
||||
if(pEntity == NULL || ((CEntity *)pEntity)->GetType() != enActor) return 0;
|
||||
return (int)(((CActor * )pEntity)->GetBagSystem().availableCount(type));
|
||||
}
|
||||
|
||||
int getAllBagMinEmptyGridCount(void *pEntity)
|
||||
{
|
||||
if(pEntity == NULL || ((CEntity *)pEntity)->GetType() != enActor) return 0;
|
||||
return (int)(((CActor * )pEntity)->GetBagSystem().availableMinCount());
|
||||
}
|
||||
|
||||
bool bagIsEnough(void *pEntity,int nType){
|
||||
if(pEntity == NULL || ((CEntity *)pEntity)->GetType() != enActor) return 0;
|
||||
return ((CActor * )pEntity)->GetBagSystem().bagIsEnough(nType);
|
||||
}
|
||||
|
||||
|
||||
int getAddItemNeedGridCount(void *pEntity,int nItemID, int nItemCount,int nQuality,
|
||||
int nStrong, int nBind, int nParam)
|
||||
{
|
||||
if(pEntity == NULL || ((CEntity *)pEntity)->GetType() != enActor) return 0;
|
||||
CUserItemContainer::ItemOPParam param;
|
||||
if (nItemID > 0)
|
||||
{
|
||||
param.wItemId =(WORD) nItemID;
|
||||
param.wCount =(WORD) nItemCount;
|
||||
param.btQuality =(BYTE) nQuality;
|
||||
param.btStrong = (BYTE) nStrong;
|
||||
param.btBindFlag =(BYTE) nBind;
|
||||
}
|
||||
else
|
||||
{
|
||||
//param = *(CUserItemContainer::ItemOPParam *)nParam;
|
||||
return 0;
|
||||
}
|
||||
return (int)(((CActor * )pEntity)->GetBagSystem().GetAddItemNeedGridCount(param));
|
||||
}
|
||||
|
||||
int getItemStaticAttrById(int nItemId, int nAttrType){
|
||||
const CStdItem *pStdItem =GetLogicServer()->GetDataProvider()->GetStdItemProvider().GetStdItem(nItemId);
|
||||
if(pStdItem ==NULL) return -1;
|
||||
for(INT_PTR i = 0; i < pStdItem->m_StaticAttrs.nCount; ++i){
|
||||
GAMEATTR& attr = pStdItem->m_StaticAttrs.pAttrs[i];
|
||||
if ( nAttrType == attr.type){
|
||||
return attr.value.nValue;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int getItemPackageTyp(int nItemId)
|
||||
{
|
||||
const CStdItem *pStdItem =GetLogicServer()->GetDataProvider()->GetStdItemProvider().GetStdItem(nItemId);
|
||||
if(pStdItem ==NULL) return NULL;
|
||||
return pStdItem->m_nPackageType;
|
||||
}
|
||||
|
||||
char * getItemName(int nItemId)
|
||||
{
|
||||
const CStdItem *pStdItem =GetLogicServer()->GetDataProvider()->GetStdItemProvider().GetStdItem(nItemId);
|
||||
if(pStdItem ==NULL) return NULL;
|
||||
return (char *)pStdItem->m_sName;
|
||||
}
|
||||
|
||||
bool addSellItem(void * pEntity, void * itemPtr, int nItemCount)
|
||||
{
|
||||
if(itemPtr ==NULL || pEntity == NULL || ((CEntity *)pEntity)->GetType() != enActor) return false;
|
||||
((CUserItem*) itemPtr)->wCount =(WORD) nItemCount;
|
||||
return (((CActor * )pEntity)->GetBagSystem().AddSellItem((CUserItem*) itemPtr));
|
||||
}
|
||||
|
||||
|
||||
bool delSellItem(void * pEntity, void * pItem)
|
||||
{
|
||||
if(pItem ==NULL || pEntity == NULL || ((CEntity *)pEntity)->GetType() != enActor) return false;
|
||||
return (((CActor * )pEntity)->GetBagSystem().DelSellItem((CUserItem*) pItem));
|
||||
}
|
||||
|
||||
|
||||
|
||||
void * getSellItem(void * pEntity, double lItemGuid)
|
||||
{
|
||||
if( pEntity == NULL || ((CEntity *)pEntity)->GetType() != enActor) return NULL;
|
||||
unsigned long long guid;
|
||||
memcpy(&guid, &lItemGuid,sizeof(guid));
|
||||
return (void *)(((CActor * )pEntity)->GetBagSystem().GetSellItem( guid));
|
||||
}
|
||||
|
||||
//ZGame不使用
|
||||
bool isForgeItem( void* itemPtr )
|
||||
{
|
||||
return false;
|
||||
//return itemPtr && ((CUserItem*)itemPtr)->btSmithCount > 0;
|
||||
}
|
||||
|
||||
bool isStrongLevel( void* pEntity,int nLevel )
|
||||
{
|
||||
if( pEntity == NULL || ((CEntity *)pEntity)->GetType() != enActor) return false;
|
||||
return ((CActor*)pEntity)->GetBagSystem().IsStrongLevel(nLevel) || ((CActor*)pEntity)->GetEquipmentSystem().IsStrongLevel(nLevel);
|
||||
}
|
||||
|
||||
/*ZGame不使用
|
||||
bool hasForgeItem( void* pEntity )
|
||||
{
|
||||
if( pEntity == NULL || ((CEntity *)pEntity)->GetType() != enActor) return false;
|
||||
return ((CActor*)pEntity)->GetBagSystem().IsForgeItem() || ((CActor*)pEntity)->GetEquipmentSystem().IsForgeItem();
|
||||
}
|
||||
*/
|
||||
|
||||
void* getDuraFullItemFromBag( void* pEntity,int nItemId )
|
||||
{
|
||||
if( pEntity == NULL || ((CEntity *)pEntity)->GetType() != enActor) return NULL;
|
||||
return ((CActor*)pEntity)->GetBagSystem().GetDuraFullItemById(nItemId);
|
||||
}
|
||||
|
||||
int getSuitIdByItemId( int nItemId )
|
||||
{
|
||||
const CStdItem* pItem = GetLogicServer()->GetDataProvider()->GetStdItemProvider().GetStdItem(nItemId);
|
||||
if (pItem)
|
||||
{
|
||||
return pItem->m_wSuitID;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool isGetAllSuitEquip( void* pEntity,int nSuit,int nCount )
|
||||
{
|
||||
if( pEntity == NULL || ((CEntity *)pEntity)->GetType() != enActor) return false;
|
||||
PONESUIT pSuit = NULL;//GetLogicServer()->GetDataProvider()->GetSuitConfig().GetDataPtr(nSuit);
|
||||
if(!pSuit) return false;
|
||||
int nResult = 0;
|
||||
//检查所有装备是否齐全
|
||||
for (INT_PTR i = 0; i < pSuit->itmList.count; i++)
|
||||
{
|
||||
INT_PTR nItemId = pSuit->itmList.pData[i];
|
||||
if (((CActor*)pEntity)->GetEquipmentSystem().FindItemByID(nItemId))
|
||||
{
|
||||
nResult++;
|
||||
}
|
||||
|
||||
}
|
||||
return nResult >= nCount;
|
||||
}
|
||||
bool takeOffItem(void* pEntity, void* pUserItem, int nHeroId, bool checkGrid)
|
||||
{
|
||||
if (!pEntity || !pUserItem || ((CEntity *)pEntity)->GetType() != enActor)
|
||||
return false;
|
||||
|
||||
CActor* pActor = (CActor *)pEntity;
|
||||
CUserItem* pItem = (CUserItem *)pUserItem;
|
||||
int location = pItem->btHandPos;
|
||||
if(location !=0 && location !=1)
|
||||
{
|
||||
location =-1;
|
||||
}
|
||||
return pActor->GetEquipmentSystem().TakeOff(pItem->series,checkGrid);
|
||||
}
|
||||
bool equipItem(void* pEntity, void* pUserItem, int nHeroId, bool isBagEquip)
|
||||
{
|
||||
if (!pEntity || !pUserItem || ((CEntity *)pEntity)->GetType() != enActor)
|
||||
return false;
|
||||
|
||||
CActor* pActor = (CActor *)pEntity;
|
||||
CUserItem* pItem = (CUserItem *)pUserItem;
|
||||
int location = pItem->btHandPos;
|
||||
if(location !=0 && location !=1)
|
||||
{
|
||||
location =-1;
|
||||
}
|
||||
if (isBagEquip)
|
||||
{
|
||||
return pActor->GetEquipmentSystem().TakeOn(pItem->series);
|
||||
}
|
||||
else
|
||||
{
|
||||
return pActor->GetEquipmentSystem().TakeOn(pItem);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void clearBag(void* pEntity)
|
||||
{
|
||||
if (!pEntity || ((CEntity *)pEntity)->GetType() != enActor)
|
||||
return;
|
||||
CActor* pActor = (CActor *)pEntity;
|
||||
pActor->GetBagSystem().Clear(pActor->GetEntityName(), GameLog::clUserDestroyItem);
|
||||
}
|
||||
|
||||
void * getEquipByType( void * pEntity, int nType )
|
||||
{
|
||||
if (!pEntity || ((CEntity*)pEntity)->GetType() != enActor)
|
||||
return NULL;
|
||||
return ((CActor *)pEntity)->GetEquipmentSystem().GetItemByType(nType);
|
||||
}
|
||||
//---不用了
|
||||
// bool isDenyRepair(int nItemId)
|
||||
// {
|
||||
// const CStdItem *pStdItem =GetLogicServer()->GetDataProvider()->GetStdItemProvider().GetStdItem(nItemId);
|
||||
// if(pStdItem ==NULL) return 0;
|
||||
|
||||
// return (bool)(pStdItem->m_Flags.denyRepair);
|
||||
// }
|
||||
|
||||
int getBagItemIndex(void* pEntity,void * itemPtr)
|
||||
{
|
||||
if (!pEntity || !itemPtr || ((CEntity *)pEntity)->GetType() != enActor)
|
||||
return -1;
|
||||
|
||||
CActor* pActor = (CActor *)pEntity;
|
||||
CUserItem* pItem = (CUserItem *)itemPtr;
|
||||
return pActor->GetBagSystem().GetBagItemIndex(pItem);
|
||||
|
||||
}
|
||||
|
||||
void* getItemPtrByIndex(void* pEntity,int nIndex)
|
||||
{
|
||||
if (!pEntity || ((CEntity *)pEntity)->GetType() != enActor)
|
||||
return NULL;
|
||||
CActor* pActor = (CActor *)pEntity;
|
||||
return pActor->GetBagSystem().GetItemByIdx(nIndex);
|
||||
}
|
||||
|
||||
int getItemId( void * pItem )
|
||||
{
|
||||
CUserItem * pUserItem = (CUserItem*)pItem;
|
||||
if (pUserItem != NULL)
|
||||
{
|
||||
return pUserItem->wItemId;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// bool initEquipBaseAttr( void * pEntity, void *pItemPtr, int nQualityDataIndex )
|
||||
// {
|
||||
// if (NULL == pEntity || NULL == pItemPtr || ((CEntity *)pEntity)->GetType() != enActor)
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
// CUserItem * pUserItem = (CUserItem *)pItemPtr;
|
||||
// if (NULL == pUserItem)
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
// return RandAttrSelector::InitSmithByUserItem(pUserItem, nQualityDataIndex);
|
||||
// }
|
||||
|
||||
bool isGuildMeltingItem(void* pItem)
|
||||
{
|
||||
if (!pItem)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
CUserItem* pUserItem = (CUserItem*)pItem;
|
||||
if (!pUserItem)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
const CStdItem* pStdItem =GetLogicServer()->GetDataProvider()->GetStdItemProvider().GetStdItem(pUserItem->wItemId);
|
||||
if (!pStdItem)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return pStdItem->isMeltingItem();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool isEquipment(void *pItemPtr)
|
||||
{
|
||||
if (!pItemPtr)
|
||||
return false;
|
||||
CUserItem* pUserItem = (CUserItem*)pItemPtr;
|
||||
if (!pUserItem)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return isEquipmentById(pUserItem->wItemId);
|
||||
}
|
||||
bool isEquipmentById(int wItemId)
|
||||
{
|
||||
const CStdItem* pStdItem =GetLogicServer()->GetDataProvider()->GetStdItemProvider().GetStdItem(wItemId);
|
||||
if (!pStdItem)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return pStdItem->isEquipment();
|
||||
}
|
||||
void* getItemPtrHighestStar(void *pEntity, int nItemID)
|
||||
{
|
||||
if (!pEntity || ((CEntity *)pEntity)->GetType() != enActor)
|
||||
return NULL;
|
||||
CActor* pActor = (CActor *)pEntity;
|
||||
return pActor->GetBagSystem().GetItemPtrHighestStar((WORD)nItemID);
|
||||
}
|
||||
|
||||
//
|
||||
void generateItemAttrsInSmith( void * pEntity, void *pItemPtr, int nSmithId, int nAttrNum, unsigned char nLockType1, unsigned char nLockType2,
|
||||
unsigned char nLockType3, int nFlag, unsigned char nJob )
|
||||
{
|
||||
if( !pEntity || ((CEntity *)pEntity)->GetType() != enActor )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if( !pItemPtr )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
CActor* pActor = (CActor *)pEntity;
|
||||
CUserItem* pUserItem = ( CUserItem* )pItemPtr;
|
||||
|
||||
if( nAttrNum <= 0 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
if( nAttrNum > CUserItem::MaxSmithAttrCount )
|
||||
{
|
||||
nAttrNum = CUserItem::MaxSmithAttrCount;
|
||||
}
|
||||
|
||||
int nLockType[ CUserItem::MaxSmithAttrCount ];
|
||||
nLockType[0] = nLockType1;
|
||||
nLockType[1] = nLockType2;
|
||||
nLockType[2] = nLockType3;
|
||||
nLockType[3] = 0; //保留
|
||||
nLockType[4] = 0; //保留
|
||||
pActor->GenerateItemAttrsInSmith( pUserItem, nSmithId, nAttrNum, nLockType, nFlag, nJob );
|
||||
}
|
||||
|
||||
void generateOneAttrInSmith( int nSmithId, unsigned char& nAttrType, int& nAttrValue, unsigned char nLockType )
|
||||
{
|
||||
RandAttrSelector::GenerateOneAttrInSmith( nSmithId, nAttrType, nAttrValue, nLockType );
|
||||
}
|
||||
|
||||
/*
|
||||
装备是否存在某种属性
|
||||
nFlag:1-鉴定属性
|
||||
*/
|
||||
bool hasItemAttrs( void * pEntity, void *pItemPtr, int nFlag )
|
||||
{
|
||||
if( !pEntity || ((CEntity *)pEntity)->GetType() != enActor )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if( !pItemPtr )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
CActor* pActor = (CActor *)pEntity;
|
||||
CUserItem* pUserItem = ( CUserItem* )pItemPtr;
|
||||
return pActor->GetBagSystem().HasItemIdentifyAttrs( pUserItem );
|
||||
}
|
||||
/*
|
||||
装备属性转移
|
||||
nFlag:1-鉴定属性转移
|
||||
*/
|
||||
bool transferItemAttrs( void * pEntity, void *pSrcItemPtr, void *pDesItemPtr, int nFlag )
|
||||
{
|
||||
if( !pEntity || ((CEntity *)pEntity)->GetType() != enActor )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if( !pSrcItemPtr )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if( !pDesItemPtr )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
CActor* pActor = (CActor *)pEntity;
|
||||
CUserItem* pSrcUserItem = ( CUserItem* )pSrcItemPtr;
|
||||
CUserItem* pDesUserItem = ( CUserItem* )pDesItemPtr;
|
||||
return pActor->TransferItemAttrs( pSrcUserItem, pDesUserItem, nFlag );
|
||||
}
|
||||
|
||||
bool drop_item_in_random_area_byGroupID(int sceneId, int nPosX,int nPosY,int dropGroupId,int pick_time, int nDropTips){
|
||||
|
||||
CFuBen * pFb = GetGlobalLogicEngine()->GetFuBenMgr()->GetFbStaticDataPtr(0);
|
||||
if (pFb == NULL) return false ;
|
||||
|
||||
CScene *pScene= pFb->GetScene(sceneId);
|
||||
if (pScene == NULL) return false ;
|
||||
|
||||
if(!CMonster::RealDropItemByDropGroupId(pScene,nPosX,nPosY,dropGroupId,pick_time,nDropTips)) return false ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
}
|
||||
399
server/LogicServer/script/export/LuaHelpExport.cpp
Normal file
399
server/LogicServer/script/export/LuaHelpExport.cpp
Normal file
@@ -0,0 +1,399 @@
|
||||
#include "StdAfx.h"
|
||||
#include "../interface/LuaHelpExportFun.h"
|
||||
using namespace wylib;
|
||||
using namespace wylib::stream;
|
||||
|
||||
|
||||
//Note向LuaHelp导出的一些辅助性的函数在这里要放一份
|
||||
//不然脚本无法访问
|
||||
const luaL_Reg LuaHelpExpot[]=
|
||||
{
|
||||
{"saveTable",LuaHelp::saveTable},
|
||||
{"getTestTable",LuaHelp::getTestTable},
|
||||
{"getTeamMemberList",LuaHelp::getTeamMemberList},
|
||||
{"getTeamMemberListByPtr",LuaHelp::getTeamMemberListByPtr},
|
||||
{"getFbFromId",LuaHelp::getFbFromId},
|
||||
{"getReloadMapPos",LuaHelp::getReloadMapPos},
|
||||
{"getNearEntityList",LuaHelp::getNearEntityList},
|
||||
{"getAllActorList",LuaHelp::getAllActorList},
|
||||
{"getSceneActorListById",LuaHelp::getSceneActorListById},
|
||||
{"getSceneAliveActorListById",LuaHelp::getSceneAliveActorListById},
|
||||
{"getNearEntityListFromXY",LuaHelp::getNearEntityListFromXY},
|
||||
{"getNearEntityListFromRange",LuaHelp::getNearEntityListFromRange},
|
||||
{"getRankingItemList",LuaHelp::getRankingItemList},
|
||||
{"getFbActorList",LuaHelp::getFbActorList},
|
||||
{"getVisiActorList",LuaHelp::getVisiActorList},
|
||||
|
||||
{ NULL, NULL }, //这行不要删除,删除服务器将无法启动
|
||||
};
|
||||
|
||||
|
||||
namespace LuaHelp
|
||||
{
|
||||
int saveTable(lua_State *L)
|
||||
{
|
||||
if (lua_istable(L, 1) ==false)
|
||||
{
|
||||
OutputMsg(rmError,_T("saveTable要作为参数传过来"));
|
||||
return 0;
|
||||
}
|
||||
const char * sFileName = lua_tostring(L,2);
|
||||
if(sFileName ==NULL)
|
||||
{
|
||||
OutputMsg(rmWaning,_T("saveTable表的名字为空,保存为./demo.txt"));
|
||||
sFileName ="./demo.txt";
|
||||
}
|
||||
const char * sTableName = lua_tostring(L,3);
|
||||
CFileStream stm(sFileName, CFileStream::faWrite | CFileStream::faCreate,CFileStream::AlwaysCreate );
|
||||
if(NULL !=sTableName)
|
||||
{
|
||||
stm.write(sTableName,strlen(sTableName));
|
||||
stm.write(" =\r\n",4);
|
||||
}
|
||||
|
||||
FormatTableA(L,1,stm);
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
int getTestTable(lua_State *L)
|
||||
{
|
||||
float a[10];
|
||||
for(int i=0;i< 10;i++)
|
||||
{
|
||||
a[i]= (float)1221.3443;
|
||||
}
|
||||
PushNumberVector(L,(float*)(&a[0]),10);
|
||||
return 1; //返回1个参数
|
||||
}
|
||||
|
||||
int getTeamMemberList(lua_State *L)
|
||||
{
|
||||
void* member[MAX_TEAM_MEMBER_COUNT];
|
||||
|
||||
void* pEntity = ((void*) tolua_touserdata(L,1,0));
|
||||
if(pEntity == NULL || ((CEntity *)pEntity)->GetType() != enActor) return 0;
|
||||
CTeam* pTeam = ((CActor*)pEntity)->GetTeam();
|
||||
if (!pTeam) return 0;
|
||||
|
||||
int nCount = 0;
|
||||
const TEAMMEMBER* pMember= pTeam->GetMemberList();
|
||||
|
||||
for(INT_PTR i=0; i< MAX_TEAM_MEMBER_COUNT; i++)
|
||||
{
|
||||
if(pMember[i].pActor)
|
||||
{
|
||||
member[nCount++] = pMember[i].pActor;
|
||||
}
|
||||
}
|
||||
|
||||
LuaHelp::PushDataPointerToTable(L,member,nCount);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int getTeamMemberListByPtr( lua_State *L )
|
||||
{
|
||||
void* member[MAX_TEAM_MEMBER_COUNT];
|
||||
|
||||
void* pTeam = ((void*) tolua_touserdata(L,1,0));
|
||||
if (!pTeam) return 0;
|
||||
|
||||
int nCount = 0;
|
||||
const TEAMMEMBER* pMember= ((CTeam*)pTeam)->GetMemberList();
|
||||
|
||||
for(INT_PTR i=0; i< MAX_TEAM_MEMBER_COUNT; i++)
|
||||
{
|
||||
if(pMember[i].pActor)
|
||||
{
|
||||
member[nCount++] = pMember[i].pActor;
|
||||
}
|
||||
}
|
||||
|
||||
LuaHelp::PushDataPointerToTable(L,member,nCount);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int getFbFromId( lua_State *L )
|
||||
{
|
||||
int nFbid = (int)tolua_tonumber(L,1,0);
|
||||
unsigned int Buf[256];//最多返回256个副本
|
||||
int nCount = GetGlobalLogicEngine()->GetFuBenMgr()->GetFbCountFromId(nFbid,Buf,256);
|
||||
LuaHelp::PushNumberVector(L,Buf,nCount);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int getReloadMapPos( lua_State *L )
|
||||
{
|
||||
void* pEntity = ((void*) tolua_touserdata(L,1,0));
|
||||
if(pEntity == NULL || ((CEntity *)pEntity)->GetType() != enActor) return 0;
|
||||
|
||||
int pos[3];
|
||||
((CActor*)pEntity)->GetNotReloadMapPos(pos[0],pos[1],pos[2]);
|
||||
LuaHelp::PushNumberVector(L,pos,3);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int getNearEntityList( lua_State *L )
|
||||
{
|
||||
void* pEntity = ((void*) tolua_touserdata(L,1,0));
|
||||
if(pEntity == NULL) return 0;
|
||||
int nRadio = (int)tolua_tonumber(L,2,0);
|
||||
int nType = (int)tolua_tonumber(L, 3, -1);
|
||||
EntityVector& vec = *(CFuBenManager::m_pVisibleList);
|
||||
vec.clear();
|
||||
CScene* pScene = ((CEntity*)pEntity)->GetScene();
|
||||
if (pScene)
|
||||
{
|
||||
pScene->GetVisibleList(((CEntity*)pEntity),vec,-nRadio,nRadio,-nRadio,nRadio);
|
||||
if (vec.count() > 0)
|
||||
{
|
||||
CVector<void*> pEntityList;
|
||||
pEntityList.clear();
|
||||
CEntityManager* pMgr = GetGlobalLogicEngine()->GetEntityMgr();
|
||||
for (int i = 0; i < vec.count(); i++)
|
||||
{
|
||||
CEntity* pe = pMgr->GetEntity(vec[i]);
|
||||
if (pe && (-1 == nType || pe->GetType() == nType))
|
||||
{
|
||||
pEntityList.add(pe);
|
||||
}
|
||||
}
|
||||
LuaHelp::PushDataPointerToTable(L,(void**)(pEntityList),pEntityList.count());
|
||||
}else
|
||||
{
|
||||
LuaHelp::PushDataPointerToTable(L,NULL,0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LuaHelp::PushDataPointerToTable(L,NULL,0);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int getNearEntityListFromXY( lua_State *L )
|
||||
{
|
||||
void* pScene = ((void*) tolua_touserdata(L,1,0));
|
||||
if(pScene == NULL) return 0;
|
||||
int x = (int)tolua_tonumber(L,2,0);
|
||||
int y = (int)tolua_tonumber(L,3,0);
|
||||
int nRadio = (int)tolua_tonumber(L,4,0);
|
||||
|
||||
EntityVector& vec = *(CFuBenManager::m_pVisibleList);
|
||||
vec.clear();
|
||||
|
||||
((CScene*)pScene)->GetVisibleList(x,y,vec,-nRadio,nRadio,-nRadio,nRadio);
|
||||
if (vec.count() > 0)
|
||||
{
|
||||
CVector<void*> pEntityList;
|
||||
pEntityList.clear();
|
||||
CEntityManager* pMgr = GetGlobalLogicEngine()->GetEntityMgr();
|
||||
for (int i = 0; i < vec.count(); i++)
|
||||
{
|
||||
CEntity* pe = pMgr->GetEntity(vec[i]);
|
||||
if (pe)
|
||||
{
|
||||
pEntityList.add(pe);
|
||||
}
|
||||
}
|
||||
LuaHelp::PushDataPointerToTable(L,(void**)(pEntityList),pEntityList.count());
|
||||
}else
|
||||
{
|
||||
LuaHelp::PushDataPointerToTable(L,NULL,0);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int getNearEntityListFromRange( lua_State *L )
|
||||
{
|
||||
void* pScene = ((void*) tolua_touserdata(L,1,0));
|
||||
if(pScene == NULL) return 0;
|
||||
int x = (int)tolua_tonumber(L,2,0);
|
||||
int y = (int)tolua_tonumber(L,3,0);
|
||||
int width = (int)tolua_tonumber(L,4,0);
|
||||
int height = (int)tolua_tonumber(L,5,0);
|
||||
int type = (int)tolua_tonumber(L,6,0);
|
||||
|
||||
EntityVector& vec = *(CFuBenManager::m_pVisibleList);
|
||||
vec.clear();
|
||||
|
||||
((CScene*)pScene)->GetVisibleList(x,y,vec,-width,width,-height,height);
|
||||
if (vec.count() > 0)
|
||||
{
|
||||
CVector<void*> pEntityList;
|
||||
pEntityList.clear();
|
||||
CEntityManager* pMgr = GetGlobalLogicEngine()->GetEntityMgr();
|
||||
for (int i = 0; i < vec.count(); i++)
|
||||
{
|
||||
CEntity* pe = pMgr->GetEntity(vec[i]);
|
||||
if (pe && pe->GetType() == type)
|
||||
{
|
||||
pEntityList.add(pe);
|
||||
}
|
||||
}
|
||||
LuaHelp::PushDataPointerToTable(L,(void**)(pEntityList),pEntityList.count());
|
||||
}else
|
||||
{
|
||||
LuaHelp::PushDataPointerToTable(L,NULL,0);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int getAllActorList( lua_State *L )
|
||||
{
|
||||
CVector<void*> pEntityList;
|
||||
pEntityList.clear();
|
||||
int nMinLevel = (int)(tolua_tonumber(L, 1, 0));
|
||||
GetGlobalLogicEngine()->GetEntityMgr()->GetOnlineAcotrPtrList(pEntityList, nMinLevel);
|
||||
LuaHelp::PushDataPointerToTable(L,(void**)(pEntityList),pEntityList.count());
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int getSceneActorListById( lua_State *L )
|
||||
{
|
||||
int sid = (int)tolua_tonumber(L,1,0);
|
||||
CScene* pScene = GetGlobalLogicEngine()->GetFuBenMgr()->GetFbStaticDataPtr(0)->GetScene(sid);
|
||||
if (pScene)
|
||||
{
|
||||
CVector<void*> pEntityList;
|
||||
pEntityList.clear();
|
||||
|
||||
CEntityList& list = pScene->GetPlayList();
|
||||
CEntityManager* pEntityMgr = GetGlobalLogicEngine()->GetEntityMgr();
|
||||
CLinkedNode<EntityHandle> *pNode;
|
||||
CLinkedListIterator<EntityHandle> it(list);
|
||||
for (pNode = it.first(); pNode; pNode = it.next())
|
||||
{
|
||||
CEntity* pEntity = pEntityMgr->GetEntity(pNode->m_Data);
|
||||
if (pEntity && pEntity->GetType() == enActor)
|
||||
{
|
||||
pEntityList.add(pEntity);
|
||||
}
|
||||
}
|
||||
LuaHelp::PushDataPointerToTable(L,(void**)(pEntityList),pEntityList.count());
|
||||
}
|
||||
else
|
||||
{
|
||||
LuaHelp::PushDataPointerToTable(L,NULL,0);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int getSceneAliveActorListById(lua_State *L)
|
||||
{
|
||||
int sid = (int)tolua_tonumber(L,1,0);
|
||||
CScene* pScene = GetGlobalLogicEngine()->GetFuBenMgr()->GetFbStaticDataPtr(0)->GetScene(sid);
|
||||
if (pScene)
|
||||
{
|
||||
CVector<void*> pEntityList;
|
||||
pEntityList.clear();
|
||||
|
||||
CEntityList& list = pScene->GetPlayList();
|
||||
CEntityManager* pEntityMgr = GetGlobalLogicEngine()->GetEntityMgr();
|
||||
CLinkedNode<EntityHandle> *pNode;
|
||||
CLinkedListIterator<EntityHandle> it(list);
|
||||
for (pNode = it.first(); pNode; pNode = it.next())
|
||||
{
|
||||
CEntity* pEntity = pEntityMgr->GetEntity(pNode->m_Data);
|
||||
if (pEntity && pEntity->GetType() == enActor)
|
||||
{
|
||||
if(pEntity->IsDeath() == false)
|
||||
pEntityList.add(pEntity);
|
||||
}
|
||||
}
|
||||
LuaHelp::PushDataPointerToTable(L,(void**)(pEntityList),pEntityList.count());
|
||||
}
|
||||
else
|
||||
{
|
||||
LuaHelp::PushDataPointerToTable(L,NULL,0);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int getRankingItemList( lua_State* L )
|
||||
{
|
||||
void* pRank = ((void*) tolua_touserdata(L,1,0));
|
||||
if(pRank == NULL) return 0;
|
||||
int nCount = (int)tolua_tonumber(L,2,0);//需要返回前N名
|
||||
|
||||
CVector<CRankingItem*>& itemList = ((CRanking*)pRank)->GetList();
|
||||
CVector<void*>* pList = (CVector<void*>*)(&itemList);
|
||||
nCount = __min(nCount, (int)itemList.count());
|
||||
LuaHelp::PushDataPointerToTable(L,(void**)(*pList),nCount);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int getFbActorList( lua_State* L )
|
||||
{
|
||||
void* pFb = ((void*) tolua_touserdata(L,1,0));
|
||||
if(pFb == NULL) return 0;
|
||||
|
||||
CVector<void*> pEntityList;
|
||||
pEntityList.clear();
|
||||
|
||||
CFuBen::SceneList& sl = ((CFuBen*)pFb)->GetSceneList();
|
||||
CEntityManager* pEntityMgr = GetGlobalLogicEngine()->GetEntityMgr();
|
||||
for ( INT_PTR i = 0; i < sl.count(); i++)
|
||||
{
|
||||
CScene* pScene = sl[i];
|
||||
if (pScene)
|
||||
{
|
||||
CEntityList& list = pScene->GetPlayList();
|
||||
CLinkedNode<EntityHandle> *pNode;
|
||||
CLinkedListIterator<EntityHandle> it(list);
|
||||
for (pNode = it.first(); pNode; pNode = it.next())
|
||||
{
|
||||
CEntity* pEntity = pEntityMgr->GetEntity(pNode->m_Data);
|
||||
if (pEntity && pEntity->GetType() == enActor)
|
||||
{
|
||||
pEntityList.add(pEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LuaHelp::PushDataPointerToTable(L,(void**)(pEntityList),pEntityList.count());
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int getVisiActorList( lua_State* L )
|
||||
{
|
||||
void* pEntity = ((void*) tolua_touserdata(L,1,0));
|
||||
if(pEntity == NULL) return 0;
|
||||
|
||||
CVector<void*> pEntityList;
|
||||
pEntityList.clear();
|
||||
const CVector<EntityHandleTag>& entityList = ((CAnimal*)pEntity)->GetObserverSystem()->GetVisibleList();
|
||||
for (INT_PTR i = 0; i < entityList.count(); i++)
|
||||
{
|
||||
CEntity* pEntity = GetEntityFromHandle(entityList[i].m_handle);
|
||||
if (pEntity && pEntity->GetType() == enActor)
|
||||
{
|
||||
pEntityList.add(pEntity);
|
||||
}
|
||||
}
|
||||
|
||||
LuaHelp::PushDataPointerToTable(L,(void**)(pEntityList),pEntityList.count());
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
288
server/LogicServer/script/export/PetExportFun.cpp
Normal file
288
server/LogicServer/script/export/PetExportFun.cpp
Normal file
@@ -0,0 +1,288 @@
|
||||
#include "StdAfx.h"
|
||||
#include "../interface/PetExportFun.h"
|
||||
namespace Pet
|
||||
{
|
||||
|
||||
int addPet(void* pEntity,int nPetConfigId,int nLevel, int nAiId,int nLiveSecs)
|
||||
{
|
||||
|
||||
if(pEntity == NULL || ((CEntity *)pEntity)->GetType() != enActor) return -1;
|
||||
return ((CActor *)pEntity)->GetPetSystem().AddPet(nPetConfigId,nLevel, nAiId,nLiveSecs);
|
||||
}
|
||||
|
||||
int getPetCountByConfigId( void * pEntity, int nPetId )
|
||||
{
|
||||
if(pEntity == NULL || ((CEntity*)pEntity)->GetType() != enActor)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
return ((CActor*)pEntity)->GetPetSystem().GetPetCountByConfigId(nPetId);
|
||||
}
|
||||
|
||||
char * getPetName(void * pEntity ,int nPetId)
|
||||
{
|
||||
if(pEntity == NULL || ((CEntity *)pEntity)->GetType() != enActor) return NULL;
|
||||
const PMONSTERCONFIG pConfig = GetLogicServer()->GetDataProvider()->GetMonsterConfig().GetMonsterData(nPetId);
|
||||
if (pConfig)
|
||||
{
|
||||
return pConfig->szName;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool delPetById(void * pEntity, int nPetId)
|
||||
{
|
||||
if(pEntity == NULL || ((CEntity *)pEntity)->GetType() != enActor) return false;
|
||||
CActor * pActor = (CActor *)pEntity;
|
||||
return pActor->GetPetSystem().RemoveAllPetByConfigId(nPetId) > 0;
|
||||
}
|
||||
/*
|
||||
bool setPetStrong(void *pEntity, int nPertId,int nStrong)
|
||||
{
|
||||
if(pEntity == NULL || ((CEntity *)pEntity)->GetType() != enActor) return false;
|
||||
return ((CActor *)pEntity)->GetPetSystem().SetPetStrong(nPertId,nStrong);
|
||||
}
|
||||
|
||||
|
||||
bool petSmith(void *pEntity, int nPetId)
|
||||
{
|
||||
if(pEntity == NULL || ((CEntity *)pEntity)->GetType() != enActor) return false;
|
||||
return ((CActor *)pEntity)->GetPetSystem().SmithPet(nPetId);
|
||||
|
||||
}
|
||||
bool setCircle(void *pEntity, int nPetID, int nCircle)
|
||||
{
|
||||
if(pEntity == NULL || ((CEntity *)pEntity)->GetType() != enActor) return false;
|
||||
return ((CActor *)pEntity)->GetPetSystem().SetCircle(nPetID,nCircle);
|
||||
}
|
||||
|
||||
|
||||
bool addExp(void *pEntity,int nPetId, int nExp)
|
||||
{
|
||||
if(pEntity == NULL || ((CEntity *)pEntity)->GetType() != enActor) return false;
|
||||
return ((CActor *)pEntity)->GetPetSystem().ChangeExp(nPetId,nExp);
|
||||
}
|
||||
|
||||
bool canAddPet(void *pEntity, int nPetConfigId)
|
||||
{
|
||||
if(pEntity == NULL || ((CEntity *)pEntity)->GetType() != enActor) return false;
|
||||
return ((CActor *)pEntity)->GetPetSystem().CanAddPet(nPetConfigId);
|
||||
}
|
||||
|
||||
bool addLoyalty(void *pEntity,int nPetId, int nValue)
|
||||
{
|
||||
if(pEntity == NULL || ((CEntity *)pEntity)->GetType() != enActor) return false;
|
||||
return ((CActor *)pEntity)->GetPetSystem().ChangeLoyalty(nPetId,nValue);
|
||||
}
|
||||
|
||||
int getPetProperty(void *pEntity,int nPetId, int nPropId)
|
||||
{
|
||||
if(pEntity == NULL || ((CEntity *)pEntity)->GetType() != enActor) return -1;
|
||||
|
||||
const CPetSystem::PETDATA * pPet = ((CActor *)pEntity)->GetPetSystem().GetPetData(nPetId);
|
||||
if(pPet ==NULL)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
if( enPetMaxLoyalty ==nPropId)
|
||||
{
|
||||
return ((CActor *)pEntity)->GetPetSystem().GetMaxLoyalty();
|
||||
}
|
||||
|
||||
switch ( nPropId)
|
||||
{
|
||||
case enPetLevel:
|
||||
return pPet->data.bLevel;
|
||||
break;
|
||||
case enPetStrong:
|
||||
return pPet->data.bStrong;
|
||||
break;
|
||||
case enPetCircle:
|
||||
return pPet->data.bCircle;
|
||||
break;
|
||||
case enPetConfigId:
|
||||
return pPet->data.wConfigId;
|
||||
break;
|
||||
case enPetExp:
|
||||
return (int)(pPet->data.nExp);
|
||||
break;
|
||||
|
||||
case enPetLoyalty:
|
||||
return pPet->data.wLoyalty;
|
||||
break;
|
||||
|
||||
case enBaseAttack:
|
||||
return (int)(pPet->data.nBaseAttack);
|
||||
break;
|
||||
case enBaseDefence:
|
||||
return (int)(pPet->data.nBaseDefence);
|
||||
break;
|
||||
|
||||
case enBaseAgility:
|
||||
return (int)(pPet->data.nBaseAgility);
|
||||
break;
|
||||
case enBasePhysique:
|
||||
return (int)(pPet->data.nBasePhysique);
|
||||
break;
|
||||
case enSmithAttack:
|
||||
return (int)(pPet->data.nSmithAttack);
|
||||
break;
|
||||
case enSmithDefence:
|
||||
return (int)(pPet->data.nSmithDefence);
|
||||
break;
|
||||
case enSmithAgility:
|
||||
return (int)(pPet->data.nSmithAgility);
|
||||
break;
|
||||
|
||||
case enSmithPhysique:
|
||||
return (int)(pPet->data.nSmithPhysique);
|
||||
break;
|
||||
case enPetScore:
|
||||
return (int)(pPet->data.nScore);
|
||||
break;
|
||||
case enPetAttackType:
|
||||
return (int)(pPet->data.bAattackType);
|
||||
break;
|
||||
|
||||
case enPetIconId: //宠物的图标ID
|
||||
return (int)(pPet->data.bIconId);
|
||||
break;
|
||||
|
||||
case enPetWashMergeRate://洗出来的附体的比例
|
||||
return (int)(pPet->data.wWashMergeRate);
|
||||
break;
|
||||
case enPetQuality: //品质
|
||||
return (int)(pPet->data.bQuality);
|
||||
break;
|
||||
case enPetTotalMergeRate: //当前全部的附体资质
|
||||
return (int)(pPet->data.wWashMergeRate + pPet->wQualityMergeRate);
|
||||
break;
|
||||
case enPetMaxMergeRate://当前最大的附体资质比例
|
||||
return pPet->wMaxMergeRate;
|
||||
break;
|
||||
//技能的洗练次数为
|
||||
case enPetSkillSlotCount:
|
||||
return pPet->data.bSkillOpenSlot + pPet->data.bCircle;
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
bool enlargePetSlot(void *pEntity, int nGridCount)
|
||||
{
|
||||
if(pEntity == NULL || ((CEntity *)pEntity)->GetType() != enActor) return false;
|
||||
return ((CActor *)pEntity)->GetPetSystem().EnlargePetSlot(nGridCount);
|
||||
}
|
||||
|
||||
bool learnSkill(void *pEntity,int nPetID, int nSkillID,int nSlotId)
|
||||
{
|
||||
if(pEntity == NULL || ((CEntity *)pEntity)->GetType() != enActor) return false;
|
||||
return ((CActor *)pEntity)->GetPetSystem().LearnSkill(nPetID,nSkillID,nSlotId);
|
||||
}
|
||||
|
||||
int getLearnSkillId(void* pEntity,int nPetId,int nSkillSlot)
|
||||
{
|
||||
if(pEntity == NULL || ((CEntity *)pEntity)->GetType() != enActor) return false;
|
||||
return ((CActor *)pEntity)->GetPetSystem().GetLearnSkillId(nPetId,nSkillSlot);
|
||||
}
|
||||
|
||||
bool forgetSkill(void* pEntity,int nPetId,int nSkillId)
|
||||
{
|
||||
if(pEntity == NULL || ((CEntity *)pEntity)->GetType() != enActor) return false;
|
||||
return ((CActor *)pEntity)->GetPetSystem().ForgetSkill(nPetId,nSkillId);
|
||||
}
|
||||
int getSkillLevel(void* pEntity,int nPetId, int nSkillId)
|
||||
{
|
||||
if(pEntity == NULL || ((CEntity *)pEntity)->GetType() != enActor) return 0;
|
||||
return ((CActor *)pEntity)->GetPetSystem().GetSkillLevel(nPetId,nSkillId);
|
||||
}
|
||||
bool skillLevelUp(void *pEntity,int nPetID, int nSkillID )
|
||||
{
|
||||
if(pEntity == NULL || ((CEntity *)pEntity)->GetType() != enActor) return false;
|
||||
return ((CActor *)pEntity)->GetPetSystem().SkillLevelUp(nPetID,nSkillID);
|
||||
}
|
||||
|
||||
bool delPet(void * pEntity, int nPetId)
|
||||
{
|
||||
if(pEntity == NULL || ((CEntity *)pEntity)->GetType() != enActor) return false;
|
||||
return ((CActor *)pEntity)->GetPetSystem().RemovePet(nPetId);
|
||||
}
|
||||
|
||||
|
||||
int getBattlePetId(void * pEntity)
|
||||
{
|
||||
if(pEntity == NULL || ((CEntity *)pEntity)->GetType() != enActor) return -1;
|
||||
return ((CActor *)pEntity)->GetPetSystem().GetBattlePetId();
|
||||
|
||||
}
|
||||
|
||||
int getMergePetId(void * pEntity)
|
||||
{
|
||||
if (pEntity == NULL || ((CEntity *)pEntity)->GetType() != enActor) return -1;
|
||||
return ((CActor *)pEntity)->GetPetSystem().GetMergePetId();
|
||||
}
|
||||
|
||||
void sendPetOpResult(void * pEntity,int nPetId,int nOpId, bool result)
|
||||
{
|
||||
if(pEntity == NULL || ((CEntity *)pEntity)->GetType() != enActor) return ;
|
||||
CActor *pActor = (CActor *)pEntity;
|
||||
if( pActor &&pActor->IsInited() )
|
||||
{
|
||||
CActorPacket pack;
|
||||
pActor->AllocPacket(pack);
|
||||
pack << (BYTE)(enPetSystemID)<< (BYTE) sPetOpResult;
|
||||
pack << (BYTE)(nOpId) ;
|
||||
pack << (BYTE) nPetId;
|
||||
if(result)
|
||||
{
|
||||
pack <<(BYTE)1;
|
||||
}
|
||||
else
|
||||
{
|
||||
pack <<(BYTE)0;
|
||||
}
|
||||
pack.flush();
|
||||
}
|
||||
}
|
||||
bool changeAttackType(void *pEntity, int nPetId)
|
||||
{
|
||||
if(pEntity == NULL || ((CEntity *)pEntity)->GetType() != enActor) return false;
|
||||
return ((CActor *)pEntity)->GetPetSystem().ChangePetAttackState(nPetId);
|
||||
}
|
||||
|
||||
void setPetBattle(void* pEntity, int nPetId)
|
||||
{
|
||||
if(pEntity == NULL || ((CEntity *)pEntity)->GetType() != enActor) return ;
|
||||
((CActor *)pEntity)->GetPetSystem().SetPetBattle(nPetId);
|
||||
}
|
||||
bool setPetSkin(void* pEntity, int nPetId,int configId,int nQuality)
|
||||
{
|
||||
if(pEntity == NULL || ((CEntity *)pEntity)->GetType() != enActor) return false;
|
||||
return ((CActor *)pEntity)->GetPetSystem().SetPetSkin(nPetId,configId,nQuality);
|
||||
}
|
||||
|
||||
bool setPetMergeRate(void* pEntity, int nPetId,int nRate)
|
||||
{
|
||||
if(pEntity == NULL || ((CEntity *)pEntity)->GetType() != enActor) return false;
|
||||
return ((CActor *)pEntity)->GetPetSystem().SetPetMergeRate(nPetId,nRate);
|
||||
}
|
||||
char * getPetName(void * pEntity ,int nPetId)
|
||||
{
|
||||
if(pEntity == NULL || ((CEntity *)pEntity)->GetType() != enActor) return NULL;
|
||||
const CPetSystem::PETDATA * pPet = ((CActor *)pEntity)->GetPetSystem().GetPetData(nPetId);
|
||||
if(pPet ==NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
return (char*)(pPet->data.name);
|
||||
}
|
||||
bool enlargePetSkillSlot(void * pEntity, int nPetId)
|
||||
{
|
||||
if(pEntity == NULL || ((CEntity *)pEntity)->GetType() != enActor) return false;
|
||||
return ((CActor *)pEntity)->GetPetSystem().EnlargePetSkillSlot(nPetId);
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
295
server/LogicServer/script/export/RankingExport.cpp
Normal file
295
server/LogicServer/script/export/RankingExport.cpp
Normal file
@@ -0,0 +1,295 @@
|
||||
#include "StdAfx.h"
|
||||
#include "../interface/RankingExport.h"
|
||||
|
||||
|
||||
namespace Ranking
|
||||
{
|
||||
void* getRanking( int rankId )
|
||||
{
|
||||
return GetGlobalLogicEngine()->GetRankingMgr().GetRanking(rankId);
|
||||
}
|
||||
|
||||
void* add( int rankId,char* sName,int nMax,int boDisplay, int nBroadCount)
|
||||
{
|
||||
return GetGlobalLogicEngine()->GetRankingMgr().Add(rankId,sName,nMax,boDisplay, nBroadCount);
|
||||
}
|
||||
|
||||
bool load( void* pRank,char* sFile )
|
||||
{
|
||||
if (pRank)
|
||||
{
|
||||
return ((CRanking*)pRank)->Load(sFile);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool save( void* pRank,char* sFile,bool bForceSave)
|
||||
{
|
||||
if (pRank)
|
||||
{
|
||||
((CRanking*)pRank)->Save(sFile, bForceSave);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void addColumn( void* pRank,char* sTitle, int nIndex /*= -1*/, bool bUnique )
|
||||
{
|
||||
if (pRank)
|
||||
{
|
||||
((CRanking*)pRank)->AddColumn(sTitle,nIndex,bUnique);
|
||||
}
|
||||
}
|
||||
|
||||
void setColumnTitle(void* pRank, char* sTitle, int nIndex)
|
||||
{
|
||||
if (pRank)
|
||||
{
|
||||
((CRanking*)pRank)->SetColumnTitle(sTitle, nIndex);
|
||||
}
|
||||
}
|
||||
|
||||
void* addItem( void* pRank,unsigned int nId, int nPoint, bool bRankFlag)
|
||||
{
|
||||
if (pRank)
|
||||
{
|
||||
return ((CRanking*)pRank)->AddItem(nId,nPoint,bRankFlag);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int getItemIndexFromId( void* pRank,unsigned int nId )
|
||||
{
|
||||
if (pRank)
|
||||
{
|
||||
return (int)(((CRanking*)pRank)->GetIndexFromId(nId));
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void* getItemPtrFromId( void* pRank,unsigned int nId )
|
||||
{
|
||||
if (pRank)
|
||||
{
|
||||
return ((CRanking*)pRank)->GetPtrFromId(nId);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void* updateItem( void* pRank,unsigned int nId,int nPoint )
|
||||
{
|
||||
if (pRank)
|
||||
{
|
||||
return ((CRanking*)pRank)->Update(nId,nPoint);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void* setItem( void* pRank,unsigned int nId,int nPoint )
|
||||
{
|
||||
if (pRank)
|
||||
{
|
||||
return ((CRanking*)pRank)->Set(nId,nPoint);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void setSub( void* pRankItem,int nIndex, char* sData )
|
||||
{
|
||||
if (pRankItem)
|
||||
{
|
||||
return ((CRankingItem*)pRankItem)->SetSub(nIndex,sData);
|
||||
}
|
||||
}
|
||||
|
||||
void addRef( void* pRank )
|
||||
{
|
||||
if (pRank)
|
||||
{
|
||||
((CRanking*)pRank)->addRef();
|
||||
}
|
||||
}
|
||||
|
||||
void release( void* pRank )
|
||||
{
|
||||
if (pRank)
|
||||
{
|
||||
((CRanking*)pRank)->release();
|
||||
}
|
||||
}
|
||||
|
||||
int getRef( void* pRank )
|
||||
{
|
||||
if (pRank)
|
||||
{
|
||||
return ((CRanking*)pRank)->getRef();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void removeRanking( int rankId )
|
||||
{
|
||||
GetGlobalLogicEngine()->GetRankingMgr().Remove(rankId);
|
||||
}
|
||||
|
||||
int getRankItemCount( void* pRank )
|
||||
{
|
||||
if (pRank)
|
||||
{
|
||||
return (int)(((CRanking*)pRank)->GetList().count());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int getRankItemCountByLimit(void* pRank, int nLimit)
|
||||
{
|
||||
if (pRank)
|
||||
{
|
||||
return GetGlobalLogicEngine()->GetMiscMgr().GetRankLimitCount((CRanking*)pRank, nLimit);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int getPoint( void* pRankItem )
|
||||
{
|
||||
if (pRankItem)
|
||||
{
|
||||
return ((CRankingItem*)pRankItem)->GetPoint();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned int getId( void* pRankItem )
|
||||
{
|
||||
if (pRankItem)
|
||||
{
|
||||
return ((CRankingItem*)pRankItem)->GetId();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char* getSub( void* pRankItem,int nIndex )
|
||||
{
|
||||
if (pRankItem)
|
||||
{
|
||||
const char* p = ((CRankingItem*)pRankItem)->GetSubData(nIndex);
|
||||
return p;
|
||||
}
|
||||
return "-";
|
||||
}
|
||||
|
||||
void clearRanking( void* pRank )
|
||||
{
|
||||
if (pRank)
|
||||
{
|
||||
return ((CRanking*)pRank)->clear();
|
||||
}
|
||||
}
|
||||
|
||||
void* getItemFromIndex( void* pRank,int nIndex )
|
||||
{
|
||||
if (pRank)
|
||||
{
|
||||
/*
|
||||
CVector<CRankingItem*>& itemList = ((CRanking*)pRank)->GetList();
|
||||
if (nIndex >= 0 && nIndex < itemList.count())
|
||||
{
|
||||
return itemList[nIndex];
|
||||
}
|
||||
*/
|
||||
return (void *)(((CRanking*)pRank)->GetItem(nIndex));
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void setColumnDisplay( void* pRank, int nIndex ,int boDisplay )
|
||||
{
|
||||
if (pRank)
|
||||
{
|
||||
((CRanking*)pRank)->SetColDisplay(nIndex, boDisplay > 0 );
|
||||
}
|
||||
}
|
||||
|
||||
int getIndexFromPtr( void* pRankItem )
|
||||
{
|
||||
if (pRankItem)
|
||||
{
|
||||
return ((CRankingItem*)pRankItem)->GetIndex();
|
||||
}
|
||||
return -100000;//
|
||||
}
|
||||
|
||||
void setDisplayName( void* pRank, const char* sName )
|
||||
{
|
||||
if (pRank)
|
||||
{
|
||||
((CRanking*)pRank)->SetDisplayName(sName);
|
||||
}
|
||||
}
|
||||
|
||||
void setIdTitle( void* pRank,const char* sName )
|
||||
{
|
||||
if (pRank)
|
||||
{
|
||||
((CRanking*)pRank)->SetIdTitle(sName);
|
||||
}
|
||||
}
|
||||
|
||||
void setPointTitle( void* pRank, const char* sName )
|
||||
{
|
||||
if (pRank)
|
||||
{
|
||||
((CRanking*)pRank)->SetPointTitle(sName);
|
||||
}
|
||||
}
|
||||
|
||||
void removeId( void* pRank, unsigned int id )
|
||||
{
|
||||
if (pRank)
|
||||
{
|
||||
((CRanking*)pRank)->RemoveId(id);
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateCsRank(int rankId)
|
||||
{
|
||||
GetGlobalLogicEngine()->GetRankingMgr().NotifyRankUpdateCs(rankId);
|
||||
}
|
||||
|
||||
void setRankPropConfig(void* pRank, int nRankPropIndex)
|
||||
{
|
||||
if (pRank)
|
||||
{
|
||||
((CRanking*)pRank)->SetRankPropConfig(nRankPropIndex);
|
||||
}
|
||||
}
|
||||
|
||||
int GetRankColumnCount(void* pRank){
|
||||
int count = 0;
|
||||
if (pRank)
|
||||
{
|
||||
count = ((CRanking*)pRank)->ColumnCount();
|
||||
}
|
||||
return (int)count;
|
||||
}
|
||||
|
||||
void forceSave(void* pRank,char* sFile)
|
||||
{
|
||||
if (pRank)
|
||||
{
|
||||
((CRanking*)pRank)->ForceSave(sFile);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool CheckActorIdInRank(void* pRank,unsigned int id)
|
||||
{
|
||||
if (pRank)
|
||||
{
|
||||
return ((CRanking*)pRank)->CheckActorIdInRank(id);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
189
server/LogicServer/script/export/ScoreRecorderExport.cpp
Normal file
189
server/LogicServer/script/export/ScoreRecorderExport.cpp
Normal file
@@ -0,0 +1,189 @@
|
||||
#include "StdAfx.h"
|
||||
#include "../interface/ScoreRecorderExport.h"
|
||||
|
||||
namespace ScoreRecorder
|
||||
{
|
||||
|
||||
//创建一个计分器,创建计分器后不必调用addRef,以及自动调用了。当不再使用这个计分器的时候,必须调用release解除引用。
|
||||
void *create(const char *sName)
|
||||
{
|
||||
if(sName ==NULL )
|
||||
{
|
||||
OutputMsg(rmError,_T("%s 传入空指针"),__FUNCTION__);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CCustomScoreRecorder *pRecorder = new CMultiNotifyScoreRecorder(sName);
|
||||
pRecorder->addRef();
|
||||
return pRecorder;
|
||||
}
|
||||
|
||||
|
||||
//增加引用计数
|
||||
//注意:调用Create??ScoreRecorder系列函数创建的计分器后不必调用addRef,除非有特殊的需求。
|
||||
int addRef(void* pRecorder)
|
||||
{
|
||||
if(pRecorder ==NULL )
|
||||
{
|
||||
OutputMsg(rmError,_T("%s 传入空指针"),__FUNCTION__);
|
||||
return 0;
|
||||
}
|
||||
return ((CCustomScoreRecorder*)pRecorder)->addRef();
|
||||
}
|
||||
|
||||
//减少引用计数,对象引用计数为0的时候将自动销毁对象
|
||||
//****脚本必须在不使用计分器对象的时候调用release解除对计分器的引用,否则将造成内存泄露。
|
||||
int release(void* pRecorder)
|
||||
{
|
||||
if(pRecorder ==NULL )
|
||||
{
|
||||
OutputMsg(rmError,_T("%s 传入空指针"),__FUNCTION__);
|
||||
return 0;
|
||||
}
|
||||
return ((CCustomScoreRecorder*)pRecorder)->release();
|
||||
}
|
||||
|
||||
|
||||
//将一个队伍加入到计分器通知列表中
|
||||
void joinTeam(void *pRecorder, void *pTarget)
|
||||
{
|
||||
if(pRecorder ==NULL || pTarget==NULL )
|
||||
{
|
||||
OutputMsg(rmError,_T("%s 传入空指针"),__FUNCTION__);
|
||||
return ;
|
||||
}
|
||||
((CMultiNotifyScoreRecorder*)pRecorder)->AddTeam((CTeam*)pTarget);
|
||||
}
|
||||
|
||||
//将一个帮会加入到计分器通知列表中
|
||||
void joinGuild(void *pRecorder, void *pTarget)
|
||||
{
|
||||
if(pRecorder ==NULL || pTarget==NULL )
|
||||
{
|
||||
OutputMsg(rmError,_T("%s 传入空指针"),__FUNCTION__);
|
||||
return ;
|
||||
}
|
||||
|
||||
((CMultiNotifyScoreRecorder*)pRecorder)->AddGuild((CGuild*)pTarget);
|
||||
}
|
||||
|
||||
//将一个阵营加入到计分器通知列表中
|
||||
void joinCamp(void *pRecorder, void *pTarget)
|
||||
{
|
||||
|
||||
if(pRecorder ==NULL || pTarget==NULL )
|
||||
{
|
||||
OutputMsg(rmError,_T("%s 传入空指针"),__FUNCTION__);
|
||||
return ;
|
||||
}
|
||||
|
||||
((CMultiNotifyScoreRecorder*)pRecorder)->AddCamp((CCamp*)pTarget);
|
||||
}
|
||||
|
||||
//将一个副本加入到计分器通知列表中
|
||||
void joinFuBen(void *pRecorder, void *pTarget)
|
||||
{
|
||||
if(pRecorder ==NULL || pTarget==NULL )
|
||||
{
|
||||
OutputMsg(rmError,_T("%s 传入空指针"),__FUNCTION__);
|
||||
return ;
|
||||
}
|
||||
((CMultiNotifyScoreRecorder*)pRecorder)->AddFuBen((CFuBen*)pTarget);
|
||||
}
|
||||
|
||||
|
||||
//将一个通知对象从计分器通知列表中移除
|
||||
void leave(void *pRecorder, void *pTarget)
|
||||
{
|
||||
if(pRecorder ==NULL || pTarget==NULL )
|
||||
{
|
||||
OutputMsg(rmError,_T("%s 传入空指针"),__FUNCTION__);
|
||||
return ;
|
||||
}
|
||||
((CMultiNotifyScoreRecorder*)pRecorder)->RemoveNotifyTarget(pTarget);
|
||||
}
|
||||
|
||||
//停止一个计分器对象
|
||||
void stop(void* pRecorder)
|
||||
{
|
||||
if(pRecorder ==NULL )
|
||||
{
|
||||
OutputMsg(rmError,_T("%s 传入空指针"),__FUNCTION__);
|
||||
return ;
|
||||
}
|
||||
((CCustomScoreRecorder*)pRecorder)->stop();
|
||||
}
|
||||
|
||||
//为计分项增加分值。如果计分项不存在则会创建计分项并设置值为要增加的值,否则会增加原有计分项的值。
|
||||
int incScore(void* pRecorder, const char* sName, int nValueToAdd)
|
||||
{
|
||||
if(pRecorder ==NULL || sName ==NULL)
|
||||
{
|
||||
OutputMsg(rmError,_T("%s 传入空指针"),__FUNCTION__);
|
||||
return 0;
|
||||
}
|
||||
return ((CCustomScoreRecorder*)pRecorder)->incScore(sName, nValueToAdd, true);
|
||||
}
|
||||
|
||||
//改变计分项分值。如果计分项不存在则会创建计分项并设置值,否则会调整原有计分项的值。
|
||||
int setScore(void* pRecorder, const char* sName, int nValue)
|
||||
{
|
||||
if(pRecorder ==NULL || sName ==NULL)
|
||||
{
|
||||
OutputMsg(rmError,_T("%s 传入空指针"),__FUNCTION__);
|
||||
return 0;
|
||||
}
|
||||
return ((CCustomScoreRecorder*)pRecorder)->setScore(sName, nValue, true);
|
||||
}
|
||||
|
||||
//获取一个计分项的值
|
||||
int getScore(void* pRecorder, const char* sName)
|
||||
{
|
||||
if(pRecorder ==NULL || sName==NULL )
|
||||
{
|
||||
OutputMsg(rmError,_T("%s 传入空指针"),__FUNCTION__);
|
||||
return 0;
|
||||
}
|
||||
return ((CCustomScoreRecorder*)pRecorder)->getScore(sName);
|
||||
}
|
||||
|
||||
//判断指定名称的计分项是否存在
|
||||
bool itemExists(void* pRecorder, const char* sName)
|
||||
{
|
||||
if(pRecorder ==NULL || sName==NULL )
|
||||
{
|
||||
OutputMsg(rmError,_T("%s 传入空指针"),__FUNCTION__);
|
||||
return false ;
|
||||
}
|
||||
return ((CCustomScoreRecorder*)pRecorder)->itemExists(sName);
|
||||
}
|
||||
|
||||
//获取完整的计分器数据,数据表的格式为{ { name = "计分项名称", value = 分值 } .. }
|
||||
int getScoreData(lua_State *L)
|
||||
{
|
||||
CCustomScoreRecorder *pRecorder = (CCustomScoreRecorder*)lua_touserdata(L, 1);
|
||||
const CCustomHashTable<SCORERECORD> tb = pRecorder->getScoreDataTable();
|
||||
|
||||
int nIdx = 1;
|
||||
lua_createtable(L, (int)tb.count(), 0);
|
||||
CHashTableIterator<SCORERECORD> it(tb);
|
||||
const SCORERECORD *pItem = it.first();
|
||||
while (pItem)
|
||||
{
|
||||
lua_createtable(L, 0, 1);
|
||||
//name
|
||||
lua_pushstring(L, pItem->sName);
|
||||
lua_setfield(L, -1, "name");
|
||||
//value
|
||||
lua_pushinteger(L, pItem->nScore);
|
||||
lua_setfield(L, -1, "value");
|
||||
//设置表数组项
|
||||
lua_rawseti(L, -2, nIdx);
|
||||
//下一个
|
||||
nIdx++;
|
||||
pItem = it.next();
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
2029
server/LogicServer/script/export/SystemExportFun.cpp
Normal file
2029
server/LogicServer/script/export/SystemExportFun.cpp
Normal file
File diff suppressed because it is too large
Load Diff
79
server/LogicServer/script/export/TeamExportFun.cpp
Normal file
79
server/LogicServer/script/export/TeamExportFun.cpp
Normal file
@@ -0,0 +1,79 @@
|
||||
#include "StdAfx.h"
|
||||
#include "../interface/TeamExportFun.h"
|
||||
|
||||
namespace TeamFun
|
||||
{
|
||||
void* getTeamCaptain( unsigned int nTeamId )
|
||||
{
|
||||
CTeam* pTeam = GetGlobalLogicEngine()->GetTeamMgr().GetTeam(nTeamId);
|
||||
if (pTeam)
|
||||
{
|
||||
return pTeam->GetCaptin();
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void* getTeamCaptain( void* pTeam )
|
||||
{
|
||||
if (pTeam)
|
||||
{
|
||||
return ((CTeam*)pTeam)->GetCaptin();
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
unsigned int getChallenge( unsigned int nTeamId )
|
||||
{
|
||||
CTeam* pTeam = GetGlobalLogicEngine()->GetTeamMgr().GetTeam(nTeamId);
|
||||
if (pTeam)
|
||||
{
|
||||
return pTeam->GetChallengeId();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void setChallenge( unsigned int nTeamId,unsigned int nChalllengeId )
|
||||
{
|
||||
CTeam* pTeam = GetGlobalLogicEngine()->GetTeamMgr().GetTeam(nTeamId);
|
||||
if (pTeam)
|
||||
{
|
||||
return pTeam->SetChallengeId(nChalllengeId);
|
||||
}
|
||||
}
|
||||
|
||||
void setTeamFubenId( unsigned int nTeamId,int nFbId )
|
||||
{
|
||||
CTeam* pTeam = GetGlobalLogicEngine()->GetTeamMgr().GetTeam(nTeamId);
|
||||
if (pTeam)
|
||||
{
|
||||
return pTeam->SetFbId(nFbId);
|
||||
}
|
||||
}
|
||||
|
||||
int getDyanmicVar( lua_State *L )
|
||||
{
|
||||
unsigned int nTeamId = (unsigned int )lua_tonumber(L, 1);
|
||||
if( nTeamId > 0)
|
||||
{
|
||||
CTeam* pTeam = GetGlobalLogicEngine()->GetTeamMgr().GetTeam(nTeamId);
|
||||
if (pTeam)
|
||||
{
|
||||
return LuaCLVariant::returnValue(L, pTeam->GetVar());
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool setTeamTimer( unsigned int nTeamId, unsigned int nExpiredTime )
|
||||
{
|
||||
CTeam* pTeam = GetGlobalLogicEngine()->GetTeamMgr().GetTeam(nTeamId);
|
||||
if (pTeam)
|
||||
{
|
||||
pTeam->SetExpiredTime(nExpiredTime);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
31
server/LogicServer/script/export/TestExportFun.cpp
Normal file
31
server/LogicServer/script/export/TestExportFun.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
#include "StdAfx.h"
|
||||
#include "../interface/TestExportFun.h"
|
||||
|
||||
namespace TestSys
|
||||
{
|
||||
void setLevel(void* sysarg, int nLevel)
|
||||
{
|
||||
CEntity* pEntity = (CEntity *)sysarg;
|
||||
if (!pEntity || pEntity->GetType() != enActor)
|
||||
return;
|
||||
|
||||
((CActor *)pEntity)->SetLevel(nLevel);
|
||||
}
|
||||
|
||||
int addItemById(void* sysarg, int nItemId, int nCount, int nQuality, int nStrong, bool bBind)
|
||||
{
|
||||
CEntity* pEntity = (CEntity *)sysarg;
|
||||
if (!pEntity || pEntity->GetType() != enActor)
|
||||
return 0;
|
||||
|
||||
CUserItemContainer::ItemOPParam itemData;
|
||||
itemData.wItemId = (WORD)nItemId;
|
||||
itemData.wCount = (BYTE)nCount;
|
||||
itemData.btQuality = (BYTE)nQuality;
|
||||
itemData.btStrong = (BYTE)nStrong;
|
||||
itemData.btBindFlag = (BYTE)bBind;
|
||||
return (int)((CActor *)sysarg)->GetBagSystem().AddItem(itemData,
|
||||
pEntity->GetEntityName(),
|
||||
(int)GameLog::clGMAddItem);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user