Voila, j'avais programmé un bot se connectant à un monde de type active world (www.activeworlds.com).
Le bot était en console dos, et donc pas très beau, j'ai donc décidé de le transformer et de lui donner une interface win32, voila donc la source obtenue.
(Certaines fonctions peuvent vous paraître bizarre, ce sont des fonctions de l'api AW, Le programme se compile merveilleusement bien mais lorsque je le lance et que je clic sur connecter, le programme se bloque).
Le SDK comprenant aw.h aw.lib aw_static.lib et aw.dll est téléchargeable à cette adresse:
http://objects.activeworlds.com/downloads/sdk39.zip
// fichier main.cpp
#include <windows.h>
#include "resource.h"
#include "aw.h"
#include <stdio.h>
#include <stdlib.h>
#define BOSS_NUMBER 1
#define BOSS_PASS ""
#define BOT_NAME "Eole"
#define UNIVERS ""
#define MONDE ""
LRESULT CALLBACK MainProc(HWND Dlg,UINT message,WPARAM wParam,LPARAM lParam);
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
DialogBox(hInstance,(LPCTSTR)IDD_MAIN,NULL,(DLGPROC)MainProc);
return 0;
}
LRESULT CALLBACK MainProc(HWND Dlg,UINT message,WPARAM wParam,LPARAM lParam)
{
int Select;
int rc;
switch(message)
{
case WM_COMMAND:
Select=LOWORD(wParam);
switch(Select)
{
case IDCONNECT:
if (rc = aw_init (AW_BUILD)) {
printf ("Impossible d'initialiser l'API (reason %d)\n", rc);
exit (1);
}
if (rc = aw_create (UNIVERS, 0, 0)) {printf ("connection à l'univers echue (raison %d)\n", rc);}
aw_string_set (AW_LOGIN_NAME, BOT_NAME);
aw_int_set (AW_LOGIN_OWNER, BOSS_NUMBER);
aw_string_set (AW_LOGIN_PRIVILEGE_PASSWORD, BOSS_PASS);
aw_string_set (AW_LOGIN_APPLICATION, "Eole");
if (rc = aw_login ())printf ("Connection echue (raison %d)\n", rc);
if (rc = aw_enter (MONDE)) {printf ("Entree impossible dans le monde (Raison %d)\n", rc);}
aw_int_set (AW_MY_X, 0);
aw_int_set (AW_MY_Z, 0);
aw_int_set (AW_MY_YAW, 0);
if (rc = aw_state_change ()) {printf ("Coordonnees impossibles (raison %d)\n", rc);}
printf ("%s\n",aw_string(AW_WORLD_WELCOME_MESSAGE));
while (!aw_wait (-1));
aw_destroy ();
aw_term ();
return 0;
case IDOK:
EndDialog(Dlg,0);
return TRUE;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
default:
return FALSE;
}
}
// fichier resource.h
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by res.rc
//
#define IDCONNECT 1003
#define IDD_MAIN 101
#define IDC_TEXT 1001
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 102
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1002
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
//fichier res.rc
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// French (France) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_FRA)
#ifdef _WIN32
LANGUAGE LANG_FRENCH, SUBLANG_FRENCH
#pragma code_page(1252)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE DISCARDABLE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_MAIN DIALOG DISCARDABLE 0, 0, 269, 142
STYLE DS_MODALFRAME | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Eole 0.2"
FONT 8, "MS Sans Serif"
BEGIN
PUSHBUTTON "Quitter",IDOK,165,121,50,14
EDITTEXT IDC_TEXT,7,7,255,111,ES_MULTILINE | ES_AUTOVSCROLL |
WS_VSCROLL
DEFPUSHBUTTON "Connecter",IDCONNECT,47,121,50,14
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE
BEGIN
IDD_MAIN, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 262
TOPMARGIN, 7
BOTTOMMARGIN, 135
END
END
#endif // APSTUDIO_INVOKED
#endif // French (France) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED
Là, je suis coincé.
(Dur dur la programmation win32)
Merci :)