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

233 lines
5.5 KiB
C++
Raw Normal View History

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 )
{
/* ??????????<3F><><EFBFBD>x */
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));
pActTop->pPrev = NULL; /* <20>q?????<3F><>? */
pActTop->pNext = pActBtm; /* ????????<3F><> */
pActTop->func = NULL; /* <20><>????<3F><>? */
pActTop->prio = PRIO_TOP; /* ?<3F>I???<3F><> */
pActTop->bmpNo = -1; /* ???<3F>k???? */
pActBtm->pPrev = pActTop; /* <20>q?????<3F>I<EFBFBD>d */
pActBtm->pNext = NULL; /* ??????<3F><>? */
pActBtm->func = NULL; /* <20><>????<3F><>? */
pActBtm->prio = PRIO_BTM; /* ?<3F>I???<3F>^ */
pActBtm->bmpNo = -1; /* ???<3F>k???? */
}
/* ?????????<3F>K? *****************************************************/
ACTION *GetAction( UCHAR prio, UINT yobiSize )
{
ACTION *pAct;
ACTION *pActLoop;
/* ??????<3F>B<EFBFBD>l????<3F><> */
pAct = ( ACTION * )CALLOC( 1, sizeof( ACTION ) );
#ifdef _STONDEBUG_
g_iMallocCount++;
#endif
if( pAct == NULL ){
MessageBoxNew( hWnd, "pActΪ<EFBFBD><EFBFBD>", "GetAction Erorr", MB_OK );
return NULL;
}
memset(pAct,0,sizeof(ACTION));
if( yobiSize > 0 ){
/* ?<3F><>?<3F>B<EFBFBD>l????<3F><> */
pAct->pYobi = CALLOC( 1, yobiSize );
#ifdef _STONDEBUG_
g_iMallocCount++;
#endif
// <20><><EFBFBD><EFBFBD>???
if( pAct->pYobi == NULL ){
/* ??????<3F>B<EFBFBD>l??????<3F><> */
FREE( pAct );
#ifdef _STONDEBUG_
g_iMallocCount--;
#endif
MessageBoxNew( hWnd, "YobiΪ<EFBFBD><EFBFBD>", "GetYobi Erorr", MB_OK );
return NULL;
}
memset(pAct->pYobi,0,yobiSize);
}
/* ??? */
pAct->func = NULL; /* <20><>????<3F><>? */
pAct->prio = prio; /* ?<3F>I?? */
pAct->bmpNo = -1; /* ???<3F>k???? */
pAct->hitDispNo = -2; /* ??????????<3F>R<EFBFBD>e<EFBFBD>k???? */
/* ?<3F>I??<3F><>?? */
for( pActLoop = pActTop->pNext ; pActLoop != pActBtm->pNext ; pActLoop = pActLoop->pNext ){
/* ?<3F>I<EFBFBD>T?<3F>^?? */
if( pActLoop->prio > prio ){
/* ??<3F><>?<3F>D? */
/* <20>q????????? */
pAct->pPrev = pActLoop->pPrev; /* <20>q???? */
pAct->pNext = pActLoop; /* ????? */
/* <20>q????? */
pActLoop->pPrev->pNext = pAct; /* <20>q???? */
pActLoop->pPrev = pAct; /* ????? */
#ifdef _STONDEBUG_
/* ?????????? */
ActCnt++;
#endif
break;
}
}
return pAct;
}
/* ????????? *********************************************************/
// ִ<><D6B4><EFBFBD><EFBFBD><EFBFBD>еĶ<D0B5><C4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>deathFlag<61>趨ΪTRUEʱ<45><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɴ˶<C9B4><CBB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD>
void RunAction( void )
{
ACTION *pActLoop = pActTop->pNext; /* <20>I<EFBFBD>d????????<3F><><EFBFBD>x */
ACTION *pActLoopBak; /* ?<3F><>???????? */
// ?????
while(1){
/* ??<3F><>???????? */
if( pActLoop == pActBtm ) break;
/* <20><>????? */
if( pActLoop->deathFlag == FALSE ){
/* ?????????<3F><>? */
if( pActLoop->func != NULL ){
pActLoop->func( pActLoop );
}
/* ?????????? */
pActLoop = pActLoop->pNext;
}else{ /* ?????? */
/* <20>q????? */
pActLoop->pPrev->pNext = pActLoop->pNext;
pActLoop->pNext->pPrev = pActLoop->pPrev;
/* ?????? */
pActLoopBak = pActLoop->pNext;
/* ??????<3F><> */
ClearAction( pActLoop );
/* ???????? */
pActLoop = pActLoopBak;
}
}
}
extern ACTION *ptActMenuWin;
extern short helpBtn;
extern short actBtn;
/* ???????????<3F><>?<3F><> ***********************************************/
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;
}
/* ???????????<3F>u?<3F><> ***********************************************/
void ClearAction( ACTION *pAct )
{
// ?<3F><>?<3F>B<EFBFBD>l?????
if( pAct->pYobi != NULL ){
// ?<3F><>?<3F>B<EFBFBD>l??<3F><>
FREE( pAct->pYobi );
pAct->pYobi=0;
#ifdef _STONDEBUG_
g_iMallocCount--;
#endif
}
// ??????<3F>B<EFBFBD>l??<3F><>
FREE( pAct );
pAct = NULL;
#ifdef _STONDEBUG_
g_iMallocCount--;
#endif
#ifdef _STONDEBUG_
/* ?????????? */
ActCnt--;
#endif
}
#include <tlhelp32.h>
/* <20>u??????<3F><> ***********************************************************/
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;
/* ???????<3F><>? */
while( pActLoop != pActBtm ){
/* ?<3F><>?????? */
pActLoop->deathFlag = TRUE;
/* ??????? */
pActLoop = pActLoop->pNext;
}
}
/* ?????<3F><>??? *********************************************************/
void EndAction( void )
{
// <20>u??????<3F><>
DeathAllAction();
//???????????<3F>u?<3F><>?
RunAction();
/* ???????????<3F><> */
FREE( pActTop );
FREE( pActBtm );
#ifdef _STONDEBUG_
g_iMallocCount -= 2;
#endif
}