author | nemo |
Wed, 28 Oct 2015 10:01:31 -0400 | |
changeset 11255 | 66796cd627d8 |
parent 11151 | 5c40c65b619d |
child 11408 | b894922d58cc |
child 13511 | 36f3f77e9b1b |
permissions | -rw-r--r-- |
4930 | 1 |
(* |
2 |
* Hedgewars, a free turn based strategy game |
|
11046 | 3 |
* Copyright (c) 2004-2015 Andrey Korotaev <unC0Rr@gmail.com> |
4930 | 4 |
* |
5 |
* This program is free software; you can redistribute it and/or modify |
|
6 |
* it under the terms of the GNU General Public License as published by |
|
7 |
* the Free Software Foundation; version 2 of the License |
|
8 |
* |
|
9 |
* This program is distributed in the hope that it will be useful, |
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
13 |
* |
|
14 |
* You should have received a copy of the GNU General Public License |
|
15 |
* along with this program; if not, write to the Free Software |
|
10108
c68cf030eded
update FSF address. note: two sdl include files (by Sam Lantinga) still have the old FSF address in their copyright - but I ain't gonna touch their copyright headers
sheepluva
parents:
10017
diff
changeset
|
16 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
4930 | 17 |
*) |
2698 | 18 |
|
6033
6bcc36225162
fix compiling for android, strip out all delphi code, objfpc ftw
koda
parents:
6027
diff
changeset
|
19 |
{$INCLUDE "options.inc"} |
5452
3edc3e3b8cdc
Created callbacks to give the frontend information of maxteams/hogs
Xeli
parents:
5166
diff
changeset
|
20 |
|
7048
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
21 |
(* |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
22 |
* When engine is compiled as library this unit will export functions |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
23 |
* as C declarations for convenient library usage in your application |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
24 |
* and language of choice. |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
25 |
* |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
26 |
* See also: C declarations on Wikipedia |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
27 |
* http://en.wikipedia.org/wiki/X86_calling_conventions#cdecl |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
28 |
*) |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
29 |
|
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
30 |
Library hwLibrary; |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
31 |
|
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
32 |
uses hwengine, uTypes, uConsts, uVariables, uSound, uCommands, uUtils, |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
33 |
uLocale{$IFDEF ANDROID}, jni{$ENDIF}; |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
34 |
|
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
35 |
{$INCLUDE "config.inc"} |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
36 |
|
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
37 |
// retrieve protocol information |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
38 |
procedure HW_versionInfo(netProto: PLongInt; versionStr: PPChar); cdecl; export; |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
39 |
begin |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
40 |
netProto^:= cNetProtoVersion; |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
41 |
versionStr^:= cVersionString; |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
42 |
end; |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
43 |
|
9309
7e8f91634f80
engine compiles for ios again, but SDL bindings are outdated. Fix some warnings
koda
parents:
9080
diff
changeset
|
44 |
function HW_versionString: PChar; cdecl; export; |
7e8f91634f80
engine compiles for ios again, but SDL bindings are outdated. Fix some warnings
koda
parents:
9080
diff
changeset
|
45 |
begin |
7e8f91634f80
engine compiles for ios again, but SDL bindings are outdated. Fix some warnings
koda
parents:
9080
diff
changeset
|
46 |
exit(cVersionString + '-r' + cRevisionString + ' (' + cHashString + ')'); |
7e8f91634f80
engine compiles for ios again, but SDL bindings are outdated. Fix some warnings
koda
parents:
9080
diff
changeset
|
47 |
end; |
7e8f91634f80
engine compiles for ios again, but SDL bindings are outdated. Fix some warnings
koda
parents:
9080
diff
changeset
|
48 |
|
7048
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
49 |
// equivalent to esc+y; when closeFrontend = true the game exits after memory cleanup |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
50 |
procedure HW_terminate(closeFrontend: boolean); cdecl; export; |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
51 |
begin |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
52 |
closeFrontend:= closeFrontend; // avoid hint |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
53 |
ParseCommand('forcequit', true); |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
54 |
end; |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
55 |
|
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
56 |
function HW_getWeaponNameByIndex(whichone: LongInt): PChar; cdecl; export; |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
57 |
begin |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
58 |
HW_getWeaponNameByIndex:= (str2pchar(trammo[Ammoz[TAmmoType(whichone+1)].NameId])); |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
59 |
end; |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
60 |
|
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
61 |
(*function HW_getWeaponCaptionByIndex(whichone: LongInt): PChar; cdecl; export; |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
62 |
begin |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
63 |
HW_getWeaponCaptionByIndex:= (str2pchar(trammoc[Ammoz[TAmmoType(whichone+1)].NameId])); |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
64 |
end; |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
65 |
|
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
66 |
function HW_getWeaponDescriptionByIndex(whichone: LongInt): PChar; cdecl; export; |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
67 |
begin |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
68 |
HW_getWeaponDescriptionByIndex:= (str2pchar(trammod[Ammoz[TAmmoType(whichone+1)].NameId])); |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
69 |
end;*) |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
70 |
|
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
71 |
function HW_getNumberOfWeapons: LongInt; cdecl; export; |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
72 |
begin |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
73 |
HW_getNumberOfWeapons:= ord(high(TAmmoType)); |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
74 |
end; |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
75 |
|
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
76 |
function HW_getMaxNumberOfHogs: LongInt; cdecl; export; |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
77 |
begin |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
78 |
HW_getMaxNumberOfHogs:= cMaxHHIndex + 1; |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
79 |
end; |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
80 |
|
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
81 |
function HW_getMaxNumberOfTeams: LongInt; cdecl; export; |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
82 |
begin |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
83 |
HW_getMaxNumberOfTeams:= cMaxTeams; |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
84 |
end; |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
85 |
|
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
86 |
procedure HW_memoryWarningCallback; cdecl; export; |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
87 |
begin |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
88 |
ReleaseSound(false); |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
89 |
end; |
5452
3edc3e3b8cdc
Created callbacks to give the frontend information of maxteams/hogs
Xeli
parents:
5166
diff
changeset
|
90 |
|
6027 | 91 |
{$IFDEF ANDROID} |
5452
3edc3e3b8cdc
Created callbacks to give the frontend information of maxteams/hogs
Xeli
parents:
5166
diff
changeset
|
92 |
function JNI_HW_versionInfoNet(env: PJNIEnv; obj: JObject):JInt;cdecl; |
3edc3e3b8cdc
Created callbacks to give the frontend information of maxteams/hogs
Xeli
parents:
5166
diff
changeset
|
93 |
begin |
6033
6bcc36225162
fix compiling for android, strip out all delphi code, objfpc ftw
koda
parents:
6027
diff
changeset
|
94 |
env:= env; // avoid hint |
6bcc36225162
fix compiling for android, strip out all delphi code, objfpc ftw
koda
parents:
6027
diff
changeset
|
95 |
obj:= obj; // avoid hint |
6bcc36225162
fix compiling for android, strip out all delphi code, objfpc ftw
koda
parents:
6027
diff
changeset
|
96 |
JNI_HW_versionInfoNet:= cNetProtoVersion; |
5452
3edc3e3b8cdc
Created callbacks to give the frontend information of maxteams/hogs
Xeli
parents:
5166
diff
changeset
|
97 |
end; |
3edc3e3b8cdc
Created callbacks to give the frontend information of maxteams/hogs
Xeli
parents:
5166
diff
changeset
|
98 |
|
3edc3e3b8cdc
Created callbacks to give the frontend information of maxteams/hogs
Xeli
parents:
5166
diff
changeset
|
99 |
function JNI_HW_versionInfoVersion(env: PJNIEnv; obj: JObject):JString; cdecl; |
6033
6bcc36225162
fix compiling for android, strip out all delphi code, objfpc ftw
koda
parents:
6027
diff
changeset
|
100 |
var envderef : JNIEnv; |
5452
3edc3e3b8cdc
Created callbacks to give the frontend information of maxteams/hogs
Xeli
parents:
5166
diff
changeset
|
101 |
begin |
6033
6bcc36225162
fix compiling for android, strip out all delphi code, objfpc ftw
koda
parents:
6027
diff
changeset
|
102 |
obj:= obj; // avoid hint |
6bcc36225162
fix compiling for android, strip out all delphi code, objfpc ftw
koda
parents:
6027
diff
changeset
|
103 |
envderef:= @env; |
6bcc36225162
fix compiling for android, strip out all delphi code, objfpc ftw
koda
parents:
6027
diff
changeset
|
104 |
JNI_HW_versionInfoVersion := envderef^.NewStringUTF(env, PChar(cVersionString)); |
5452
3edc3e3b8cdc
Created callbacks to give the frontend information of maxteams/hogs
Xeli
parents:
5166
diff
changeset
|
105 |
end; |
3edc3e3b8cdc
Created callbacks to give the frontend information of maxteams/hogs
Xeli
parents:
5166
diff
changeset
|
106 |
|
7508
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7500
diff
changeset
|
107 |
procedure JNI_HW_GenLandPreview(env: PJNIEnv; c: JClass; port: JInt); cdecl; |
7500
6253cae96f21
engine: Added JNI-compatible function to start map generation
Medo <smaxein@googlemail.com>
parents:
7083
diff
changeset
|
108 |
begin |
10017 | 109 |
GenLandPreview(port); |
7508
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7500
diff
changeset
|
110 |
end; |
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7500
diff
changeset
|
111 |
|
6025
cac1d5601d7c
reviewed the build system and parts of the previous merge, performed some code cleanup
koda
parents:
5452
diff
changeset
|
112 |
exports |
10017 | 113 |
JNI_HW_versionInfoNet name Java_Prefix+'HWversionInfoNetProto', |
114 |
JNI_HW_versionInfoVersion name Java_Prefix+'HWversionInfoVersion', |
|
7500
6253cae96f21
engine: Added JNI-compatible function to start map generation
Medo <smaxein@googlemail.com>
parents:
7083
diff
changeset
|
115 |
JNI_HW_GenLandPreview name Java_Prefix + 'HWGenLandPreview', |
5452
3edc3e3b8cdc
Created callbacks to give the frontend information of maxteams/hogs
Xeli
parents:
5166
diff
changeset
|
116 |
HW_getNumberOfweapons name Java_Prefix + 'HWgetNumberOfWeapons', |
3edc3e3b8cdc
Created callbacks to give the frontend information of maxteams/hogs
Xeli
parents:
5166
diff
changeset
|
117 |
HW_getMaxNumberOfHogs name Java_Prefix + 'HWgetMaxNumberOfHogs', |
6035
bdd0528ee8a6
Close a game without leaking memory. It should be noted that sending an SDL Quit event leaks memory
Xeli
parents:
6033
diff
changeset
|
118 |
HW_getMaxNumberOfTeams name Java_Prefix + 'HWgetMaxNumberOfTeams', |
7083 | 119 |
Game; |
7048
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
120 |
{$ELSE} |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
121 |
exports |
10175
c92668840ea8
Remove game/preview functions split in library mode, just let normal procedure run instead:
unc0rr
parents:
10108
diff
changeset
|
122 |
RunEngine, |
7048
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
123 |
LoadLocaleWrapper, |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
124 |
HW_versionInfo, |
9309
7e8f91634f80
engine compiles for ios again, but SDL bindings are outdated. Fix some warnings
koda
parents:
9080
diff
changeset
|
125 |
HW_versionString, |
7048
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
126 |
HW_terminate, |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
127 |
HW_getNumberOfWeapons, |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
128 |
HW_getMaxNumberOfHogs, |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
129 |
HW_getMaxNumberOfTeams, |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
130 |
HW_getWeaponNameByIndex, |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
131 |
HW_memoryWarningCallback; |
5452
3edc3e3b8cdc
Created callbacks to give the frontend information of maxteams/hogs
Xeli
parents:
5166
diff
changeset
|
132 |
{$ENDIF} |
3edc3e3b8cdc
Created callbacks to give the frontend information of maxteams/hogs
Xeli
parents:
5166
diff
changeset
|
133 |
|
4187 | 134 |
begin |
2698 | 135 |
end. |