"undeclared identifier" definition

nod77

New member
Joined
Jul 3, 2008
Messages
21
Reaction score
0
Points
0
As I explained in one of my recent posts, I had to wait for the next build before a fix htw put in for me was out. In the mean time I've been doing my own build. Well, now that I've had to do my own build, I'm really having fun learning to make stuff. I'd like my clip plane to be adjusted based on the zone population. I found where someone had done it in this post; http://www.macroquest2.com/phpBB3/viewtopic.php?f=31&t=17851

I'm running into trouble when I try to compile it. I'm getting the error, "MQ2AutoClip.cpp(62): error C2065: 'PCcount' : undeclared identifier".

The problem starts right here;
Code:
         if (GetSpawnType(pSpawn)==PC) {
            PCcount++;
            }

My question; Is it not properly declared inside this file or is it that it used to be declared in one of the core Macroquest files that makes up say, MQ2Main and has been changed to something else?

Thanks for your time in advance,

-nod77


Code:
// MQ2AutoClip - Reduces Player Clip Plane when too many PCs in zone
// Most code taken from MQ2Clip and revised for Player Count
#define SKIP_REDRAW 4
#define MAX_CLIP 1800.0f
#define MIN_CLIP 75.0f
#include "../MQ2Plugin.h"

PreSetup("MQ2AutoClip");

bool bInBackground=false;
float fGoodPlayerCount = 75;
float fForegroundClip = MAX_CLIP;
HMODULE EQWhMod=0;
typedef HWND   (__stdcall *fEQW_GetDisplayWindow)(VOID);
fEQW_GetDisplayWindow EQW_GetDisplayWindow=0;

VOID GoodPCCommand(PSPAWNINFO pChar, PCHAR szLine)
{
   char szTemp[MAX_STRING];
   GetArg(szTemp,szLine,1);
   if (IsNumber(szTemp)) {
      fGoodPlayerCount = (float)atof(szTemp);
   }
   WriteChatf("GoodPlayerCount is %0.3f",fGoodPlayerCount);
}

PLUGIN_API VOID OnZoned(VOID)
{
   PZONEINFO ZoneInfo = (PZONEINFO)pZoneInfo;
   ZoneInfo->MinClip = MIN_CLIP;
   ZoneInfo->MaxClip = MAX_CLIP;
}

PLUGIN_API VOID OnDrawHUD(VOID)
{
   static int N=0;
   if (gGameState==GAMESTATE_INGAME && ++N>SKIP_REDRAW) {
      N = 0;
      HWND EQhWnd = *(HWND*)EQADDR_HWND;
      PZONEINFO ZoneInfo = (PZONEINFO)pZoneInfo;
      PSPAWNINFO pSpawn = (PSPAWNINFO)pSpawnList;
      PSPAWNINFO pChar = GetCharInfo()->pSpawn;
       while (pSpawn)
       {    
         if (GetSpawnType(pSpawn)==PC) {
            PCcount++;
            }
         pSpawn=pSpawn->pNext;
       }
      if (EQW_GetDisplayWindow) EQhWnd=EQW_GetDisplayWindow();
      if (GetForegroundWindow()==EQhWnd) { // EQ in foreground
         if (bInBackground) { // just got focus
            DebugSpewAlways("MQ2AutoClip:: Foreground Mode (Restoring clip plane)");
            bInBackground = false;
            ZoneInfo->MaxClip = fForegroundClip;
            return;
         }
         if ( (fGoodPlayerCount > PCcount) && (ZoneInfo->MaxClip < MAX_CLIP) ) {
            ZoneInfo->MaxClip += 5;
            DebugSpewAlways("MQ2AutoClip:: Upping clip plane");
         }
         if ( (fGoodPlayerCount < PCcount) && (ZoneInfo->MaxClip > ZoneInfo->MinClip) ) {
            ZoneInfo->MaxClip -= 5;
            DebugSpewAlways("MQ2AutoClip:: Dropping clip plane");
         }
      } else { // EQ in background
         if (!bInBackground) {
            DebugSpewAlways("MQ2AutoClip:: Background Mode (Saving clip plane)");
            bInBackground = true;
            fForegroundClip = ZoneInfo->MaxClip;
            ZoneInfo->MaxClip = ZoneInfo->MinClip;
         }
      }
   }
}

PLUGIN_API VOID SetGameState(DWORD GameState)
{
   if (GameState == GAMESTATE_INGAME) OnZoned();
   return;
}

PLUGIN_API VOID OnCleanUI()
{
   OnZoned();
   return;
}

PLUGIN_API VOID InitializePlugin(VOID)
{
   DebugSpewAlways("Initializing MQ2AutoClip");
   AddCommand("/goodpc",GoodPCCommand);
}

PLUGIN_API VOID ShutdownPlugin(VOID)
{
   DebugSpewAlways("Shutting down MQ2AutoClip");
   RemoveCommand("/goodpc");
}
 
Last edited:
No, that's just an error by the author. That variable is not used anywhere except in OnDrawHUD(), so you should just add the declaration and initialize it to zero.

Code:
PLUGIN_API VOID OnDrawHUD(VOID) 
{    
  static int N=0;    
  int PCcount = 0;
  if (gGameState==GAMESTATE_INGAME && ++N>SKIP_REDRAW) {
       N = 0;
      // rest of code

htw
 
Thanks htw, that did it and it compiled for me!

-nod77