Bennu Game Development

Foros en Español => Mesa de Ayuda => Topic started by: Arcontus on February 26, 2019, 03:06:30 PM

Title: Necesito la API de Steam
Post by: Arcontus on February 26, 2019, 03:06:30 PM
Hola chicos,

necesito ayuda para hacer la DLL para Bennu de la API de Steam.

Inicialmente necesito algo muy sencillo, inicializar la API con el userID y appID para el momento en que arranco la aplicación. Creo que con esto basta para poder subir el juego a Steam.

Dispongo de un entorno en Code::Blocks, donde he compilado la DLL del portapapeles : https://forum.bennugd.org/index.php/topic,4706.msg73500.html#msg73500
Dispongo de la SDK de la api de Steam: https://partner.steamgames.com/downloads/steamworks_sdk.zip

Y he ejecutado con éxito un código de ejemplo en C++:

#include <iostream>
#include "steam_api.h"

using namespace std;


int main()
{
    if ( SteamAPI_RestartAppIfNecessary( 480 ) ) // Replace with your App ID
    {
        return 1;
    }
    if ( !SteamAPI_Init() )
    {
        printf( "Fatal Error - Steam must be running to play this game (SteamAPI_Init() failed).\n" ); return 1;
    }
    return 0;
}


Pero al tratar de ejecutar en C un simple "hola mundo" me da error al agregar la librería "steam_api.h":
#include <stdio.h>
#include <stdlib.h>
#include "steam_api.h"

int main()
{
    printf("Hello world!\n");

    return 0;
}


||=== Build: Release in Steam_prueba (compiler: GNU GCC Compiler) ===|
C:\Bennu\sdk\public\steam\steamtypes.h|109|error: variably modified 'Salt_t' at file scope|
C:\Bennu\sdk\public\steam\steamtypes.h|125|error: initializer element is not constant|
C:\Bennu\sdk\public\steam\steamclientpublic.h|378|error: expected declaration specifiers or '...' before '*' token|
C:\Bennu\sdk\public\steam\steamclientpublic.h|393|error: enumerator value for 'k_EChatInstanceFlagClan' is not an integer constant|
C:\Bennu\sdk\public\steam\steamclientpublic.h|394|error: enumerator value for 'k_EChatInstanceFlagLobby' is not an integer constant|
C:\Bennu\sdk\public\steam\steamclientpublic.h|395|error: enumerator value for 'k_EChatInstanceFlagMMSLobby' is not an integer constant|
C:\Bennu\sdk\public\steam\steamclientpublic.h|495|error: unknown type name 'bool'|
C:\Bennu\sdk\public\steam\steamclientpublic.h|495|error: unknown type name 'ELaunchOptionType'|
C:\Bennu\sdk\public\steam\steamclientpublic.h|557|error: unknown type name 'bool'|
C:\Bennu\sdk\public\steam\steamclientpublic.h|557|error: unknown type name 'EVRHMDType'|
C:\Bennu\sdk\public\steam\steamclientpublic.h|566|error: unknown type name 'bool'|
C:\Bennu\sdk\public\steam\steamclientpublic.h|566|error: unknown type name 'EVRHMDType'|
C:\Bennu\sdk\public\steam\steamclientpublic.h|575|error: unknown type name 'bool'|
C:\Bennu\sdk\public\steam\steamclientpublic.h|575|error: unknown type name 'EVRHMDType'|
C:\Bennu\sdk\public\steam\steamclientpublic.h|584|error: unknown type name 'bool'|
C:\Bennu\sdk\public\steam\steamclientpublic.h|584|error: unknown type name 'EVRHMDType'|
C:\Bennu\sdk\public\steam\steamclientpublic.h|655|error: unknown type name 'class'|
C:\Bennu\sdk\public\steam\steamclientpublic.h|656|error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token|
C:\Bennu\sdk\public\steam\steamclientpublic.h|1033|error: unknown type name 'bool'|
C:\Bennu\sdk\public\steam\steamclientpublic.h|1033|error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token|
C:\Bennu\sdk\public\steam\steamclientpublic.h|1096|error: unknown type name 'class'|
C:\Bennu\sdk\public\steam\steamclientpublic.h|1097|error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token|
C:\Bennu\sdk\public\steam\steam_api_common.h|56|warning: "__cdecl" redefined [enabled by default]|
C:\Users\David\Documents\c prueba\Steam_prueba\main.c|1|note: this is the location of the previous definition|
C:\Bennu\sdk\public\steam\steam_api_common.h|58|error: expected identifier or '(' before string constant|
C:\Bennu\sdk\public\steam\steam_api_common.h|59|error: expected identifier or '(' before string constant|
C:\Bennu\sdk\public\steam\steam_api_common.h|92|error: expected identifier or '(' before string constant|
C:\Bennu\sdk\public\steam\steam_api_common.h|109|error: expected identifier or '(' before string constant|
C:\Bennu\sdk\public\steam\steam_api_common.h|121|error: unknown type name 'class'|
C:\Bennu\sdk\public\steam\steam_api_common.h|122|error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token|
C:\Bennu\sdk\public\steam\steam_api_common.h|145|error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token|
C:\Bennu\sdk\public\steam\steam_api_common.h|163|error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token|
C:\Bennu\sdk\public\steam\steam_api_common.h|194|error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token|
C:\Bennu\sdk\public\steam\steam_api_common.h|219|error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token|
C:\Bennu\sdk\public\steam\steam_api_internal.h|17|error: expected identifier or '(' before string constant|
C:\Bennu\sdk\public\steam\steam_api_internal.h|18|error: expected identifier or '(' before string constant|
C:\Bennu\sdk\public\steam\steam_api_internal.h|20|error: expected identifier or '(' before string constant|
C:\Bennu\sdk\public\steam\steam_api_internal.h|21|error: expected identifier or '(' before string constant|
C:\Bennu\sdk\public\steam\steam_api_internal.h|23|error: expected identifier or '(' before string constant|
C:\Bennu\sdk\public\steam\steam_api_internal.h|24|error: expected identifier or '(' before string constant|
C:\Bennu\sdk\public\steam\steam_api_internal.h|25|error: expected identifier or '(' before string constant|
C:\Bennu\sdk\public\steam\steam_api_internal.h|26|error: expected identifier or '(' before string constant|
C:\Bennu\sdk\public\steam\steam_api_internal.h|27|error: expected identifier or '(' before string constant|
C:\Bennu\sdk\public\steam\steam_api_internal.h|28|error: expected identifier or '(' before string constant|
C:\Bennu\sdk\public\steam\steam_api_internal.h|29|error: expected identifier or '(' before string constant|
C:\Bennu\sdk\public\steam\steam_api_internal.h|30|error: expected identifier or '(' before string constant|
C:\Bennu\sdk\public\steam\steam_api_internal.h|56|error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token|
C:\Bennu\sdk\public\steam\steam_api_internal.h|65|error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token|
C:\Bennu\sdk\public\steam\steam_api_internal.h|79|error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token|
C:\Bennu\sdk\public\steam\steam_api_internal.h|85|error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token|
C:\Bennu\sdk\public\steam\steam_api_internal.h|95|error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token|
C:\Bennu\sdk\public\steam\steam_api_internal.h|101|error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token|
||More errors follow but not being shown.|
||Edit the max errors limit in compiler options...|
||=== Build failed: 50 error(s), 1 warning(s) (0 minute(s), 0 second(s)) ===|


¿Puedo hacer la DLL a partir de una compilacion en C++? ¿O he de hacer algun tipo de magia adicional?

En Pixtudio hay un código que seguramente se podría usar de referencia para portar a Bennu: https://gitlab.com/josebagar/pixtudio/tree/bigmap/modules/mod_steam


Por último y no menos importante, aun no dispongo de cuenta de SteamWorks, pero en breve se solucionará. Creo que esto no es necesario para hacer la DLL de Bennu.


Title: Re:Necesito la API de Steam
Post by: Arcontus on February 27, 2019, 11:10:47 AM
Hola chicos,

estoy haciendo ingeniería inversa de la libreria de pixtudio de Steam, pero me está dando una serie de errores inesperados:
DLCONSTANT __bgdexport( mod_steam, constants_def )[] =
{
    { "AVATAR_SMALL"   , TYPE_INT, 0  },
    { "AVATAR_MEDIUM"  , TYPE_INT, 1 },
    { "AVATAR_LARGE"   , TYPE_INT, 2  },
    { NULL             , 0       , 0 }
} ;
mod_steam_symbols.h|36|error: invalid conversion from 'int' to 'BASETYPE' [-fpermissive]

según el manual de OSK:*Para definir constantes que se puedan utilizar desde Bennu, deberíamos  escribir:
DLCONSTANT  __bgdexport( nombremodulo, constants_def )[] =
{
    { "NOMBRE_CONSTANTE", TYPE_INT, 0  },
    { "NOMBRE_CONSTANTE", TYPE_INT, 1  },
    { NULL          , 0       , 0  }
} ;
Si añado la opción -fpermissive se traga el error y continua compilando, pero no se si dará error en ejecución.
Title: Re:Necesito la API de Steam
Post by: Arcontus on February 27, 2019, 12:38:40 PM
Bueno chicos, creo que lo he conseguido:
He adaptado el commit: https://gitlab.com/josebagar/pixtudio/commit/16e6306644dfa0f63faa27282b0a77b46013fa0b que era mucho más simple que la última versión del código a BennuGD y he logrado compilarlo.

Al arrancar:Steam Init OK.

Al cerrar la aplicación:
Setting breakpad minidump AppID = 480Steam_SetMinidumpSteamID:  Caching Steam ID:  76561197991559430 [API loaded no]

Pero hay una cosa que me sigue mosqueando, si no le indico al compilador (Codeblocks) la opción "-fpermissive", me da este error en compilación:
"invalid conversion from 'int (*)(INSTANCE*, int*) {aka int (*)(_instance*, int*)}' to 'void*' [-fpermissive]"
En el código siguiente:

DLSYSFUNCS __bgdexport( mod_steam, functions_exports )[] =
{
    { "STEAM_INIT" , "I"  , TYPE_INT     , steam_init },
    { "STEAM_CLOSE", "" , TYPE_INT  , steam_close},
    { 0             , 0       , 0           , 0                }
};


Title: Re:Necesito la API de Steam
Post by: SplinterGU on February 27, 2019, 02:37:18 PM
cambia las definiciones de las funciones que sean necesarias y listo
Title: Re:Necesito la API de Steam
Post by: Arcontus on February 27, 2019, 05:32:42 PM
Quote from: SplinterGU on February 27, 2019, 02:37:18 PM
cambia las definiciones de las funciones que sean necesarias y listo
Eso mismo es lo que yo pienso :D, pero no veo el error.

Mira, te paso una porción de código donde hay el problema:
(Función)
static int steam_close(INSTANCE *my, int *params) {
        if (Steam_Cargado_Ok) {
            // Shutdown the SteamAPI
            SteamAPI_Shutdown();

            // Shutdown Steam CEG
            // c_Steamworks_TermCEGLibrary();
            return 0;
        }

        return -1;
    }

(Export)
DLSYSFUNCS __bgdexport( mod_steam, functions_exports )[] =
{
    { "STEAM_INIT" , "I"  , TYPE_INT     , steam_init },
    { "STEAM_CLOSE", "" , TYPE_INT  , steam_close},
    { 0             , 0       , 0           , 0                }
};

(Error)invalid conversion from 'int (*)(INSTANCE*, int*) {aka int (*)(_instance*, int*)}' to 'void*' [-fpermissive]|

Lo mismo es una "," o un "." y no lo estoy viendo, que esto a veces me pasa.
Title: Re:Necesito la API de Steam
Post by: SplinterGU on February 28, 2019, 03:00:02 AM
hace tiempo no compilo... algun numero de linea? estan los includes?
Title: Re:Necesito la API de Steam
Post by: Arcontus on February 28, 2019, 08:40:16 AM
Quote from: SplinterGU on February 28, 2019, 03:00:02 AM
hace tiempo no compilo... algun numero de linea? estan los includes?

El número de linea de error es justo el }; de la última linea del export:DLSYSFUNCS __bgdexport( mod_steam, functions_exports )[] =
{
    { "STEAM_INIT" , "I"  , TYPE_INT     , steam_init },
    { "STEAM_CLOSE", "" , TYPE_INT  , steam_close},
    { 0             , 0       , 0           , 0                }
};


El fallo lo repite 2 veces coincidiendo con el número de funciones exportadas.

Los includes son:#include "bgddl.h"
#include "stdio.h"
#include "unistd.h"
#include "bgdrtm.h"
#include "steam_api.h"

Yo lo veo correcto, pero insisto, lo mismo es una "," o un "." que no veo.

Title: Re:Necesito la API de Steam
Post by: SplinterGU on February 28, 2019, 11:25:46 AM
claro, ya veo... pues claro, estas usando c++...
Title: Re:Necesito la API de Steam
Post by: Arcontus on February 28, 2019, 12:30:51 PM
Quote from: SplinterGU on February 28, 2019, 11:25:46 AM
claro, ya veo... pues claro, estas usando c++...
Si, creo que lo indiqué al principio de todo, hay algún problema en ello?
Será inestable la librería resultante debido a este sobrecasteo?
Hay alguna manera mejor de hacerlo?
Title: Re:Necesito la API de Steam
Post by: SplinterGU on February 28, 2019, 02:31:49 PM
declara la estructura y las funciones como external "C"... las que van a interfacear con BennuGD.

https://isocpp.org/wiki/faq/mixing-c-and-cpp#call-cpp