callbackfnx.cpp

来自「小时候玩过的在纸上画的小游戏」· C++ 代码 · 共 64 行

CPP
64
字号
/*
Copyright (c)  2005  william.
      Permission is granted to copy, distribute and/or modify this document
      under the terms of the GNU Free Documentation License, Version 1.2
      or any later version published by the Free Software Foundation;
      with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
	 Texts.  A copy of the license is included in the section entitled "GNU
      Free Documentation License".
*/
#include "stdafx.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif

typedef CbombplaneDlg CBPD;
typedef bool (CBPD::* _CBPD_FUNC)(CMsg* rcv_msg);

_CBPD_FUNC CBPD_FUNC[8]={
	CBPD::OnRcvNone,
	CBPD::OnRcvPos,
	CBPD::OnRcvChat,
	CBPD::OnRcvConn,
	CBPD::OnRcvDisc,
	CBPD::OnRcvStart,
	CBPD::OnRcvHit,
	CBPD::OnRcvLose
};

//false if the connection has disconnected.
//true for nothing.
//and,this msg argument will no onger exist 
bool Dispatch(CMsg* msg)
{
   CBPD* MainDlg = CBPD::This;
	ASSERT(MainDlg!=0);

	int whichFnx = (int)msg->GetMsgState();
   if(whichFnx>10)whichFnx-=10;
	ASSERT(whichFnx>=0 && whichFnx<=20);
	return ((MainDlg->*CBPD_FUNC[whichFnx]))(msg);
}

//disconnect for abnormal condition
void DisConnect(UINT info)
{
	CBPD* MainDlg = CBPD::This;
	ASSERT(MainDlg!=0);
	MainDlg->OnErrorDisc(info);
}

void onAccept(CCntSock** out)
{
   CBPD* MainDlg = CBPD::This;
	ASSERT(MainDlg!=0);
	*out =MainDlg->OnAccept();
}

void SetGuide(UINT IDS_id)
{
   CBPD* MainDlg = CBPD::This;
	ASSERT(MainDlg!=0);
	MainDlg->SetGameGuide(IDS_id);
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?