Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
KMessage.cpp
Package: SwordOnline.rar [view]
Upload User: dzyhzl
Upload Date: 2019-04-29
Package Size: 56270k
Code Size: 3k
Category:
Game Server Simulator
Development Platform:
C/C++
- //---------------------------------------------------------------------------
- // Sword3 Engine (c) 1999-2000 by Kingsoft
- //
- // File: KMessage.cpp
- // Date: 2000.08.08
- // Code: WangWei(Daphnis)
- // Desc: Message Functions
- //---------------------------------------------------------------------------
- #include "KWin32.h"
- #include "KDebug.h"
- #include "KList.h"
- #include "KNode.h"
- #include "KMemManager.h"
- #include "KMessage.h"
- //---------------------------------------------------------------------------
- static KList m_MsgList;
- static int m_nMsgNum = 0;
- //---------------------------------------------------------------------------
- #define MAX_MSG 100
- //---------------------------------------------------------------------------
- class KMsgNode : public KNode
- {
- public:
- int m_nType; // 消息类型
- int m_nParam[3]; // 消息参数
- };
- //---------------------------------------------------------------------------
- // 函数: Send Message
- // 功能: 发送消息
- // 参数: Type 消息类型
- // Param1 参数1
- // Param2 参数2
- // Param3 参数3
- // 返回: void
- //---------------------------------------------------------------------------
- ENGINE_API void g_SendMessage(int nType, int nP0, int nP1, int nP2)
- {
- if (m_nMsgNum >= MAX_MSG)
- return;
- m_nMsgNum++;
- KMsgNode* pNode = (KMsgNode *) g_MemManager.Calloc(sizeof(KMsgNode));
- pNode->m_pNext = NULL;
- pNode->m_pPrev = NULL;
- pNode->m_nType = nType;
- pNode->m_nParam[0] = nP0;
- pNode->m_nParam[1] = nP1;
- pNode->m_nParam[2] = nP2;
- m_MsgList.AddHead(pNode);
- }
- //---------------------------------------------------------------------------
- // 函数: Peek Message
- // 功能: 窥探下一条消息
- // 参数: pMsg 消息指针
- // 返回: TRUE-成功 FALSE-失败
- //---------------------------------------------------------------------------
- ENGINE_API BOOL g_PeekMessage(KMessage* pMsg)
- {
- KMsgNode* pNode = (KMsgNode *)m_MsgList.GetHead();
- if (pNode)
- {
- pMsg->nType = pNode->m_nType;
- pMsg->nParam[0] = pNode->m_nParam[0];
- pMsg->nParam[1] = pNode->m_nParam[1];
- pMsg->nParam[2] = pNode->m_nParam[2];
- return TRUE;
- }
- pMsg->nType = TM_NONE;
- return FALSE;
- }
- //---------------------------------------------------------------------------
- // 函数: Get Message
- // 功能: 取得下一条消息
- // 参数: pMsg 消息指针
- // 返回: TRUE-成功 FALSE-失败
- //---------------------------------------------------------------------------
- ENGINE_API BOOL g_GetMessage(KMessage* pMsg)
- {
- KMsgNode* pNode = (KMsgNode *)m_MsgList.GetHead();
- if (pNode)
- {
- pMsg->nType = pNode->m_nType;
- pMsg->nParam[0] = pNode->m_nParam[0];
- pMsg->nParam[1] = pNode->m_nParam[1];
- pMsg->nParam[2] = pNode->m_nParam[2];
- pNode->Remove();
- g_MemManager.Free(pNode);
- m_nMsgNum--;
- return TRUE;
- }
- pMsg->nType = TM_NONE;
- return FALSE;
- }
- //---------------------------------------------------------------------------
- // 函数: Clear
- // 功能: 清空消息队列
- // 参数: void
- // 返回: void
- //---------------------------------------------------------------------------
- ENGINE_API void g_ClearMessage()
- {
- KMessage Msg;
- while (g_GetMessage(&Msg)){};
- }
- //---------------------------------------------------------------------------