Panel użytkownika
Nazwa użytkownika:
Hasło:
Nie masz jeszcze konta?

format pliku dll.

Ostatnio zmodyfikowano 2009-02-23 19:59
Autor Wiadomość
Pasza196
Temat założony przez niniejszego użytkownika
format pliku dll.
» 2009-02-23 18:57:49
Witam chciałbym zapytać czy ktoś by mógł z tego kodu:

C/C++
centity_t * getEntityByIndex( int index ) { return & cg_entities[ index ]; }

int target = - 1;
vec3_t pAngles;

qboolean isVisible( int index ) {
    centity_t * cent = getEntityByIndex( index );
    trace_t tr;
   
    CG_Trace( & tr, cg.refdef.vieworg, vec3_origin, vec3_origin, cent->ent.origin, cg.chasedNum + 1, MASK_OPAQUE );
   
    if( tr.fraction == 1.0 )
         return qtrue;
    else
         return qfalse;
   
}

qboolean isValidPlayer( int index ) {
    if( index != cgs.playerNum || index != cg.chasedNum )
         return qfalse;
   
    return qtrue;
}

void calcAimingOrigin( int index ) {
    vec3_t forward, right, up, tAngles;
    centity_t * cent = getEntityByIndex( index );
   
    VectorCopy( cent->ent.origin, pAngles );
    AngleVectors( tAngles, forward, right, up );
   
    pAngles = pAngles + forward;
    pAngles = pAngles + right;
    pAngles = pAngles + up;
}

void searchTarget() {
    target = - 1;
    for( int index = 0; index < MAX_CLIENTS; index++ ) {
        if( isValidPlayer( index ) && isVisible( index ) ) {
            target = index;
            break;
        }
    }
}

if( target != - 1 ) {
    if( cg_aim->integer ) {
        float vecScreen[ 2 ];
       
        calcAimingOrigin( target );
        trap_R_TransformVectorToScreen( & cg.refdef, pAngles, vecScreen );
       
        if( cg_aim->integer == 1 )
             SetCursorPos( vecScreen[ 0 ], vecScreen[ 1 ] );
        else if( cg_aim->integer == 2 )
             VectorCopy( pAngles, cg.refdef.viewangles );
       
    }
    if( cg_shoot->integer ) {
        usercmd_t cmd;
        trap_NET_GetUserCmd( trap_NET_GetCurrentUserCmdNum(), & cmd );
       
        cmd.buttons |= BUTTON_ATTACK;
    }
}

zrobić plik dll. a jak nie to proszę o nakierowanie mnie jak to zrobić  Pozdrawiam    Ps. jak nie chcesz pomóc to nie pisze głupot
P-4402
pekfos
» 2009-02-23 19:07:06
poszukaj. było już tu kilka takich tematów;
na początku nowy projekt->biblioteka dll
tam gdzie jest
C/C++
#if BUILDING_DLL
# define DLLIMPORT __declspec (dllexport)
#else
# define DLLIMPORT __declspec (dllimport)
#endif
 ma być
C/C++
#if BUILDING_DLL
# define DLLIMPORT __declspec (dllexport)
# define DLLFUNCTION __stdcall __declspec (dllexport)
#else
# define DLLIMPORT __declspec (dllimport)
# define DLLFUNCTION __stdcall __declspec (dllimport)
#endif

a funkcje
przykładowo
int dodaj( int, int );
napisać trzeba tak
int DLLFUNCTION dodaj( int, int );
na samym początku pliku.h napisz extern "C" aby
nie było tworzenia dziwacznych przerobionych nazw.
to w pliku *.h
a w *.cpp definicje funkcji. tak jak ta:
int DLLFUNCTION dodaj( int a, int b );
DLLFUNCTION jest do funkcji
a DLLIMPORT do klas

to chyba wszystko;
P-4406
DejaVu
» 2009-02-23 19:10:23
Znalazłem jakiś temat na forum (jest ich więcej, ale ten chyba jest najlepszy do Twojego pytania): http://forum.ddt.pl/?Tid=521
P-4407
Pasza196
Temat założony przez niniejszego użytkownika
» 2009-02-23 19:22:49
wiem że nie powinienem prosić ale czy mógłby ktoś zrobić mi tą dll???? zielony jestem w programowaniu a potrzebuje ten plik;)
P-4409
pekfos
» 2009-02-23 19:59:19
przerób ten kod i dokładnie zapoznaj sie z jego działaniem
a może sie czegoś nauczysz:)

Plik: dllmain.cpp
C/C++
/* Replace "dll.h" with the name of your header */
#include "dll.h"
#include <windows.h>

centity_t * DLLFUNCTION getEntityByIndex( int index ) { return & cg_entities[ index ]; }

int target = - 1;
vec3_t pAngles;

qboolean DLLFUNCTION isVisible( int index ) {
    centity_t * cent = getEntityByIndex( index );
    trace_t tr;
   
    CG_Trace( & tr, cg.refdef.vieworg, vec3_origin, vec3_origin, cent->ent.origin, cg.chasedNum + 1, MASK_OPAQUE );
   
    if( tr.fraction == 1.0 )
         return qtrue;
    else
         return qfalse;
   
}

qboolean DLLFUNCTION isValidPlayer( int index ) {
    if( index != cgs.playerNum || index != cg.chasedNum )
         return qfalse;
   
    return qtrue;
}

void DLLFUNCTION calcAimingOrigin( int index ) {
    vec3_t forward, right, up, tAngles;
    centity_t * cent = getEntityByIndex( index );
   
    VectorCopy( cent->ent.origin, pAngles );
    AngleVectors( tAngles, forward, right, up );
   
    pAngles = pAngles + forward;
    pAngles = pAngles + right;
    pAngles = pAngles + up;
}

void DLLFUNCTION searchTarget() {
    target = - 1;
    for( int index = 0; index < MAX_CLIENTS; index++ ) {
        if( isValidPlayer( index ) && isVisible( index ) ) {
            target = index;
            break;
        }
    }
}

BOOL APIENTRY DllMain( HINSTANCE hInst /* Library instance handle. */,
DWORD reason /* Reason this function is being called. */,
LPVOID reserved /* Not used. */ )
{
    switch( reason )
    {
    case DLL_PROCESS_ATTACH:
        break;
       
    case DLL_PROCESS_DETACH:
        break;
       
    case DLL_THREAD_ATTACH:
        break;
       
    case DLL_THREAD_DETACH:
        break;
    }
   
    /* Returns TRUE on success, FALSE on failure */
    return TRUE;
}
Plik: dll.h
C/C++
extern "C"
#ifndef _DLL_H_
#define _DLL_H_

#if BUILDING_DLL
# define DLLFUNCTION __stdcall __declspec (dllexport)
#else /* Not BUILDING_DLL */
# define DLLFUNCTION __stdcall __declspec (dllimport)
#endif /* Not BUILDING_DLL */

centiy_t * DLLFUNCTION getEntityByIndex( int );
qboolean DLLFUNCTION isVisible( int );
qboolean DLLFUNCTION isValidPlayer( int );
void DLLFUNCTION calcAimingOrigin( int );
void DLLFUNCTION searchTarget();


#endif /* _DLL_H_ */
P-4410
« 1 »
  Strona 1 z 1