From 53332dbe766452f1b0c8c3d6d807e0be4c34ba18 Mon Sep 17 00:00:00 2001 From: Steve Dudenhoeffer Date: Tue, 27 Jul 2004 01:15:10 +0000 Subject: [PATCH] Added ns_set_fov Began porting ns_show_menu, having problems though. --- dlls/ns/ns/CPlayer.cpp | 10 ++++++++++ dlls/ns/ns/CPlayer.h | 3 ++- dlls/ns/ns/NMenu.cpp | 17 ++++++++++++----- dlls/ns/ns/NMisc.cpp | 30 ++++++++++++++++++++++++++++++ dlls/ns/ns/hookedfunctions.cpp | 14 ++++++++++++++ dlls/ns/ns/include/ns.inc | 1 + dlls/ns/ns/moduleconfig.h | 2 +- dlls/ns/ns/ns.h | 1 - dlls/ns/ns/ns.suo | Bin 13312 -> 17920 bytes 9 files changed, 70 insertions(+), 8 deletions(-) diff --git a/dlls/ns/ns/CPlayer.cpp b/dlls/ns/ns/CPlayer.cpp index d956b0af..6ab3e578 100755 --- a/dlls/ns/ns/CPlayer.cpp +++ b/dlls/ns/ns/CPlayer.cpp @@ -101,12 +101,15 @@ void CPlayer::Reset() this->model[0]='\0'; this->skin=0; this->body=0; + this->fov=0.0; + this->foved=false; } BOOL CPlayer::ClientCommand() { // As of now, all that needs to be checked is the "menuselect" command. if (menucmd.inmenu) { + LOG_CONSOLE(PLID,"Checking menuselect..."); if (FStrEq(CMD_ARGV(0),"menuselect")) { int key=0; @@ -122,6 +125,13 @@ BOOL CPlayer::ClientCommand() if (key_mask & menucmd.keys) { ClearHudMessage(edict,menuhudtext," "); + LOG_CONSOLE(PLID,"Clearing hud text..."); + LOG_CONSOLE(PLID,"this->menucmd.iFunctionIndex: %i, this->index: %i key: %i",this->menucmd.iFunctionIndex,this->index,key); + int temp = this->menucmd.iFunctionIndex; + MF_ExecuteForward(this->menucmd.iFunctionIndex,this->index,key); + MF_UnregisterSPForward(temp); + + LOG_CONSOLE(PLID,"Executing..."); // AMX_EXEC(menucmd.amx,NULL,menucmd.iFunctionIndex,2,index,key); } return true; diff --git a/dlls/ns/ns/CPlayer.h b/dlls/ns/ns/CPlayer.h index 6a107dac..736a43f0 100755 --- a/dlls/ns/ns/CPlayer.h +++ b/dlls/ns/ns/CPlayer.h @@ -23,7 +23,8 @@ public: int index; bool connected; - + REAL fov; + bool foved; // Custom model/body/skin bool custommodel; bool customskin; diff --git a/dlls/ns/ns/NMenu.cpp b/dlls/ns/ns/NMenu.cpp index 8b64ff0d..698afb83 100755 --- a/dlls/ns/ns/NMenu.cpp +++ b/dlls/ns/ns/NMenu.cpp @@ -53,14 +53,21 @@ static cell AMX_NATIVE_CALL ns_show_menu(AMX *amx,cell *params) if (FNullEnt(INDEXENT2(params[1]))) return 0; } - // First we set the command to be executed here... int len; - // AMX publics have a limit of 19 characters. + int ifx; char sTemp[20]; - sprintf(sTemp,"%s",MF_GetAmxString(amx,params[2],0,&len)); char sText[512]; - sprintf(sText,"%s",MF_GetAmxString(amx,params[3],1,&len)); - iFunctionIndex = MF_RegisterSPForwardByName(amx, sTemp, ET_IGNORE, FP_CELL, FP_CELL); + strncpy(sTemp,MF_GetAmxString(amx,params[2],0,&len),19); + strncpy(sText,MF_GetAmxString(amx,params[3],1,&len),511); + sTemp[19]='\0'; + sText[511]='\0'; + if (MF_AmxFindPublic(amx,sTemp,&ifx) == AMX_ERR_NONE) + iFunctionIndex = MF_RegisterSPForward(amx,ifx,FP_CELL, FP_CELL,FP_DONE); + else + { + MF_Log("(ns_show_menu): Function not found: %s",sTemp); + return 0; + } if (pEntity==NULL) { int i; diff --git a/dlls/ns/ns/NMisc.cpp b/dlls/ns/ns/NMisc.cpp index eaf07452..2240e92f 100755 --- a/dlls/ns/ns/NMisc.cpp +++ b/dlls/ns/ns/NMisc.cpp @@ -271,6 +271,34 @@ static cell AMX_NATIVE_CALL ns_popup(AMX *amx, cell *params) MESSAGE_END(); return 1; } +static cell AMX_NATIVE_CALL ns_set_fov(AMX *amx, cell *params) +{ + if (params[1] < 1 || params[1] > gpGlobals->maxClients) + return 0; + CPlayer *player = GET_PLAYER_I(params[1]); + REAL fov = CELL_TO_FLOAT(params[2]); + LOG_CONSOLE(PLID,"Got fov. fov=%f",fov); + int gmsgSetFov = GET_USER_MSG_ID(PLID, "SetFOV", NULL); + if (fov == 0.0) + { + player->foved=false; + player->fov=0.0; + MESSAGE_BEGIN(MSG_ONE,gmsgSetFov,NULL,player->edict); + WRITE_BYTE(0); + MESSAGE_END(); + return 1; + } + if (fov > 0) + { + player->foved=true; + player->fov=fov; + MESSAGE_BEGIN(MSG_ONE,gmsgSetFov,NULL,player->edict); + WRITE_BYTE((int)fov); + MESSAGE_END(); + return 1; + } + return 0; +} AMX_NATIVE_INFO ns_misc_natives[] = { /////////////////// { "ns_get_build", ns_get_build }, @@ -301,6 +329,8 @@ AMX_NATIVE_INFO ns_misc_natives[] = { { "ns_popup", ns_popup }, + { "ns_set_fov", ns_set_fov }, + /////////////////// { NULL, NULL } diff --git a/dlls/ns/ns/hookedfunctions.cpp b/dlls/ns/ns/hookedfunctions.cpp index 728223b7..dd372069 100755 --- a/dlls/ns/ns/hookedfunctions.cpp +++ b/dlls/ns/ns/hookedfunctions.cpp @@ -3,6 +3,7 @@ #include //useful almost everywhere #include +#include CSpawn ns_spawnpoints; CPlayer g_player[33]; @@ -382,4 +383,17 @@ void ClientDisconnect(edict_t *pEntity) CPlayer *player = GET_PLAYER_E(pEntity); player->Disconnect(); RETURN_META(MRES_HANDLED); +} + +// NS resets pev->fov every single frame, but this is called right before the data is sent to the client. +// Reset FOV if we need to. +void UpdateClientData( const struct edict_s *ent, int sendweapons, struct clientdata_s *cd ) +{ + edict_t *pEntity = (edict_t*)ent; + CPlayer *player = GET_PLAYER_E(pEntity); + if (player->foved) + pEntity->v.fov = player->fov; + + RETURN_META(MRES_HANDLED); + } \ No newline at end of file diff --git a/dlls/ns/ns/include/ns.inc b/dlls/ns/ns/include/ns.inc index 2da4777c..25cf83ec 100755 --- a/dlls/ns/ns/include/ns.inc +++ b/dlls/ns/ns/include/ns.inc @@ -173,3 +173,4 @@ native ns_get_hive_trait(idHive); /* Sets the trait type tied to the hive. Look at the hivetrait enum for the values. */ native ns_set_hive_trait(idHive,trait); +native ns_set_fov(idPlayer,Float:_fov=0.0); diff --git a/dlls/ns/ns/moduleconfig.h b/dlls/ns/ns/moduleconfig.h index b6ae1deb..b882c2dd 100755 --- a/dlls/ns/ns/moduleconfig.h +++ b/dlls/ns/ns/moduleconfig.h @@ -90,7 +90,7 @@ // #define FN_PM_Init PM_Init /* pfnPM_Init() Server version of player movement initialization; (wd) SDK2 */ // #define FN_PM_FindTextureType PM_FindTextureType /* pfnPM_FindTextureType() (wd) SDK2 */ // #define FN_SetupVisibility SetupVisibility /* pfnSetupVisibility() Set up PVS and PAS for networking for this client; (wd) SDK2 */ -// #define FN_UpdateClientData UpdateClientData /* pfnUpdateClientData() Set up data sent only to specific client; (wd) SDK2 */ +#define FN_UpdateClientData UpdateClientData /* pfnUpdateClientData() Set up data sent only to specific client; (wd) SDK2 */ // #define FN_AddToFullPack AddToFullPack /* pfnAddToFullPack() (wd) SDK2 */ // #define FN_CreateBaseline CreateBaseline /* pfnCreateBaseline() Tweak entity baseline for network encoding allows setup of player baselines too.; (wd) SDK2 */ // #define FN_RegisterEncoders RegisterEncoders /* pfnRegisterEncoders() Callbacks for network encoding; (wd) SDK2 */ diff --git a/dlls/ns/ns/ns.h b/dlls/ns/ns/ns.h index 53879bab..994f4613 100755 --- a/dlls/ns/ns/ns.h +++ b/dlls/ns/ns/ns.h @@ -8,7 +8,6 @@ #include "ns_const.h" #include "CPlayer.h" #include "CSpawn.h" -#include "CCallList.h" #include "utilfunctions.h" extern CSpawn ns_spawnpoints; diff --git a/dlls/ns/ns/ns.suo b/dlls/ns/ns/ns.suo index eda51a27b96c965cb21b49670b1bd7506d3e12eb..b341982e77b0b0a364d8795a2fed2dd9fa93c340 100755 GIT binary patch delta 1643 zcmds0O=uHQ5Pom-l4kS&+x%?WY--$8+mIBE2qF{|YO(bPN{ot>U}G!9CeYM2_0W3i z#X{>`JP7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