Willkommen ~Gast!
Registrieren || Einloggen || Hilfe/FAQ || Staff
Probleme mit der Registrierung im Forum? Melde dich unter registerEin Bild.
Autor Beitrag
000
21.03.2001, 19:33
Robertos



Hey Leutz ich habe mal ein paar Fragen ich hoffe ihr könnt sie mir beantworten.

1. Ich habe zwei Fehler wenn ich meine Client.dll compiliere. Ich hab probiert ein
Nachtsichtgerät zu bastel. Folgender Fehler tritt auf:

nvg.cpp
c:\spiele\sierra\half-life\sdk\sourcecode\dlls\enginecallback.h(22) : error C2146: Syntaxfehler : Fehlendes ';' vor Bezeichner 'g_engfuncs'
c:\spiele\sierra\half-life\sdk\sourcecode\dlls\enginecallback.h(22) : fatal error C1004: Unerwartetes Dateiende gefunden

Hier ist mein nvg.cpp:

#include "hud.h"
#include "util.h"
#include <string.h>
#include <stdio.h>
#include <time.h>
#include "parsemsg.h"

DECLARE_MESSAGE(m_NVG, NVGActivate )
DECLARE_MESSAGE(m_NVG, NVG )

int CHudNVG::Init(void)
{
HOOK_MESSAGE( NVGActivate );
HOOK_MESSAGE( NVG );

m_iNVG = 0;
m_iOn = 0;
m_flBattery = 0;

m_iFlags = 0;
gHUD.AddHudElem(this);
srand( (unsigned)time( NULL ) );

return 1;
}

int CHudNVG::VidInit(void)
{
// this is the NVG effect sprite
m_hFlicker = LoadSprite("sprites/nvg.spr");

// get the battery sprites
int HUD_battery_full = gHUD.GetSpriteIndex( "nvg_battery_full" );
int HUD_battery_empty = gHUD.GetSpriteIndex( "nvg_battery_empty" );

m_hBatteryFull = gHUD.GetSprite(HUD_battery_full);
m_hBatteryEmpty = gHUD.GetSprite(HUD_battery_empty);
m_prcBatteryFull = &gHUD.GetSpriteRect(HUD_battery_full);
m_prcBatteryEmpty = &gHUD.GetSpriteRect(HUD_battery_empty);

m_iWidth = m_prcBatteryFull->right - m_prcBatteryFull->left;

// calculate the y offset (using the flashlight sprite)
int HUD_flashlight = gHUD.GetSpriteIndex( "flash_empty" );
wrect_t *prcFL;

prcFL = &gHUD.GetSpriteRect( HUD_flashlight );
m_iBatteryY = (prcFL->bottom - prcFL->top)*2;

return 1;
};

return 1;
}

int CHudNVG::Draw(float fTime)
{
// draw the battery
if (m_iNVG) {
int r, g, b, x, y, a, offset;
wrect_t rc;

// updates the battery state, calculate colors
if (m_iOn) {
m_flBattery -= gHUD.m_flTimeDelta * NVG_DRAIN_PER_SECOND;

if (m_flBattery < 0)
m_flBattery = 0;
a = 255;
} else {
m_flBattery += gHUD.m_flTimeDelta * NVG_RECHARGE_PER_SECOND;
if (m_flBattery > 100)
m_flBattery = 100;

a = MIN_ALPHA;
}

if (m_flBattery < 20)
UnpackRGB(r,g,b, RGB_REDISH);
else
UnpackRGB(r,g,b, RGB_YELLOWISH);

ScaleColors(r, g, b, a);

// calculate x/y offsets, empty width
x = ScreenWidth - m_iWidth - m_iWidth / 2;
y = m_iBatteryY;

offset = (m_flBattery * m_iWidth) / 100;

// draw the empty part first...
if (offset < m_iWidth) {
SPR_Set(m_hBatteryEmpty, r, g, b);

rc = *m_prcBatteryEmpty;
rc.right -= offset;
SPR_DrawAdditive( 0, x, y, &rc);
}

// and then the full part
if (offset > 0) {
SPR_Set(m_hBatteryFull, r, g, b);

rc = *m_prcBatteryFull;
rc.left += (m_iWidth - offset);
SPR_DrawAdditive( 0, x + m_iWidth - offset, y, &rc);
}
}

if (m_iOn)
{
int x, y, w, h;
int frame;

SPR_Set(m_hFlicker, 10, 100, 10 );

{
if (m_iOn)
{
int x, y, w, h;
int frame;

SPR_Set(m_hFlicker, 10, 100, 10 );

// play at 15fps
frame = (int)(fTime * 15) % SPR_Frames(m_hFlicker);

w = SPR_Width(m_hFlicker,0);
h = SPR_Height(m_hFlicker,0);

for(y = -(rand() % h); y < ScreenHeight; y += h) {
for(x = -(rand() % w); x < ScreenWidth; x += w) {
SPR_DrawAdditive( frame, x, y, NULL );
}
}
}

return 1;

int CHudNVG::MsgFunc_NVG(const char *pszName, int iSize, void *pbuf)
{
BEGIN_READ( pbuf, iSize );

// update NVG data
m_iNVG = READ_BYTE();
m_flBattery = (float)READ_BYTE();

if (m_iNVG)
m_iFlags |= HUD_ACTIVE;
else
m_iFlags &= ~HUD_ACTIVE;

m_iOn = 0;

return 1;
}

int CHudNVG::MsgFunc_NVGActivate(const char *pszName, int iSize, void *pbuf)
{
BEGIN_READ( pbuf, iSize );

// update NVG data
m_iOn = READ_BYTE();
m_flBattery = (float)READ_BYTE();

return 1;
}

--

zum Seitenanfang zum Seitenende Profil || Suche
001
21.03.2001, 19:43
Prefect



*gähn* der wird aber auch langsam alt... sorry

Am Anfang der Datei util.h durch cl_util.h ersetzen.

@TTT/Masterstroke: könnt ihr das in dem Tutorial nicht mal schnell ändern?

cu,
Prefect

--

Widelands - Gemütliche Aufbaustrategie, Free Software
Noch ein Blog - Lerne, wie die Welt wirklich ist, aber vergiss niemals, wie sie sein sollte.

zum Seitenanfang zum Seitenende Profil || Suche
002
21.03.2001, 23:03
apfelkorn



@pref: das wird sich nie ändern... es muss doch irgendwas geben, an dem sich die fragen immer wieder aufhängen *g*

--

zum Seitenanfang zum Seitenende Profil || Suche
003
22.03.2001, 19:03
Prefect



Stimmt auch wieder *g*

cu,
Prefect

--

Widelands - Gemütliche Aufbaustrategie, Free Software
Noch ein Blog - Lerne, wie die Welt wirklich ist, aber vergiss niemals, wie sie sein sollte.

zum Seitenanfang zum Seitenende Profil || Suche
004
30.05.2001, 14:46
Saugie



muh also me hat auch ein prob damit (dies hier scheint älter zu sein da bei mir schon cl_ steht...) also hier meine fehler:
--------------------Konfiguration: cl_dll - Win32 Debug--------------------
Kompilierung läuft...
nvg.cpp
E:\Spiele\Hl-sdk\Sdk\SourceCode\cl_dll\nvg.cpp(119) : error C2601: 'MsgFunc_NVG' : Lokale Funktionsdefinitionen sind unzulaessig
E:\Spiele\Hl-sdk\Sdk\SourceCode\cl_dll\nvg.cpp(137) : error C2601: 'MsgFunc_NVGActivate' : Lokale Funktionsdefinitionen sind unzulaessig
E:\Spiele\Hl-sdk\Sdk\SourceCode\cl_dll\nvg.cpp(146) : fatal error C1004: Unerwartetes Dateiende gefunden
Fehler beim Ausführen von cl.exe.

client.dll - 3 Fehler, 0 Warnung(en)

der kram mit den Funktionsdefinitionen zeigt dann immer auf das { der letzten beiden funktionen und der andere fehlwer auf das } der letzten funktionen... was kann man an einer klammer flasch schrieben??? naja öhm also im tut stehts glaub ich genauso :-/

MfG Saugie

--

zum Seitenanfang zum Seitenende Profil || Suche
005
30.05.2001, 15:11
Archangel



hmm, lokale funktionsdefininitionen sind unzulässig bedeutet meistens, das du eine '}' vergessen hast.. dann schließt eine funktion nämlich noch die nächste etc ein...

--

Mar 01 01:10:13 <voice> jo
Mar 01 01:10:40 <voice> bis dann ^^
Mar 01 01:11:20 <Archangel> jo
**** ENDING LOGGING AT Tue Mar 1 01:58:13 2005

zum Seitenanfang zum Seitenende Profil || Suche
006
30.05.2001, 20:26
Saugie



hab schon versucht die klammern wegzulassen und bis zu 3 mehr klammern gemacht und der code is genauso wie im tut.... :-/
*edit*
also ich poste mal den quellcode teil wo die fehler sind:

int CHudNVG::MsgFunc_NVG(const char *pszName, int iSize, void *pbuf)
{ //<-- fehler 1
BEGIN_READ( pbuf, iSize );

// update NVG data
m_iNVG = READ_BYTE();
m_flBattery = (float)READ_BYTE();

if (m_iNVG)
m_iFlags |= HUD_ACTIVE;
else
m_iFlags &= ~HUD_ACTIVE;

m_iOn = 0;

return 1;
}

int CHudNVG::MsgFunc_NVGActivate(const char *pszName, int iSize, void *pbuf)
{ //<-- fehler 2
BEGIN_READ( pbuf, iSize );

// update NVG data
m_iOn = READ_BYTE();
m_flBattery = (float)READ_BYTE();

return 1;
}

--

zum Seitenanfang zum Seitenende Profil || Suche
007
30.05.2001, 21:59
Killing Me Softly



in der Funktion ÜBER CHudNVG::MsgFunc_NVG(...) fehlt eine Klammer, und zwar nach dem 'return 1;'

--

Der Horizont vieler Menschen ist ein Kreis mit Radius Null - und das nennen sie ihren Standpunkt.

zum Seitenanfang zum Seitenende Profil || Suche
008
30.05.2001, 22:58
Saugie



so jez is da ne klammer abe rimmnoch ein fehler (und noch ne frage wie bist du dadrauf gekommen? is doch nur eine { und dafür 2 }??? :confused: ;))

--------------------Konfiguration: cl_dll - Win32 Debug--------------------
Kompilierung läuft...
nvg.cpp
E:\Spiele\Hl-sdk\Sdk\SourceCode\cl_dll\nvg.cpp(119) : error C2601: 'MsgFunc_NVG' : Lokale Funktionsdefinitionen sind unzulaessig
Fehler beim Ausführen von cl.exe.

client.dll - 1 Fehler, 0 Warnung(en)
muh muh ;)

also jez is der untere fehler (fehler 2 :D) weg aber der erste bleibt...

liegt das vielleicht daran das ichs aus ner html datei einfach kopiert hab? ;)
also auf einer seite stand mal das der code komisch wird wenn man ihn aus einer html datei kopiert...

--

zum Seitenanfang zum Seitenende Profil || Suche
009
01.06.2001, 19:32
-=)GhOsT(=-



Ahoi ich hab auch ein sch.... fehler

--------------------Configuration: hl - Win32 Release--------------------
Compiling...
items.cpp
D:\FullSDKSource\dlls\items.cpp(331) : error C2065: 'gmsgNVG' : undeclared identifier
player.cpp
Error executing cl.exe.
Creating browse info file...

hl.dll - 1 error(s), 0 warning(s)

und hier der Code

/***
*
* Copyright (c) 1999, 2000 Valve LLC. All rights reserved.
*
* 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
* object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC.
*
****/
/*

===== items.cpp ========================================================

functions governing the selection/use of weapons for players

*/

#include "extdll.h"
#include "util.h"
#include "cbase.h"
#include "weapons.h"
#include "player.h"
#include "skill.h"
#include "items.h"
#include "gamerules.h"

extern int gmsgItemPickup;

class CWorldItem : public CBaseEntity
{
public:
void KeyValue(KeyValueData *pkvd );
void Spawn( void );
int m_iType;
};

LINK_ENTITY_TO_CLASS(world_items, CWorldItem);

void CWorldItem::KeyValue(KeyValueData *pkvd)
{
if (FStrEq(pkvd->szKeyName, "type"))
{
m_iType = atoi(pkvd->szValue);
pkvd->fHandled = TRUE;
}
else
CBaseEntity::KeyValue( pkvd );
}

void CWorldItem::Spawn( void )
{
CBaseEntity *pEntity = NULL;

switch (m_iType)
{
case 44: // ITEM_BATTERY:
pEntity = CBaseEntity::Create( "item_battery", pev->origin, pev->angles );
break;
case 42: // ITEM_ANTIDOTE:
pEntity = CBaseEntity::Create( "item_antidote", pev->origin, pev->angles );
break;
case 43: // ITEM_SECURITY:
pEntity = CBaseEntity::Create( "item_security", pev->origin, pev->angles );
break;
case 45: // ITEM_SUIT:
pEntity = CBaseEntity::Create( "item_suit", pev->origin, pev->angles );
break;
}

if (!pEntity)
{
ALERT( at_console, "unable to create world_item %d\n", m_iType );
}
else
{
pEntity->pev->target = pev->target;
pEntity->pev->targetname = pev->targetname;
pEntity->pev->spawnflags = pev->spawnflags;
}

REMOVE_ENTITY(edict());
}

void CItem::Spawn( void )
{
pev->movetype = MOVETYPE_TOSS;
pev->solid = SOLID_TRIGGER;
UTIL_SetOrigin( pev, pev->origin );
UTIL_SetSize(pev, Vector(-16, -16, 0), Vector(16, 16, 16));
SetTouch(ItemTouch);

if (DROP_TO_FLOOR(ENT(pev)) == 0)
{
ALERT(at_error, "Item %s fell out of level at %f,%f,%f", STRING( pev->classname ), pev->origin.x, pev->origin.y, pev->origin.z);
UTIL_Remove( this );
return;
}
}

extern int gEvilImpulse101;

void CItem::ItemTouch( CBaseEntity *pOther )
{
// if it's not a player, ignore
if ( !pOther->IsPlayer() )
{
return;
}

CBasePlayer *pPlayer = (CBasePlayer *)pOther;

// ok, a player is touching this item, but can he have it?
if ( !g_pGameRules->CanHaveItem( pPlayer, this ) )
{
// no? Ignore the touch.
return;
}

if (MyTouch( pPlayer ))
{
SUB_UseTargets( pOther, USE_TOGGLE, 0 );
SetTouch( NULL );

// player grabbed the item.
g_pGameRules->PlayerGotItem( pPlayer, this );
if ( g_pGameRules->ItemShouldRespawn( this ) == GR_ITEM_RESPAWN_YES )
{
Respawn();
}
else
{
UTIL_Remove( this );
}
}
else if (gEvilImpulse101)
{
UTIL_Remove( this );
}
}

CBaseEntity* CItem::Respawn( void )
{
SetTouch( NULL );
pev->effects |= EF_NODRAW;

UTIL_SetOrigin( pev, g_pGameRules->VecItemRespawnSpot( this ) );// blip to whereever you should respawn.

SetThink ( Materialize );
pev->nextthink = g_pGameRules->FlItemRespawnTime( this );
return this;
}

void CItem::Materialize( void )
{
if ( pev->effects & EF_NODRAW )
{
// changing from invisible state to visible.
EMIT_SOUND_DYN( ENT(pev), CHAN_WEAPON, "items/suitchargeok1.wav", 1, ATTN_NORM, 0, 150 );
pev->effects &= ~EF_NODRAW;
pev->effects |= EF_MUZZLEFLASH;
}

SetTouch( ItemTouch );
}

#define SF_SUIT_SHORTLOGON 0x0001

class CItemSuit : public CItem
{
void Spawn( void )
{
Precache( );
SET_MODEL(ENT(pev), "models/w_suit.mdl");
CItem::Spawn( );
}
void Precache( void )
{
PRECACHE_MODEL ("models/w_suit.mdl");
}
BOOL MyTouch( CBasePlayer *pPlayer )
{
if ( pPlayer->pev->weapons & (1<<WEAPON_SUIT) )
return FALSE;

if ( pev->spawnflags & SF_SUIT_SHORTLOGON )
EMIT_SOUND_SUIT(pPlayer->edict(), "!HEV_A0"); // short version of suit logon,
else
EMIT_SOUND_SUIT(pPlayer->edict(), "!HEV_AAx"); // long version of suit logon

pPlayer->pev->weapons |= (1<<WEAPON_SUIT);
return TRUE;
}
};

LINK_ENTITY_TO_CLASS(item_suit, CItemSuit);

class CItemBattery : public CItem
{
void Spawn( void )
{
Precache( );
SET_MODEL(ENT(pev), "models/w_battery.mdl");
CItem::Spawn( );
}
void Precache( void )
{
PRECACHE_MODEL ("models/w_battery.mdl");
PRECACHE_SOUND( "items/gunpickup2.wav" );
}
BOOL MyTouch( CBasePlayer *pPlayer )
{
if ((pPlayer->pev->armorvalue < MAX_NORMAL_BATTERY) &&
(pPlayer->pev->weapons & (1<<WEAPON_SUIT)))
{
int pct;
char szcharge[64];

pPlayer->pev->armorvalue += gSkillData.batteryCapacity;
pPlayer->pev->armorvalue = min(pPlayer->pev->armorvalue, MAX_NORMAL_BATTERY);

EMIT_SOUND( pPlayer->edict(), CHAN_ITEM, "items/gunpickup2.wav", 1, ATTN_NORM );

MESSAGE_BEGIN( MSG_ONE, gmsgItemPickup, NULL, pPlayer->pev );
WRITE_STRING( STRING(pev->classname) );
MESSAGE_END();


// Suit reports new power level
// For some reason this wasn't working in release build -- round it.
pct = (int)( (float)(pPlayer->pev->armorvalue * 100.0) * (1.0/MAX_NORMAL_BATTERY) + 0.5);
pct = (pct / 5);
if (pct > 0)
pct--;

sprintf( szcharge,"!HEV_%1dP", pct );

//EMIT_SOUND_SUIT(ENT(pev), szcharge);
pPlayer->SetSuitUpdate(szcharge, FALSE, SUIT_NEXT_IN_30SEC);
return TRUE;
}
return FALSE;
}
};

LINK_ENTITY_TO_CLASS(item_battery, CItemBattery);

class CItemAntidote : public CItem
{
void Spawn( void )
{
Precache( );
SET_MODEL(ENT(pev), "models/w_antidote.mdl");
CItem::Spawn( );
}
void Precache( void )
{
PRECACHE_MODEL ("models/w_antidote.mdl");
}
BOOL MyTouch( CBasePlayer *pPlayer )
{
pPlayer->SetSuitUpdate("!HEV_DET4", FALSE, SUIT_NEXT_IN_1MIN);

pPlayer->m_rgItems[ITEM_ANTIDOTE] += 1;
return TRUE;
}
};

LINK_ENTITY_TO_CLASS(item_antidote, CItemAntidote);

class CItemSecurity : public CItem
{
void Spawn( void )
{
Precache( );
SET_MODEL(ENT(pev), "models/w_security.mdl");
CItem::Spawn( );
}
void Precache( void )
{
PRECACHE_MODEL ("models/w_security.mdl");
}
BOOL MyTouch( CBasePlayer *pPlayer )
{
pPlayer->m_rgItems[ITEM_SECURITY] += 1;
return TRUE;
}
};

LINK_ENTITY_TO_CLASS(item_security, CItemSecurity);

class CItemLongJump : public CItem
{
void Spawn( void )
{
Precache( );
SET_MODEL(ENT(pev), "models/w_longjump.mdl");
CItem::Spawn( );
}
void Precache( void )
{
PRECACHE_MODEL ("models/w_longjump.mdl");
}
BOOL MyTouch( CBasePlayer *pPlayer )
{
if ( pPlayer->m_fLongJump )
{
return FALSE;
}

if ( ( pPlayer->pev->weapons & (1<<WEAPON_SUIT) ) )
{
pPlayer->m_fLongJump = TRUE;// player now has longjump module

g_engfuncs.pfnSetPhysicsKeyValue( pPlayer->edict(), "slj", "1" );

MESSAGE_BEGIN( MSG_ONE, gmsgItemPickup, NULL, pPlayer->pev );
WRITE_STRING( STRING(pev->classname) );
MESSAGE_END();

// ... and tell them that we now have an NVG
MESSAGE_BEGIN( MSG_ONE, gmsgNVG, NULL, pPlayer->pev ); <-HIER
WRITE_BYTE( 1 );
WRITE_BYTE( pPlayer->m_flNVGBattery );
MESSAGE_END( );

EMIT_SOUND_SUIT( pPlayer->edict(), "!HEV_A1" ); // Play the longjump sound UNDONE: Kelly? correct sound?
return TRUE;
}
return FALSE;
}
};

LINK_ENTITY_TO_CLASS( item_longjump, CItemLongJump );

// advanced NVG
extern int gmsgNVG; // we need to send this message

class CItemNVG : public CItem
{
void Spawn( void )
{
Precache( );
SET_MODEL(ENT(pev), "models/w_longjump.mdl"); // you'll want to change this
CItem::Spawn( );
}
void Precache( void )
{
PRECACHE_MODEL("models/w_longjump.mdl"); // you'll want to change this
PRECACHE_SOUND("buttons/blip1.wav");
}
BOOL MyTouch( CBasePlayer *pPlayer )
{
if ( pPlayer->m_fNVG ) // does the player already have it
{
return FALSE; // if so, quit
}

if ( ( pPlayer->pev->weapons & (1<<WEAPON_SUIT) ) )
{
pPlayer->m_fNVG = TRUE; // player now has night vision goggles

// make the client.dll print out the symbol on ammo history
MESSAGE_BEGIN( MSG_ONE, gmsgItemPickup, NULL, pPlayer->pev );
WRITE_STRING( STRING(pev->classname) );
MESSAGE_END();

// play a sound to tell the player he's picked up the NVG
EMIT_SOUND(pPlayer->edict(), CHAN_WEAPON, "buttons/blip1.wav", 0.8, ATTN_NORM );
return TRUE;
}
return FALSE;
}
};

LINK_ENTITY_TO_CLASS( item_nvg, CItemNVG );
// advanced NVG

thx im voraus

--

zum Seitenanfang zum Seitenende Profil || Suche
010
01.06.2001, 20:15
Archangel



muss ich das verstehen? wieso wird denn in der CLongjump die NVGpickup msg gesendet?

--

Mar 01 01:10:13 <voice> jo
Mar 01 01:10:40 <voice> bis dann ^^
Mar 01 01:11:20 <Archangel> jo
**** ENDING LOGGING AT Tue Mar 1 01:58:13 2005

zum Seitenanfang zum Seitenende Profil || Suche