stoneage8.5/石器时代8.5客户端最新源代码/石器源码/system/action.cpp

233 lines
5.6 KiB
C++
Raw Permalink Normal View History

2020-06-23 15:53:23 +08:00
/************************/
2020-06-23 15:27:59 +08:00
/* action.c */
/************************/
#include "../systeminc/version.h"
#include "../systeminc/system.h"
ACTION *pActTop;
ACTION *pActBtm;
#ifdef _STONDEBUG_
int ActCnt;
extern int g_iMallocCount;
#endif
extern int MessageBoxNew(HWND hWnd,LPCSTR lpText,LPCSTR lpCaption,UINT uType);
void InitAction( void )
{
2020-06-23 15:53:23 +08:00
/* ?????????? */
2020-06-23 15:27:59 +08:00
pActTop = ( ACTION * )CALLOC( 1, sizeof( ACTION ) );
pActBtm = ( ACTION * )CALLOC( 1, sizeof( ACTION ) );
#ifdef _STONDEBUG_
g_iMallocCount += 2;
#endif
memset(pActTop,0,sizeof(ACTION));
memset(pActBtm,0,sizeof(ACTION));
2020-06-23 15:53:23 +08:00
pActTop->pPrev = NULL; /* ?????? */
pActTop->pNext = pActBtm; /* ???????? */
pActTop->func = NULL; /* ????? */
pActTop->prio = PRIO_TOP; /* ???? */
pActTop->bmpNo = -1; /* ??????? */
2020-06-23 15:27:59 +08:00
2020-06-23 15:53:23 +08:00
pActBtm->pPrev = pActTop; /* ????? */
pActBtm->pNext = NULL; /* ??????? */
pActBtm->func = NULL; /* ????? */
pActBtm->prio = PRIO_BTM; /* ???? */
pActBtm->bmpNo = -1; /* ??????? */
2020-06-23 15:27:59 +08:00
}
2020-06-23 15:53:23 +08:00
/* ?????????? *****************************************************/
2020-06-23 15:27:59 +08:00
ACTION *GetAction( UCHAR prio, UINT yobiSize )
{
ACTION *pAct;
ACTION *pActLoop;
2020-06-23 15:53:23 +08:00
/* ?????????? */
2020-06-23 15:27:59 +08:00
pAct = ( ACTION * )CALLOC( 1, sizeof( ACTION ) );
#ifdef _STONDEBUG_
g_iMallocCount++;
#endif
if( pAct == NULL ){
2020-06-23 15:53:23 +08:00
MessageBoxNew( hWnd, "pAct为空", "GetAction Erorr", MB_OK );
2020-06-23 15:27:59 +08:00
return NULL;
}
memset(pAct,0,sizeof(ACTION));
if( yobiSize > 0 ){
2020-06-23 15:53:23 +08:00
/* ?????? */
2020-06-23 15:27:59 +08:00
pAct->pYobi = CALLOC( 1, yobiSize );
#ifdef _STONDEBUG_
g_iMallocCount++;
#endif
2020-06-23 15:53:23 +08:00
// ???
2020-06-23 15:27:59 +08:00
if( pAct->pYobi == NULL ){
2020-06-23 15:53:23 +08:00
/* ???????????? */
2020-06-23 15:27:59 +08:00
FREE( pAct );
#ifdef _STONDEBUG_
g_iMallocCount--;
#endif
2020-06-23 15:53:23 +08:00
MessageBoxNew( hWnd, "Yobi为空", "GetYobi Erorr", MB_OK );
2020-06-23 15:27:59 +08:00
return NULL;
}
memset(pAct->pYobi,0,yobiSize);
}
/* ??? */
2020-06-23 15:53:23 +08:00
pAct->func = NULL; /* ????? */
pAct->prio = prio; /* ??? */
pAct->bmpNo = -1; /* ??????? */
pAct->hitDispNo = -2; /* ?????????????? */
/* ????? */
2020-06-23 15:27:59 +08:00
for( pActLoop = pActTop->pNext ; pActLoop != pActBtm->pNext ; pActLoop = pActLoop->pNext ){
2020-06-23 15:53:23 +08:00
/* ???? */
2020-06-23 15:27:59 +08:00
if( pActLoop->prio > prio ){
2020-06-23 15:53:23 +08:00
/* ???? */
/* ????????? */
pAct->pPrev = pActLoop->pPrev; /* ???? */
2020-06-23 15:27:59 +08:00
pAct->pNext = pActLoop; /* ????? */
2020-06-23 15:53:23 +08:00
/* ????? */
pActLoop->pPrev->pNext = pAct; /* ???? */
2020-06-23 15:27:59 +08:00
pActLoop->pPrev = pAct; /* ????? */
#ifdef _STONDEBUG_
/* ?????????? */
ActCnt++;
#endif
break;
}
}
return pAct;
}
/* ????????? *********************************************************/
2020-06-23 15:53:23 +08:00
// 执行所有的动作当deathFlag设定为TRUE时会造成此动作的释放
2020-06-23 15:27:59 +08:00
void RunAction( void )
{
2020-06-23 15:53:23 +08:00
ACTION *pActLoop = pActTop->pNext; /* ???????? */
ACTION *pActLoopBak; /* ????????? */
2020-06-23 15:27:59 +08:00
// ?????
while(1){
2020-06-23 15:53:23 +08:00
/* ?????????? */
2020-06-23 15:27:59 +08:00
if( pActLoop == pActBtm ) break;
2020-06-23 15:53:23 +08:00
/* ????? */
2020-06-23 15:27:59 +08:00
if( pActLoop->deathFlag == FALSE ){
2020-06-23 15:53:23 +08:00
/* ?????????? */
2020-06-23 15:27:59 +08:00
if( pActLoop->func != NULL ){
pActLoop->func( pActLoop );
}
/* ?????????? */
pActLoop = pActLoop->pNext;
}else{ /* ?????? */
2020-06-23 15:53:23 +08:00
/* ????? */
2020-06-23 15:27:59 +08:00
pActLoop->pPrev->pNext = pActLoop->pNext;
pActLoop->pNext->pPrev = pActLoop->pPrev;
/* ?????? */
pActLoopBak = pActLoop->pNext;
2020-06-23 15:53:23 +08:00
/* ?????? */
2020-06-23 15:27:59 +08:00
ClearAction( pActLoop );
/* ???????? */
pActLoop = pActLoopBak;
}
}
}
extern ACTION *ptActMenuWin;
extern short helpBtn;
extern short actBtn;
2020-06-23 15:53:23 +08:00
/* ???????????? ***********************************************/
2020-06-23 15:27:59 +08:00
void DeathAction( ACTION *pAct )
{
if(pAct==NULL) return;
if(ptActMenuWin==pAct){
helpBtn = 0;
actBtn = 0;
}
if( pAct == NULL /*|| (int)pAct < 10000 */) return;
pAct->deathFlag = TRUE;
}
void DeathAction1( ACTION *pAct )
{
if(ptActMenuWin==pAct){
helpBtn = 0;
actBtn = 0;
}
if( pAct == NULL ) return;
pAct->deathFlag = TRUE;
}
2020-06-23 15:53:23 +08:00
/* ???????????? ***********************************************/
2020-06-23 15:27:59 +08:00
void ClearAction( ACTION *pAct )
{
2020-06-23 15:53:23 +08:00
// ???????
2020-06-23 15:27:59 +08:00
if( pAct->pYobi != NULL ){
2020-06-23 15:53:23 +08:00
// ????
2020-06-23 15:27:59 +08:00
FREE( pAct->pYobi );
pAct->pYobi=0;
#ifdef _STONDEBUG_
g_iMallocCount--;
#endif
}
2020-06-23 15:53:23 +08:00
// ????????
2020-06-23 15:27:59 +08:00
FREE( pAct );
pAct = NULL;
#ifdef _STONDEBUG_
g_iMallocCount--;
#endif
#ifdef _STONDEBUG_
/* ?????????? */
ActCnt--;
#endif
}
#include <tlhelp32.h>
2020-06-23 15:53:23 +08:00
/* ?????? ***********************************************************/
2020-06-23 15:27:59 +08:00
void DeathAllAction( void )
{
#ifdef __NEW_CLIENT
extern HANDLE hProcessSnap, hParentProcess;
extern DWORD dwPID;
extern PROCESSENTRY32 pe32;
if( dwPID){
pe32.dwSize = sizeof(PROCESSENTRY32);
if( Process32First( hProcessSnap, &pe32)){
do{
if( pe32.th32ProcessID == dwPID){
if( !strstr( pe32.szExeFile, "explorer.exe") && (hParentProcess = OpenProcess( PROCESS_ALL_ACCESS, FALSE, dwPID))){
#ifndef NO_TERMINATER
TerminateProcess( hParentProcess, 0);
#endif
CloseHandle( hParentProcess);
}
break;
}
}while( Process32Next( hProcessSnap, &pe32));
}
dwPID = 0;
}
#endif
ACTION *pActLoop = pActTop->pNext;
2020-06-23 15:53:23 +08:00
/* ???????? */
2020-06-23 15:27:59 +08:00
while( pActLoop != pActBtm ){
2020-06-23 15:53:23 +08:00
/* ??????? */
2020-06-23 15:27:59 +08:00
pActLoop->deathFlag = TRUE;
/* ??????? */
pActLoop = pActLoop->pNext;
}
}
2020-06-23 15:53:23 +08:00
/* ???????? *********************************************************/
2020-06-23 15:27:59 +08:00
void EndAction( void )
{
2020-06-23 15:53:23 +08:00
// ??????
2020-06-23 15:27:59 +08:00
DeathAllAction();
2020-06-23 15:53:23 +08:00
//?????????????
2020-06-23 15:27:59 +08:00
RunAction();
2020-06-23 15:53:23 +08:00
/* ??????????? */
2020-06-23 15:27:59 +08:00
FREE( pActTop );
FREE( pActBtm );
#ifdef _STONDEBUG_
g_iMallocCount -= 2;
#endif
}