mirror of
https://github.com/unknownworlds/NS.git
synced 2025-01-18 23:11:49 +00:00
o Added labelled minimaps
git-svn-id: https://unknownworlds.svn.cloudforge.com/ns1@198 67975925-1194-0748-b3d5-c16f83f1a3a1
This commit is contained in:
parent
2581c48cfc
commit
dae5cc64f9
7 changed files with 196 additions and 161 deletions
|
@ -92,6 +92,7 @@ cl_forcedefaultfov "0"
|
|||
cl_highdetail "1"
|
||||
cl_himodels "0"
|
||||
cl_idealpitchscale "0.8"
|
||||
cl_labelmaps "1"
|
||||
cl_lc "1"
|
||||
cl_logocolor "#Valve_Orange"
|
||||
cl_logofile "lambda"
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1999, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
|
@ -32,6 +32,7 @@
|
|||
#include "ui/UIComponent.h"
|
||||
#include "vgui_scorepanel.h"
|
||||
|
||||
#include "mod/AvHClientVariables.h"
|
||||
#include "mod/ChatPanel.h"
|
||||
|
||||
class CHLVoiceStatusHelper : public IVoiceStatusHelper
|
||||
|
@ -257,7 +258,7 @@ int __MsgFunc_RandomPC(const char *pszName, int iSize, void *pbuf)
|
|||
return gViewPort->MsgFunc_RandomPC( pszName, iSize, pbuf );
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int __MsgFunc_ServerName(const char *pszName, int iSize, void *pbuf)
|
||||
{
|
||||
if (gViewPort)
|
||||
|
@ -356,6 +357,7 @@ void CHud :: Init( void )
|
|||
cl_lw = gEngfuncs.pfnGetCvarPointer( "cl_lw" );
|
||||
|
||||
CVAR_CREATE( "cl_showspeed", "0", 0);
|
||||
CVAR_CREATE( kvLabelMaps, "0", FCVAR_ARCHIVE);
|
||||
|
||||
m_pSpriteList = NULL;
|
||||
|
||||
|
@ -389,13 +391,13 @@ void CHud :: Init( void )
|
|||
m_AmmoSecondary.Init();
|
||||
m_TextMessage.Init();
|
||||
m_StatusIcons.Init();
|
||||
|
||||
|
||||
m_Spectator.m_chatEnabled = (m_SayText.m_HUD_saytext->value!=0);
|
||||
|
||||
|
||||
GetClientVoiceMgr()->Init(&g_VoiceStatusHelper, (vgui::Panel**)&gViewPort);
|
||||
|
||||
m_Menu.Init();
|
||||
|
||||
|
||||
ServersInit();
|
||||
|
||||
MsgFunc_ResetHUD(0, 0, NULL );
|
||||
|
@ -460,8 +462,8 @@ void CHud :: VidInit( void )
|
|||
// Load Sprites
|
||||
// ---------
|
||||
// m_hsprFont = LoadSprite("sprites/%d_font.spr");
|
||||
|
||||
m_hsprLogo = 0;
|
||||
|
||||
m_hsprLogo = 0;
|
||||
m_hsprCursor = 0;
|
||||
|
||||
if (ScreenWidth() < 640)
|
||||
|
@ -577,15 +579,15 @@ void COM_FileBase ( const char *in, char *out)
|
|||
int len, start, end;
|
||||
|
||||
len = strlen( in );
|
||||
|
||||
|
||||
// scan backward for '.'
|
||||
end = len - 1;
|
||||
while ( end && in[end] != '.' && in[end] != '/' && in[end] != '\\' )
|
||||
end--;
|
||||
|
||||
|
||||
if ( in[end] != '.' ) // no '.', copy to end
|
||||
end = len-1;
|
||||
else
|
||||
else
|
||||
end--; // Found ',', copy to left of '.'
|
||||
|
||||
|
||||
|
@ -596,7 +598,7 @@ void COM_FileBase ( const char *in, char *out)
|
|||
|
||||
if ( in[start] != '/' && in[start] != '\\' )
|
||||
start = 0;
|
||||
else
|
||||
else
|
||||
start++;
|
||||
|
||||
// Length of new sting
|
||||
|
@ -684,12 +686,12 @@ int CHud::MsgFunc_SetFOV(const char *pszName, int iSize, void *pbuf)
|
|||
|
||||
// Set a new sensitivity
|
||||
if ( m_iFOV == def_fov )
|
||||
{
|
||||
{
|
||||
// reset to saved sensitivity
|
||||
m_flMouseSensitivity = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
// set a new sensitivity that is proportional to the change from the FOV default
|
||||
m_flMouseSensitivity = sensitivity->value * ((float)newfov / (float)def_fov) * CVAR_GET_FLOAT("zoom_sensitivity_ratio");
|
||||
}
|
||||
|
|
|
@ -35,6 +35,9 @@ extern cvar_t* cl_musicdir;
|
|||
|
||||
// Variables
|
||||
#define kvAutoHelp "cl_autohelp"
|
||||
// puzl: 1064 The cl var that controls the display of labelled minimaps
|
||||
#define kvLabelMaps "cl_labelmaps"
|
||||
// :puzl
|
||||
#define kvCMHotKeys "cl_cmhotkeys"
|
||||
#define kvForceDefaultFOV "cl_forcedefaultfov"
|
||||
#define kvCenterEntityID "cl_centerentityid"
|
||||
|
|
|
@ -14,7 +14,7 @@ const int kGroundEndPaletteIndex = 254;
|
|||
const int kHitNothingPaletteIndex = 255;
|
||||
|
||||
#ifdef AVH_SERVER
|
||||
// Network message:
|
||||
// Network message:
|
||||
// 0: means start processing, pass map name then num samples to process, map width, map height
|
||||
// 1: means update, pass num pixels, then data
|
||||
// 2: means end processing
|
||||
|
@ -56,7 +56,7 @@ AvHMiniMap::~AvHMiniMap()
|
|||
bool AvHMiniMap::GetIsProcessing(float* outPercentageDone) const
|
||||
{
|
||||
bool theIsProcessing = false;
|
||||
|
||||
|
||||
if(this->mIsProcessing)
|
||||
{
|
||||
if(outPercentageDone)
|
||||
|
@ -65,7 +65,7 @@ bool AvHMiniMap::GetIsProcessing(float* outPercentageDone) const
|
|||
}
|
||||
theIsProcessing = true;
|
||||
}
|
||||
|
||||
|
||||
return theIsProcessing;
|
||||
}
|
||||
|
||||
|
@ -99,7 +99,7 @@ void AvHMiniMap::BuildMiniMap(const char* inMapName, AvHPlayer* inPlayer, const
|
|||
|
||||
this->mMinViewHeight = inMapExtents.GetMinViewHeight();//inMinViewHeight;
|
||||
this->mMaxViewHeight = inMapExtents.GetMaxViewHeight();//inMaxViewHeight;
|
||||
|
||||
|
||||
this->mIsProcessing = true;
|
||||
|
||||
// Tell player to rebuild minimap
|
||||
|
@ -115,55 +115,55 @@ void AvHMiniMap::BuildMiniMap(const char* inMapName, AvHPlayer* inPlayer, const
|
|||
bool AvHMiniMap::Process()
|
||||
{
|
||||
bool theProcessingComplete = false;
|
||||
|
||||
|
||||
if(this->GetIsProcessing())
|
||||
{
|
||||
// Process x pixels
|
||||
// If we've calculated them all, return true
|
||||
|
||||
|
||||
// positive y on component is down, but that means negative y in world
|
||||
float theDiffY = this->mMaxY - this->mMinY;
|
||||
|
||||
|
||||
// left to right
|
||||
float theDiffX = this->mMaxX - this->mMinX;
|
||||
|
||||
|
||||
// Preserve map aspect ratio
|
||||
float theMapAspectRatio = (this->mMaxX - this->mMinX)/(this->mMaxY - this->mMinY);
|
||||
|
||||
|
||||
float theXScale, theYScale;
|
||||
if(theMapAspectRatio > 1.0f)
|
||||
{
|
||||
theXScale = 1.0f;
|
||||
theYScale = 1.0f/theMapAspectRatio;
|
||||
theYScale = 1.0f/theMapAspectRatio;
|
||||
}
|
||||
else
|
||||
{
|
||||
theXScale = 1.0f/theMapAspectRatio;
|
||||
theXScale = 1.0f/theMapAspectRatio;
|
||||
theYScale = 1.0f;
|
||||
}
|
||||
|
||||
|
||||
float theMapCenterX = (this->mMinX + this->mMaxX)/2.0f;
|
||||
float theMapCenterY = (this->mMinY + this->mMaxY)/2.0f;
|
||||
|
||||
const int kNumPixelsPerCall = 50;
|
||||
char theSampleArray[kNumPixelsPerCall];
|
||||
memset(theSampleArray, 0, kNumPixelsPerCall);
|
||||
|
||||
|
||||
for(int i = 0; (i < kNumPixelsPerCall) && (this->mNumSamplesProcessed < this->mNumSamplesToProcess); i++)
|
||||
{
|
||||
int theSampleIndex = this->mNumSamplesProcessed;
|
||||
int theX = theSampleIndex % this->mMapWidth;
|
||||
int theY = theSampleIndex/this->mMapWidth;
|
||||
|
||||
|
||||
// Initialize the value to outside the map
|
||||
int theValue = kHitNothingPaletteIndex;
|
||||
|
||||
|
||||
// Account for map center and aspect ratio
|
||||
float theXComponent = (theX/(float)this->mMapWidth) - .5f;
|
||||
float theYComponent = (theY/(float)this->mMapHeight) - .5f;
|
||||
float theCurrentX = theMapCenterX + theXComponent*theDiffX*theXScale;
|
||||
float theCurrentY = theMapCenterY - theYComponent*theDiffY*theYScale;
|
||||
|
||||
|
||||
// If the point is inside our map boundaries, do the trace
|
||||
if((theCurrentX >= this->mMinX) && (theCurrentX <= this->mMaxX) && (theCurrentY >= this->mMinY) && (theCurrentY <= this->mMaxY))
|
||||
{
|
||||
|
@ -172,27 +172,27 @@ bool AvHMiniMap::Process()
|
|||
int theUserThree = 0;
|
||||
float theHitHeight;
|
||||
float theHeightGradient = 0.0f;
|
||||
|
||||
|
||||
if(AvHSHUTraceVerticalTangible(theCurrentX, theCurrentY, this->mMaxViewHeight, theUserThree, theHitHeight))
|
||||
{
|
||||
// TODO: Modify trace to return world brushes that are hit
|
||||
// Set color to "world brush hit", it will be changed if an entity was hit
|
||||
theValue = kHitWorldPaletteIndex;
|
||||
|
||||
|
||||
|
||||
theHitHeight = min(mMaxViewHeight, max(theHitHeight, mMinViewHeight));
|
||||
theHeightGradient = 1.0f - (this->mMaxViewHeight - theHitHeight)/(this->mMaxViewHeight - this->mMinViewHeight);
|
||||
theValue = kGroundStartPaletteIndex + (kGroundEndPaletteIndex - kGroundStartPaletteIndex)*theHeightGradient;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int theIndex = theX + theY*this->mMapWidth;
|
||||
ASSERT(theIndex < this->mNumSamplesToProcess);
|
||||
this->mMap[theIndex] = theValue;
|
||||
|
||||
theSampleArray[i] = theValue;
|
||||
|
||||
|
||||
this->mNumSamplesProcessed++;
|
||||
}
|
||||
|
||||
|
@ -208,7 +208,7 @@ bool AvHMiniMap::Process()
|
|||
WRITE_BYTE(theSampleArray[j]);
|
||||
}
|
||||
MESSAGE_END();
|
||||
|
||||
|
||||
if(this->mNumSamplesProcessed == this->mNumSamplesToProcess)
|
||||
{
|
||||
theProcessingComplete = true;
|
||||
|
@ -219,7 +219,7 @@ bool AvHMiniMap::Process()
|
|||
MESSAGE_END();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return theProcessingComplete;
|
||||
}
|
||||
|
||||
|
@ -227,13 +227,18 @@ bool AvHMiniMap::Process()
|
|||
|
||||
|
||||
#ifdef AVH_CLIENT
|
||||
string AvHMiniMap::GetSpriteNameFromMap(int inSpriteWidth, const string& inMapName)
|
||||
string AvHMiniMap::GetSpriteNameFromMap(int inSpriteWidth, const string& inMapName, int useLabels)
|
||||
{
|
||||
char theWidthString[128];
|
||||
sprintf(theWidthString, "%d", inSpriteWidth);
|
||||
|
||||
string theMiniMapName = kMiniMapSpritesDirectory + string("/") /*+ string(theWidthString)*/ + inMapName + string(".spr");
|
||||
//string theMiniMapName = kMiniMapSpritesDirectory + string("/") + inMapName + string(".spr");
|
||||
// puzl: 1064
|
||||
// insert _labelled into the filename before ".spr"
|
||||
string extraname="";
|
||||
if ( useLabels == 1 ) {
|
||||
extraname="_labelled";
|
||||
}
|
||||
string theMiniMapName = kMiniMapSpritesDirectory + string("/") /*+ string(theWidthString)*/ + inMapName + extraname + string(".spr");
|
||||
// :puzl
|
||||
return theMiniMapName;
|
||||
}
|
||||
|
||||
|
@ -246,13 +251,13 @@ void AvHMiniMap::InitializePalette()
|
|||
// char theFillChar = i % 256;
|
||||
// memset(this->mMap + i*this->mMapWidth, theFillChar, this->mMapWidth);
|
||||
// }
|
||||
//
|
||||
|
||||
//
|
||||
|
||||
// Set colors in image to use palette
|
||||
memset(this->mPalette, 0, 256*3);
|
||||
|
||||
float theGradient = 0.0f;
|
||||
|
||||
|
||||
for(int i = 0; i < 256; i++)
|
||||
{
|
||||
const int kHitWorldR = 29;
|
||||
|
@ -264,11 +269,11 @@ void AvHMiniMap::InitializePalette()
|
|||
const int kBorderB = 189;
|
||||
|
||||
uint8* theColor = this->mPalette + i*3;
|
||||
|
||||
|
||||
if (i >= kGroundStartPaletteIndex && i <= kGroundEndPaletteIndex)
|
||||
{
|
||||
// Ground start to end
|
||||
|
||||
|
||||
// Set color according to height, blending to hit world color
|
||||
theGradient = (float)(i - kGroundStartPaletteIndex)/(kGroundEndPaletteIndex - kGroundStartPaletteIndex);
|
||||
theColor[0] = (int)(theGradient*kHitWorldR);
|
||||
|
@ -287,7 +292,7 @@ void AvHMiniMap::InitializePalette()
|
|||
}
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
switch(i)
|
||||
{
|
||||
// On map but inaccessible
|
||||
|
@ -296,7 +301,7 @@ void AvHMiniMap::InitializePalette()
|
|||
theColor[1] = 0;
|
||||
theColor[2] = 0;
|
||||
break;
|
||||
|
||||
|
||||
case kHitWorldPaletteIndex:
|
||||
theColor[0] = kHitWorldR;
|
||||
theColor[1] = kHitWorldG;
|
||||
|
@ -310,7 +315,7 @@ void AvHMiniMap::InitializePalette()
|
|||
theColor[2] = 189;
|
||||
break;
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -343,7 +348,7 @@ int AvHMiniMap::ReceiveFromNetworkStream()
|
|||
|
||||
this->mMapHeight = READ_LONG();
|
||||
theBytesRead += 4;
|
||||
|
||||
|
||||
this->mMap = new uint8[this->mNumSamplesToProcess];
|
||||
memset(this->mMap, 0, this->mNumSamplesToProcess);
|
||||
|
||||
|
@ -386,7 +391,7 @@ bool AvHMiniMap::WriteMapToSprite()
|
|||
if(!this->GetIsProcessing())
|
||||
{
|
||||
// Open file
|
||||
string theSpriteFileName = string(getModDirectory()) + string("/") + GetSpriteNameFromMap(0, this->mMapName);
|
||||
string theSpriteFileName = string(getModDirectory()) + string("/") + GetSpriteNameFromMap(0, this->mMapName, 0);
|
||||
FILE* theFile = fopen(theSpriteFileName.c_str(), "wb");
|
||||
if(theFile)
|
||||
{
|
||||
|
@ -395,17 +400,17 @@ bool AvHMiniMap::WriteMapToSprite()
|
|||
|
||||
// Copy data
|
||||
memcpy(this->mSpriteData, this->mMap, kSpriteWidth*kSpriteHeight);
|
||||
|
||||
|
||||
int theNumFrames = 1;
|
||||
this->WriteMapToSprite(theFile);
|
||||
|
||||
|
||||
fclose(theFile);
|
||||
|
||||
|
||||
theSuccess = true;
|
||||
}
|
||||
}
|
||||
|
||||
return theSuccess;
|
||||
|
||||
return theSuccess;
|
||||
}
|
||||
|
||||
void AvHMiniMap::WriteMapToSprite(FILE* inFileHandle)
|
||||
|
@ -415,7 +420,7 @@ void AvHMiniMap::WriteMapToSprite(FILE* inFileHandle)
|
|||
|
||||
const int spriteWidth = 256;
|
||||
const int spriteHeight = 256;
|
||||
|
||||
|
||||
int numXFrames = mMapWidth / spriteWidth;
|
||||
int numYFrames = mMapHeight / spriteHeight;
|
||||
|
||||
|
@ -436,9 +441,9 @@ void AvHMiniMap::WriteMapToSprite(FILE* inFileHandle)
|
|||
spritetemp.synctype = ST_SYNC;
|
||||
spritetemp.version = SPRITE_VERSION;
|
||||
spritetemp.ident = IDSPRITEHEADER;
|
||||
|
||||
|
||||
SafeWrite(inFileHandle, &spritetemp, sizeof(spritetemp));
|
||||
|
||||
|
||||
short cnt = 256;
|
||||
SafeWrite(inFileHandle, (void *) &cnt, sizeof(cnt));
|
||||
SafeWrite(inFileHandle, this->mPalette, cnt*3);
|
||||
|
@ -450,14 +455,14 @@ void AvHMiniMap::WriteMapToSprite(FILE* inFileHandle)
|
|||
|
||||
spriteframetype_t theType = SPR_SINGLE;
|
||||
SafeWrite ( inFileHandle, &theType, sizeof(theType));
|
||||
|
||||
|
||||
dspriteframe_t frametemp;
|
||||
|
||||
|
||||
frametemp.origin[0] = 0;
|
||||
frametemp.origin[1] = 0;
|
||||
frametemp.width = spriteWidth;
|
||||
frametemp.height = spriteHeight;
|
||||
|
||||
|
||||
SafeWrite (inFileHandle, &frametemp, sizeof (frametemp));
|
||||
|
||||
for (int i = 0; i < spriteHeight; ++i)
|
||||
|
@ -470,14 +475,14 @@ void AvHMiniMap::WriteMapToSprite(FILE* inFileHandle)
|
|||
|
||||
spriteframetype_t theType = SPR_SINGLE;
|
||||
SafeWrite ( inFileHandle, &theType, sizeof(theType));
|
||||
|
||||
|
||||
dspriteframe_t frametemp;
|
||||
|
||||
|
||||
frametemp.origin[0] = 0;
|
||||
frametemp.origin[1] = 0;
|
||||
frametemp.width = kSpriteWidth / 2;
|
||||
frametemp.height = kSpriteHeight / 2;
|
||||
|
||||
|
||||
SafeWrite (inFileHandle, &frametemp, sizeof (frametemp));
|
||||
SafeWrite (inFileHandle, mCommanderSpriteData, kSpriteDataPixels / 4);
|
||||
|
||||
|
@ -500,11 +505,11 @@ bool AvHMiniMap::WriteSpritesIfJustFinished()
|
|||
{
|
||||
for (int y = 0; y < kSpriteHeight / 2; ++y)
|
||||
{
|
||||
mCommanderSpriteData[x + y * (kSpriteWidth / 2)] =
|
||||
mCommanderSpriteData[x + y * (kSpriteWidth / 2)] =
|
||||
mMap[(x * 2) + (y * 2) * kSpriteWidth];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
this->DrawEdges(mMap, kSpriteWidth, kSpriteHeight);
|
||||
this->DrawEdges(mCommanderSpriteData, kSpriteWidth / 2, kSpriteHeight / 2);
|
||||
|
||||
|
@ -516,7 +521,7 @@ bool AvHMiniMap::WriteSpritesIfJustFinished()
|
|||
this->mNumSamplesProcessed = this->mNumSamplesToProcess = 0;
|
||||
this->mIsProcessing = false;
|
||||
}
|
||||
|
||||
|
||||
// For each resolution
|
||||
return theSuccess;
|
||||
}
|
||||
|
@ -528,14 +533,14 @@ void AvHMiniMap::DrawEdges(uint8* inMap, int width, int height)
|
|||
uint8* newMap = new uint8[numPixels];
|
||||
|
||||
memset(newMap, kHitNothingPaletteIndex, numPixels);
|
||||
|
||||
|
||||
for (int y = 1; y < width - 1; ++y)
|
||||
{
|
||||
for (int x = 1; x < height - 1; ++x)
|
||||
{
|
||||
|
||||
int baseIndex = x + y * width;
|
||||
int color = inMap[baseIndex];
|
||||
int color = inMap[baseIndex];
|
||||
|
||||
if (color == kHitNothingPaletteIndex)
|
||||
{
|
||||
|
@ -577,7 +582,7 @@ void AvHMiniMap::DrawEdges(uint8* inMap, int width, int height)
|
|||
*/
|
||||
|
||||
}
|
||||
|
||||
|
||||
newMap[baseIndex] = color;
|
||||
|
||||
}
|
||||
|
|
|
@ -28,21 +28,21 @@ class AvHMiniMap
|
|||
public:
|
||||
AvHMiniMap();
|
||||
virtual ~AvHMiniMap();
|
||||
|
||||
|
||||
bool GetIsProcessing(float* outPercentageDone = NULL) const;
|
||||
|
||||
|
||||
#ifdef AVH_SERVER
|
||||
void BuildMiniMap(const char* inMapName, AvHPlayer* inPlayer, const AvHMapExtents& inMapExtents);
|
||||
bool Process();
|
||||
#endif
|
||||
|
||||
#ifdef AVH_CLIENT
|
||||
static string GetSpriteNameFromMap(int inSpriteWidth, const string& inMapName);
|
||||
static string GetSpriteNameFromMap(int inSpriteWidth, const string& inMapName, int useLabels);
|
||||
int ReceiveFromNetworkStream();
|
||||
bool WriteSpritesIfJustFinished();
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
private:
|
||||
#ifdef AVH_CLIENT
|
||||
void DrawEdges(uint8* inMap, int width, int height);
|
||||
|
@ -50,7 +50,7 @@ private:
|
|||
bool WriteMapToSprite();
|
||||
void WriteMapToSprite(FILE* inFileHandle);
|
||||
#endif
|
||||
|
||||
|
||||
uint8* mMap;
|
||||
int mMapWidth;
|
||||
int mMapHeight;
|
||||
|
@ -64,14 +64,14 @@ private:
|
|||
uint8 mSpriteData[kSpriteDataPixels];
|
||||
uint8 mCommanderSpriteData[kSpriteDataPixels / 4];
|
||||
#endif
|
||||
|
||||
|
||||
float mMinX;
|
||||
float mMinY;
|
||||
float mMaxX;
|
||||
float mMaxY;
|
||||
float mMinViewHeight;
|
||||
float mMaxViewHeight;
|
||||
|
||||
|
||||
int mNumSamplesToProcess;
|
||||
int mNumSamplesProcessed;
|
||||
bool mIsProcessing;
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include "mod/AvHPlayerUpgrade.h"
|
||||
#include "mod/AvHSpriteAPI.h"
|
||||
#include "mod/AvHSprites.h"
|
||||
|
||||
#include "mod/AvHClientVariables.h"
|
||||
using std::string;
|
||||
|
||||
|
||||
|
@ -20,10 +20,10 @@ class DrawingOrderSort
|
|||
{
|
||||
|
||||
public:
|
||||
|
||||
|
||||
bool operator()(const DrawableEntity& entity1, const DrawableEntity& entity2)
|
||||
{
|
||||
|
||||
|
||||
// Draw resource nodes all the way on the bottom.
|
||||
|
||||
if (entity1.mUser3 == AVH_USER3_FUNC_RESOURCE)
|
||||
|
@ -52,13 +52,13 @@ public:
|
|||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// Draw players on top of structures.
|
||||
|
||||
return (entity1.mEntityNumber > entity2.mEntityNumber);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
AvHOverviewMap::AvHOverviewMap()
|
||||
|
@ -89,9 +89,9 @@ void AvHOverviewMap::Clear()
|
|||
|
||||
void AvHOverviewMap::GetSpriteForEntity(const DrawableEntity& entity, int& outSprite, int& outFrame, int& outRenderMode)
|
||||
{
|
||||
|
||||
|
||||
outRenderMode = kRenderTransTexture;
|
||||
|
||||
|
||||
if ((this->mUser3 == AVH_USER3_COMMANDER_PLAYER) || (entity.mUser3 == AVH_USER3_UNKNOWN))
|
||||
{
|
||||
outSprite = Safe_SPR_Load(kCommBlipSprite);
|
||||
|
@ -115,7 +115,7 @@ void AvHOverviewMap::GetColorForEntity(const DrawableEntity& entity, float& outR
|
|||
}
|
||||
else if (entity.mTeam == TEAM_IND)
|
||||
{
|
||||
|
||||
|
||||
if (entity.mUser3 == AVH_USER3_WELD)
|
||||
{
|
||||
outR = 1.0;
|
||||
|
@ -168,7 +168,7 @@ void AvHOverviewMap::GetColorForEntity(const DrawableEntity& entity, float& outR
|
|||
// Color squads.
|
||||
|
||||
int localPlayerSquad;
|
||||
|
||||
|
||||
if (g_iUser1 == OBS_NONE)
|
||||
{
|
||||
localPlayerSquad = gHUD.GetCurrentSquad();
|
||||
|
@ -182,7 +182,7 @@ void AvHOverviewMap::GetColorForEntity(const DrawableEntity& entity, float& outR
|
|||
|
||||
if (mUser3 != AVH_USER3_COMMANDER_PLAYER)
|
||||
{
|
||||
if (entity.mIsLocalPlayer ||
|
||||
if (entity.mIsLocalPlayer ||
|
||||
(entity.mSquadNumber != 0 &&
|
||||
entity.mSquadNumber == localPlayerSquad))
|
||||
{
|
||||
|
@ -207,7 +207,7 @@ void AvHOverviewMap::GetColorForEntity(const DrawableEntity& entity, float& outR
|
|||
|
||||
void AvHOverviewMap::DrawMiniMapEntity(const DrawInfo& inDrawInfo, const DrawableEntity& inEntity)
|
||||
{
|
||||
|
||||
|
||||
if (!GetHasData())
|
||||
{
|
||||
return;
|
||||
|
@ -229,10 +229,10 @@ void AvHOverviewMap::DrawMiniMapEntity(const DrawInfo& inDrawInfo, const Drawabl
|
|||
int theRenderMode;
|
||||
|
||||
GetSpriteForEntity(inEntity, theSprite, theFrame, theRenderMode);
|
||||
|
||||
|
||||
if (theSprite > 0)
|
||||
{
|
||||
|
||||
|
||||
int theSprWidth = SPR_Width(theSprite, theFrame);
|
||||
int theSprHeight = SPR_Height(theSprite, theFrame);
|
||||
|
||||
|
@ -249,7 +249,7 @@ void AvHOverviewMap::DrawMiniMapEntity(const DrawInfo& inDrawInfo, const Drawabl
|
|||
|
||||
bool isPlayer = inEntity.mUser3 == AVH_USER3_MARINE_PLAYER || inEntity.mUser3 == AVH_USER3_HEAVY; //heavy used for player in minimap system
|
||||
bool theIsWaypoint = inEntity.mUser3 == AVH_USER3_WAYPOINT;
|
||||
|
||||
|
||||
float w = theSprWidth * scale;
|
||||
float h = theSprHeight * scale;
|
||||
|
||||
|
@ -258,13 +258,13 @@ void AvHOverviewMap::DrawMiniMapEntity(const DrawInfo& inDrawInfo, const Drawabl
|
|||
|
||||
float x = entityMiniMapX - w / 2.0f;
|
||||
float y = entityMiniMapY - h / 2.0f;
|
||||
|
||||
|
||||
if (theIsWaypoint)
|
||||
{
|
||||
|
||||
|
||||
float theFractionalLastUpdate = mLastUpdateTime - (int)mLastUpdateTime;
|
||||
|
||||
if (theFractionalLastUpdate < .25f)
|
||||
|
||||
if (theFractionalLastUpdate < .25f)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -279,12 +279,12 @@ void AvHOverviewMap::DrawMiniMapEntity(const DrawInfo& inDrawInfo, const Drawabl
|
|||
GetColorForEntity(inEntity, r, g, b);
|
||||
|
||||
AvHSpriteSetColor(r, g, b);
|
||||
|
||||
|
||||
// If it's the local player, draw the FOV.
|
||||
|
||||
if (inEntity.mIsLocalPlayer && mUser3 != AVH_USER3_COMMANDER_PLAYER)
|
||||
{
|
||||
|
||||
|
||||
int theSprite = Safe_SPR_Load("sprites/fov.spr");
|
||||
int theFrame = 0;
|
||||
|
||||
|
@ -298,7 +298,7 @@ void AvHOverviewMap::DrawMiniMapEntity(const DrawInfo& inDrawInfo, const Drawabl
|
|||
float y2 = entityMiniMapY - h2 / 2;
|
||||
|
||||
AvHSpriteSetRotation(-inEntity.mAngleRadians * 180 / M_PI, x2, y2 + h2 / 2);
|
||||
|
||||
|
||||
AvHSpriteSetColor(1, 1, 1);
|
||||
AvHSpriteSetRenderMode(kRenderTransAdd);
|
||||
AvHSpriteDraw(theSprite, theFrame, x2, y2, x2 + w2, y2 + h2, 0, 0, 1, 1);
|
||||
|
@ -362,7 +362,7 @@ void AvHOverviewMap::DrawMiniMapEntity(const DrawInfo& inDrawInfo, const Drawabl
|
|||
}
|
||||
|
||||
AvHSpriteSetRenderMode(renderMode);
|
||||
|
||||
|
||||
float r, g, b;
|
||||
GetColorForEntity(inEntity, r, g, b);
|
||||
|
||||
|
@ -373,7 +373,7 @@ void AvHOverviewMap::DrawMiniMapEntity(const DrawInfo& inDrawInfo, const Drawabl
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -414,13 +414,30 @@ void AvHOverviewMap::KillOldAlerts(float inCurrentTime)
|
|||
void AvHOverviewMap::DrawMiniMap(const DrawInfo& inDrawInfo)
|
||||
{
|
||||
|
||||
// Load the mini-map sprite if it's not already loaded.
|
||||
// puzl: 1064
|
||||
// Use labelled minimaps if cl_labelmaps is 1
|
||||
|
||||
if (!mMiniMapSprite && (mMapName != ""))
|
||||
{
|
||||
string theMiniMapName = AvHMiniMap::GetSpriteNameFromMap(ScreenWidth(), mMapName);
|
||||
mMiniMapSprite = Safe_SPR_Load(theMiniMapName.c_str());
|
||||
}
|
||||
// Load the mini-map sprite if it's not already loaded.
|
||||
static string lastMiniMapName="";
|
||||
if ( mMapName != "") {
|
||||
int drawLabels=CVAR_GET_FLOAT(kvLabelMaps);
|
||||
string theMiniMapName = AvHMiniMap::GetSpriteNameFromMap(ScreenWidth(), mMapName, drawLabels);
|
||||
if ( lastMiniMapName != theMiniMapName )
|
||||
{
|
||||
mMiniMapSprite = Safe_SPR_Load(theMiniMapName.c_str());
|
||||
|
||||
// We want to preserve the last minimap even if we fail. There's no point in failing again until the player
|
||||
// changes the value of the cvar.
|
||||
lastMiniMapName=theMiniMapName;
|
||||
|
||||
// Draw normal minimap if no labelled map exists ( for custom maps )
|
||||
if ( !mMiniMapSprite && drawLabels ) {
|
||||
theMiniMapName = AvHMiniMap::GetSpriteNameFromMap(ScreenWidth(), mMapName, 0);
|
||||
mMiniMapSprite = Safe_SPR_Load(theMiniMapName.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
// :puzl
|
||||
|
||||
if (!mMiniMapSprite)
|
||||
{
|
||||
|
@ -434,14 +451,14 @@ void AvHOverviewMap::DrawMiniMap(const DrawInfo& inDrawInfo)
|
|||
float mapYCenter = (mMapExtents.GetMaxMapY() + mMapExtents.GetMinMapY()) / 2;
|
||||
|
||||
float aspectRatio = mapXSize / mapYSize;
|
||||
|
||||
|
||||
float xScale;
|
||||
float yScale;
|
||||
|
||||
if(mapXSize > mapYSize)
|
||||
{
|
||||
xScale = 1.0f;
|
||||
yScale = mapYSize / mapXSize;
|
||||
yScale = mapYSize / mapXSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -464,7 +481,7 @@ void AvHOverviewMap::DrawMiniMap(const DrawInfo& inDrawInfo)
|
|||
AvHSpriteSetRotation(0, 0, 0);
|
||||
|
||||
// TODO this should be based on a flag not the user3
|
||||
|
||||
|
||||
if (mUser3 == AVH_USER3_COMMANDER_PLAYER)
|
||||
{
|
||||
// Use the small map if it's the commander view.
|
||||
|
@ -499,7 +516,7 @@ void AvHOverviewMap::DrawAlerts(const DrawInfo& inDrawInfo)
|
|||
|
||||
int theWidth = inDrawInfo.mWidth;
|
||||
int theHeight = inDrawInfo.mHeight;
|
||||
|
||||
|
||||
AvHSpriteEnableClippingRect(true);
|
||||
AvHSpriteSetClippingRect(theX, theY, theX + theWidth, theY + theHeight);
|
||||
|
||||
|
@ -516,7 +533,7 @@ void AvHOverviewMap::DrawAlerts(const DrawInfo& inDrawInfo)
|
|||
|
||||
for (unsigned int i = 0; i < mAlertList.size(); ++i)
|
||||
{
|
||||
|
||||
|
||||
float maxAlertSize = 5;
|
||||
float minAlertSize = 0.4;
|
||||
|
||||
|
@ -530,11 +547,11 @@ void AvHOverviewMap::DrawAlerts(const DrawInfo& inDrawInfo)
|
|||
|
||||
float w = theSprWidth * scale;
|
||||
float h = theSprHeight * scale;
|
||||
|
||||
|
||||
float cx = mAlertList[i].mX;
|
||||
float cy = mAlertList[i].mY;
|
||||
|
||||
WorldToMiniMapCoords(inDrawInfo, cx, cy);
|
||||
|
||||
WorldToMiniMapCoords(inDrawInfo, cx, cy);
|
||||
|
||||
float angle = dt * 180;
|
||||
|
||||
|
@ -551,20 +568,20 @@ void AvHOverviewMap::DrawAlerts(const DrawInfo& inDrawInfo)
|
|||
AvHSpriteSetRotation(angle, cx, cy);
|
||||
AvHSpriteDraw(theSprite, theFrame, cx - w / 2, cy - h / 2, cx + w / 2, cy + h / 2, 0, 0, 1, 1);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void AvHOverviewMap::AddAlert(float x, float y)
|
||||
{
|
||||
|
||||
|
||||
MapAlert alert;
|
||||
|
||||
alert.mStartTime = mLastUpdateTime;
|
||||
alert.mExpireTime = mLastUpdateTime + BALANCE_FVAR(kAlertExpireTime) / 5;
|
||||
|
||||
|
||||
alert.mX = x;
|
||||
alert.mY = y;
|
||||
|
||||
|
||||
mAlertList.push_back(alert);
|
||||
|
||||
}
|
||||
|
@ -581,11 +598,11 @@ void AvHOverviewMap::Draw(const DrawInfo& inDrawInfo)
|
|||
|
||||
AvHSpriteEnableClippingRect(true);
|
||||
AvHSpriteSetClippingRect(theX, theY, theX + theCompWidth, theY + theCompHeight);
|
||||
|
||||
|
||||
// Draw the minimap background.
|
||||
|
||||
DrawMiniMap(inDrawInfo);
|
||||
|
||||
|
||||
// Draw the entities on the minimap.
|
||||
|
||||
if (mUser3 == AVH_USER3_COMMANDER_PLAYER)
|
||||
|
@ -599,33 +616,33 @@ void AvHOverviewMap::Draw(const DrawInfo& inDrawInfo)
|
|||
}
|
||||
|
||||
// Draw the way points as entities.
|
||||
|
||||
|
||||
{
|
||||
|
||||
|
||||
for (MapOrderListType::const_iterator theIter = mMapOrderList.begin(); theIter != mMapOrderList.end(); theIter++)
|
||||
{
|
||||
DrawableEntity drawableEntity;
|
||||
|
||||
|
||||
drawableEntity.mUser3 = AVH_USER3_WAYPOINT;
|
||||
drawableEntity.mX = theIter->mX;
|
||||
drawableEntity.mY = theIter->mY;
|
||||
|
||||
|
||||
DrawMiniMapEntity(inDrawInfo, drawableEntity);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Draw the alerts.
|
||||
|
||||
DrawAlerts(inDrawInfo);
|
||||
|
||||
|
||||
// Draw the reticle.
|
||||
|
||||
if(this->mUser3 == AVH_USER3_COMMANDER_PLAYER)
|
||||
{
|
||||
|
||||
|
||||
int theFrame = 0;
|
||||
|
||||
|
||||
if (!this->mReticleSprite)
|
||||
{
|
||||
this->mReticleSprite = Safe_SPR_Load(kReticleSprite);
|
||||
|
@ -662,16 +679,16 @@ int AvHOverviewMap::GetEntityAtWorldPosition(float inWorldX, float inWorldY, flo
|
|||
|
||||
for (int i = 0; i < (int)mDrawableEntityList.size(); ++i)
|
||||
{
|
||||
|
||||
|
||||
float dx = mDrawableEntityList[i].mX - inWorldX;
|
||||
float dy = mDrawableEntityList[i].mY - inWorldY;
|
||||
|
||||
|
||||
if (dx * dx + dy * dy < inRadius * inRadius)
|
||||
{
|
||||
return mDrawableEntityList[i].mEntityNumber;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
|
@ -726,25 +743,25 @@ void AvHOverviewMap::Update(float inCurrentTime)
|
|||
|
||||
void AvHOverviewMap::UpdateDrawData(float inCurrentTime)
|
||||
{
|
||||
|
||||
|
||||
int theLocalPlayerIndex;
|
||||
|
||||
|
||||
if (g_iUser1 == OBS_NONE)
|
||||
{
|
||||
cl_entity_s* thePlayer = gEngfuncs.GetLocalPlayer();
|
||||
theLocalPlayerIndex = thePlayer->index;
|
||||
theLocalPlayerIndex = thePlayer->index;
|
||||
}
|
||||
else
|
||||
{
|
||||
theLocalPlayerIndex = g_iUser2;
|
||||
}
|
||||
|
||||
|
||||
cl_entity_s* thePlayer = gEngfuncs.GetEntityByIndex(theLocalPlayerIndex);
|
||||
mTeam = (AvHTeamNumber)(thePlayer->curstate.team);
|
||||
|
||||
// Clear list of drawable entities
|
||||
// Clear list of drawable entities
|
||||
this->mDrawableEntityList.clear();
|
||||
|
||||
|
||||
// Get all entities
|
||||
MapEntityMap theEntityList;
|
||||
gHUD.GetEntityHierarchy().GetEntityInfoList(theEntityList);
|
||||
|
@ -773,11 +790,11 @@ void AvHOverviewMap::UpdateDrawData(float inCurrentTime)
|
|||
|
||||
// Get additional information about the entity from the client state.
|
||||
|
||||
cl_entity_t* clientEntity = gEngfuncs.GetEntityByIndex(theDrawableEntity.mEntityNumber);
|
||||
|
||||
cl_entity_t* clientEntity = gEngfuncs.GetEntityByIndex(theDrawableEntity.mEntityNumber);
|
||||
|
||||
if(clientEntity)
|
||||
{
|
||||
|
||||
|
||||
if (clientEntity->index >= 32)
|
||||
{
|
||||
theDrawableEntity.mAngleRadians = clientEntity->angles[1] * M_PI / 180;
|
||||
|
@ -785,19 +802,19 @@ void AvHOverviewMap::UpdateDrawData(float inCurrentTime)
|
|||
|
||||
// Update the information for this entity from the client information
|
||||
// if they're in the local player's PVS.
|
||||
|
||||
|
||||
// We really want to check if the client data is more recent than the
|
||||
// minimap data, but I don't know how to get the timestamp on the minimap
|
||||
// data.
|
||||
|
||||
|
||||
if (clientEntity->curstate.messagenum >= thePlayer->curstate.messagenum)
|
||||
{
|
||||
|
||||
|
||||
//theDrawableEntity.mUser3 = (AvHUser3)(clientEntity->curstate.iuser3);
|
||||
|
||||
// Brush entities don't have the correct position information, so
|
||||
// don't update them from the client data.
|
||||
|
||||
|
||||
|
||||
if (theDrawableEntity.mUser3 != AVH_USER3_WELD)
|
||||
{
|
||||
|
@ -809,28 +826,28 @@ void AvHOverviewMap::UpdateDrawData(float inCurrentTime)
|
|||
}
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
// If the difference between the minimap position and the client data
|
||||
// position is less than the minimap quantization error, then use
|
||||
// the client position to avoid popping when the entity goes out of the
|
||||
// PVS.
|
||||
|
||||
|
||||
float dx = fabs(theDrawableEntity.mX - clientEntity->origin.x);
|
||||
float dy = fabs(theDrawableEntity.mY - clientEntity->origin.y);
|
||||
|
||||
|
||||
if (dx < kPositionNetworkConstant && dy < kPositionNetworkConstant)
|
||||
{
|
||||
theDrawableEntity.mX = clientEntity->origin.x;
|
||||
theDrawableEntity.mY = clientEntity->origin.y;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (theDrawableEntity.mUser3 != AVH_USER3_COMMANDER_PLAYER)
|
||||
{
|
||||
this->mDrawableEntityList.push_back(theDrawableEntity);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -849,7 +866,7 @@ void AvHOverviewMap::UpdateOrders(const OrderListType& inOrderList, const Entity
|
|||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
for (OrderListType::const_iterator theIter = inOrderList.begin(); theIter != inOrderList.end(); ++theIter)
|
||||
{
|
||||
|
||||
|
@ -861,18 +878,18 @@ void AvHOverviewMap::UpdateOrders(const OrderListType& inOrderList, const Entity
|
|||
{
|
||||
theDrawWaypoint = true;
|
||||
}
|
||||
|
||||
|
||||
if (theDrawWaypoint)
|
||||
{
|
||||
|
||||
vec3_t position;
|
||||
theIter->GetLocation(position);
|
||||
|
||||
|
||||
MapOrder mapOrder;
|
||||
|
||||
mapOrder.mX = position[0];
|
||||
mapOrder.mY = position[1];
|
||||
|
||||
|
||||
mMapOrderList.push_back(mapOrder);
|
||||
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
|
||||
|
||||
// Half-Life User Info Configuration Layout Script (stores last settings chosen, too)
|
||||
// File generated: Mon Jul 05 15:16:31 AM
|
||||
// File generated: Sun Jun 19 15:41:20 AM
|
||||
//
|
||||
//
|
||||
// Cvar - Setting
|
||||
|
@ -49,11 +49,18 @@ DESCRIPTION INFO_OPTIONS
|
|||
SetInfo
|
||||
}
|
||||
|
||||
"cl_labelmaps"
|
||||
{
|
||||
"Draw location names"
|
||||
{ BOOL }
|
||||
{ "1" }
|
||||
}
|
||||
|
||||
"cl_centerentityid"
|
||||
{
|
||||
"Center player names"
|
||||
{ BOOL }
|
||||
{ "1" }
|
||||
{ "0" }
|
||||
}
|
||||
|
||||
"cl_highdetail"
|
||||
|
@ -88,14 +95,14 @@ DESCRIPTION INFO_OPTIONS
|
|||
{
|
||||
"Weapon fast-switch"
|
||||
{ BOOL }
|
||||
{ "0" }
|
||||
{ "1" }
|
||||
}
|
||||
|
||||
"cl_musicenabled"
|
||||
{
|
||||
"Music enabled"
|
||||
{ BOOL }
|
||||
{ "0" }
|
||||
{ "1" }
|
||||
}
|
||||
|
||||
"cl_musicvolume"
|
||||
|
|
Loading…
Reference in a new issue