forked from github/server
This commit is contained in:
parent
8c152a95ae
commit
c8bc10dfe8
711 changed files with 275318 additions and 0 deletions
src
.cproject.projectJamfileJamrulesbuild_vs2003.batbuild_vs2005.bat
combined
Jamfileatoi36.cbindings.cppcurses.cgamecode.ckernel.cmain.cmalloc.cstdafx.cstdafx.cppstdafx.hstdafx.hpputil.c
common
Jamfile
attributes
Jamfileaggressive.halliance.calliance.hattributes.cattributes.hfleechance.cfleechance.hfollow.cfollow.hgiveitem.cgiveitem.hgm.cgm.hhate.chate.hiceberg.ciceberg.hkey.ckey.hmatmod.cmatmod.hmoved.cmoved.hmovement.cmovement.hobject.cobject.hoption.coption.horcification.corcification.hotherfaction.cotherfaction.hoverrideroads.coverrideroads.hracename.cracename.hraceprefix.craceprefix.hreduceproduction.creduceproduction.htargetregion.ctargetregion.hvariable.cvariable.hviewrange.cviewrange.h
config.hgamecode.vcprojgamecode
1017
src/.cproject
Normal file
1017
src/.cproject
Normal file
File diff suppressed because it is too large
Load diff
82
src/.project
Normal file
82
src/.project
Normal file
|
@ -0,0 +1,82 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>eressea</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
|
||||
<triggers>clean,full,incremental,</triggers>
|
||||
<arguments>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.cleanBuildTarget</key>
|
||||
<value></value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.enableCleanBuild</key>
|
||||
<value>true</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>?name?</key>
|
||||
<value></value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.append_environment</key>
|
||||
<value>true</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.stopOnError</key>
|
||||
<value>true</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.buildCommand</key>
|
||||
<value>make</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.contents</key>
|
||||
<value>org.eclipse.cdt.make.core.activeConfigSettings</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.buildLocation</key>
|
||||
<value>${workspace_loc:/eressea/Debug}</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>
|
||||
<value>true</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.enableAutoBuild</key>
|
||||
<value>false</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.enableFullBuild</key>
|
||||
<value>true</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.buildArguments</key>
|
||||
<value></value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.fullBuildTarget</key>
|
||||
<value></value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.autoBuildTarget</key>
|
||||
<value></value>
|
||||
</dictionary>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.cdt.core.ccnature</nature>
|
||||
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
|
||||
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
|
||||
<nature>org.eclipse.cdt.core.cnature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
7
src/Jamfile
Normal file
7
src/Jamfile
Normal file
|
@ -0,0 +1,7 @@
|
|||
SubDir TOP ;
|
||||
|
||||
SubInclude TOP common ;
|
||||
SubInclude TOP eressea ;
|
||||
|
||||
SubInclude TOP combined ;
|
||||
SubInclude TOP tools ;
|
222
src/Jamrules
Normal file
222
src/Jamrules
Normal file
|
@ -0,0 +1,222 @@
|
|||
C++ = g++ ;
|
||||
CC = gcc ;
|
||||
LINK = gcc ;
|
||||
|
||||
MSPACES = 1 ;
|
||||
|
||||
# BINDINGS = LUABIND ;
|
||||
if ! $(BINDINGS) {
|
||||
BINDINGS = TOLUA ;
|
||||
}
|
||||
|
||||
if $(BINDINGS) = LUABIND {
|
||||
CCFLAGS += -DBINDINGS_LUABIND ;
|
||||
C++FLAGS += -DBINDINGS_LUABIND ;
|
||||
}
|
||||
|
||||
if $(BINDINGS) = TOLUA {
|
||||
CCFLAGS += -DBINDINGS_TOLUA ;
|
||||
C++FLAGS += -DBINDINGS_TOLUA ;
|
||||
}
|
||||
|
||||
if ! $(LUA_VERSION) {
|
||||
LUA_VERSION = 5.1 ;
|
||||
}
|
||||
|
||||
if ! $(HAVE_LUA) {
|
||||
HAVE_LUA = 1 ;
|
||||
}
|
||||
|
||||
if ! $(CPU) {
|
||||
CPU = prescott ;
|
||||
ARCH = -march=$(CPU) -mmmx -mieee-fp ;
|
||||
ARCH += -mtune=$(CPU) ;
|
||||
}
|
||||
|
||||
if $(DISTCC_HOSTS) {
|
||||
DISTCC = 1 ;
|
||||
}
|
||||
|
||||
if $(DISTCC) {
|
||||
CC = distcc $(CC) ;
|
||||
C++ = distcc $(C++) ;
|
||||
Echo Compiling with distcc ;
|
||||
}
|
||||
|
||||
if ! $(CCACHE_DIR) {
|
||||
} else {
|
||||
CC = ccache $(CC) ;
|
||||
C++ = ccache $(C++) ;
|
||||
Echo Compiling with ccache ;
|
||||
}
|
||||
|
||||
if $(DMALLOC) {
|
||||
Echo Compiling with dmalloc ;
|
||||
CCFLAGS += -DUSE_DMALLOC ;
|
||||
C++FLAGS += -DUSE_DMALLOC ;
|
||||
LINKFLAGS += -ldmalloc ;
|
||||
}
|
||||
|
||||
if $(COVERAGE) = 1 {
|
||||
Echo Compiling with gcov info ;
|
||||
CCFLAGS += -fprofile-arcs -ftest-coverage ;
|
||||
C++FLAGS += -fprofile-arcs -ftest-coverage ;
|
||||
LINKFLAGS += -fprofile-arcs -ftest-coverage ;
|
||||
}
|
||||
|
||||
if $(PROFILE) = 1 {
|
||||
Echo Compiling with profiler ;
|
||||
CCFLAGS += -pg -ggdb ;
|
||||
LINKFLAGS += -pg -ggdb ;
|
||||
}
|
||||
|
||||
CCFLAGS += -Wall -Werror -Wno-unknown-pragmas -Wstrict-prototypes
|
||||
-Wpointer-arith -Wno-char-subscripts ;
|
||||
|
||||
CCFLAGS on foo += -Wwrite-strings
|
||||
-Wundef
|
||||
-Wstrict-prototypes
|
||||
-Werror-implicit-function-declaration
|
||||
-Wno-char-subscripts
|
||||
-Wpointer-arith
|
||||
# -Wshadow
|
||||
# -Wcast-qual
|
||||
-Wcast-align
|
||||
# -Wconversion
|
||||
# -Wunreachable-code
|
||||
-Werror
|
||||
;
|
||||
|
||||
# this require the latet luabind from CVS
|
||||
if ! $(LUABIND) {
|
||||
LUABIND = "B7" ;
|
||||
}
|
||||
|
||||
C++FLAGS += -DHAVE_LUABIND_$(LUABIND) ;
|
||||
if $(LOCAL_USR) {
|
||||
XMLHDRS = $(LOCAL_USR)/include/libxml2 ;
|
||||
C++FLAGS += -I$(LOCAL_USR)/include ;
|
||||
CFLAGS += -I$(LOCAL_USR)/include ;
|
||||
LINKLIBS += -L$(LOCAL_USR)/lib ;
|
||||
} else {
|
||||
XMLHDRS = /usr/include/libxml2 ;
|
||||
}
|
||||
C++FLAGS += -DHAVE_LUABIND_$(LUABIND) ;
|
||||
|
||||
rule iconv
|
||||
{
|
||||
if $(LINK_ICONV) {
|
||||
LINKLIBS on $(<) += -liconv ;
|
||||
}
|
||||
}
|
||||
|
||||
rule zlib
|
||||
{
|
||||
LINKLIBS on $(<) += -lz ;
|
||||
}
|
||||
|
||||
rule liblua
|
||||
{
|
||||
if $(LUA_VERSION) = 5.1 {
|
||||
LINKLIBS on $(<) += -llua5.1 ;
|
||||
} else {
|
||||
LINKLIBS on $(<) += -llua50 -llualib50 ;
|
||||
}
|
||||
}
|
||||
|
||||
rule libluabind
|
||||
{
|
||||
LINKLIBS on $(<) += -lm -lluabind ;
|
||||
}
|
||||
|
||||
rule libxml2
|
||||
{
|
||||
LINKLIBS on $(<) += -lxml2 ;
|
||||
}
|
||||
|
||||
rule libtolua
|
||||
{
|
||||
LINKLIBS on $(<) += -ltolua ;
|
||||
}
|
||||
|
||||
rule libcurses
|
||||
{
|
||||
LINKLIBS on $(<) += -lncurses ;
|
||||
}
|
||||
|
||||
rule libmcheck
|
||||
{
|
||||
if $(DEBUG) = 1 {
|
||||
LINKLIBS on $(<) += -lmcheck ;
|
||||
}
|
||||
}
|
||||
|
||||
rule UsingLuabind
|
||||
{
|
||||
SubDirHdrs $(LUABIND_ROOT)/include ;
|
||||
}
|
||||
|
||||
rule UsingLua
|
||||
{
|
||||
if $(LUA_VERSION) = 5.1 {
|
||||
SubDirHdrs /usr/include/lua5.1 ;
|
||||
} else {
|
||||
SubDirHdrs /usr/include/lua50 ;
|
||||
}
|
||||
}
|
||||
|
||||
rule TargetDirectory
|
||||
{
|
||||
# Now set up SEARCH_SOURCE, LOCATE_TARGET, SOURCE_GRIST
|
||||
# These can be reset if needed. For example, if the source
|
||||
# directory should not hold object files, LOCATE_TARGET can
|
||||
# subsequently be redefined.
|
||||
|
||||
local path = [ FDirName $(SUBDIR) $(TARGET_PREFIX) ] ;
|
||||
SEARCH_SOURCE = $(SUBDIR) ;
|
||||
LOCATE_SOURCE = $(ALL_LOCATE_TARGET) $(path) ;
|
||||
LOCATE_TARGET = $(ALL_LOCATE_TARGET) $(path) ;
|
||||
SOURCE_GRIST = $(path) ;
|
||||
if $(DEBUG) = 1 {
|
||||
SubDirCcFlags -ggdb ;
|
||||
SubDirC++Flags -ggdb ;
|
||||
OPTIM = -O0 -ffloat-store ;
|
||||
}
|
||||
else {
|
||||
SubDirCcFlags -DNDEBUG ;
|
||||
SubDirC++Flags -DNDEBUG ;
|
||||
OPTIM = -Os -ffloat-store ;
|
||||
}
|
||||
SubDirCcFlags $(ARCH) ;
|
||||
SubDirC++Flags $(ARCH) ;
|
||||
}
|
||||
|
||||
if ! $(DEBUG) {
|
||||
ECHO Assuming DEBUG=1 ;
|
||||
DEBUG = 1 ;
|
||||
}
|
||||
|
||||
if $(MSPACES) {
|
||||
CCFLAGS += -DMSPACES -DDL_DEBUG=0 ;
|
||||
C++FLAGS += -DMSPACES -DDL_DEBUG=0 ;
|
||||
}
|
||||
|
||||
if $(WITHOUT_LUA) {
|
||||
ECHO Compiling without LUA ;
|
||||
}
|
||||
|
||||
if $(DEBUG) = 0 {
|
||||
TARGET_PREFIX = Release ;
|
||||
}
|
||||
else {
|
||||
TARGET_PREFIX = Debug ;
|
||||
}
|
||||
if $(PROFILE) = 1 {
|
||||
TARGET_PREFIX = Profile ;
|
||||
}
|
||||
if $(COVERAGE) = 1 {
|
||||
TARGET_PREFIX = Coverage ;
|
||||
}
|
||||
|
||||
|
||||
|
2
src/build_vs2003.bat
Normal file
2
src/build_vs2003.bat
Normal file
|
@ -0,0 +1,2 @@
|
|||
REM rebuild eressea projects for VC7.1
|
||||
premake --file premake.lua --target vs2003
|
2
src/build_vs2005.bat
Normal file
2
src/build_vs2005.bat
Normal file
|
@ -0,0 +1,2 @@
|
|||
REM rebuild eressea projects for VC8
|
||||
premake --file premake.lua --target vs2005
|
62
src/combined/Jamfile
Normal file
62
src/combined/Jamfile
Normal file
|
@ -0,0 +1,62 @@
|
|||
SubDir TOP combined ;
|
||||
|
||||
TargetDirectory ;
|
||||
SubDirHdrs $(SUBDIR)/../eressea ;
|
||||
SubDirHdrs $(SUBDIR)/../common/gamecode ;
|
||||
SubDirHdrs $(SUBDIR)/../common/kernel ;
|
||||
SubDirHdrs $(SUBDIR)/../common/util ;
|
||||
SubDirHdrs $(SUBDIR)/../common ;
|
||||
SubDirHdrs $(SUBDIR)/../tools ;
|
||||
SubDirHdrs $(SUBDIR)/../external ;
|
||||
SubDirHdrs $(SUBDIR)/.. ;
|
||||
|
||||
UsingLua ;
|
||||
|
||||
SEARCH_SOURCE += [ FDirName $(TOP) common iniparser ] ;
|
||||
SEARCH_SOURCE += [ FDirName $(SUBDIR) curses ] ;
|
||||
if $(BINDINGS) = LUABIND {
|
||||
SEARCH_SOURCE += [ FDirName $(SUBDIR) lua ] ;
|
||||
}
|
||||
if $(BINDINGS) = TOLUA {
|
||||
SEARCH_SOURCE += [ FDirName $(SUBDIR) tolua ] ;
|
||||
}
|
||||
SubDirC++Flags -DHAVE_LUA ;
|
||||
|
||||
SubDirHdrs $(XMLHDRS) ;
|
||||
|
||||
SERVER = eressea ;
|
||||
|
||||
SERVER_SOURCES =
|
||||
curses.c
|
||||
gamecode.c
|
||||
kernel.c
|
||||
stdafx.c
|
||||
util.c
|
||||
main.c
|
||||
;
|
||||
|
||||
CCFLAGS += -DSQLITE_THREADSAFE=0 ;
|
||||
|
||||
if $(MSPACES) {
|
||||
SERVER_SOURCES += malloc.c ;
|
||||
}
|
||||
|
||||
|
||||
if $(BINDINGS) = LUABIND {
|
||||
SERVER_SOURCES += bindings.cpp ;
|
||||
libluabind $(SERVER) ;
|
||||
}
|
||||
if $(BINDINGS) = TOLUA {
|
||||
libtolua $(SERVER) ;
|
||||
}
|
||||
liblua $(SERVER) ;
|
||||
|
||||
# eressea-server with lua scripting
|
||||
libxml2 $(SERVER) ;
|
||||
libcurses $(SERVER) ;
|
||||
libmcheck $(SERVER) ;
|
||||
|
||||
LINKLIBS on $(SERVER) += -lm -ldl -lstdc++ ;
|
||||
Main $(SERVER) : $(SERVER_SOURCES) ;
|
||||
|
||||
Main atoi36 : atoi36.c ;
|
6
src/combined/atoi36.c
Normal file
6
src/combined/atoi36.c
Normal file
|
@ -0,0 +1,6 @@
|
|||
#include "common/settings.h"
|
||||
#include "common/config.h"
|
||||
#include "stdafx.h"
|
||||
|
||||
#include "common/util/base36.c"
|
||||
#include "tools/atoi36.c"
|
24
src/combined/bindings.cpp
Normal file
24
src/combined/bindings.cpp
Normal file
|
@ -0,0 +1,24 @@
|
|||
#include "common/settings.h"
|
||||
#include "common/config.h"
|
||||
#include "stdafx.hpp"
|
||||
|
||||
#include "eressea/server.cpp"
|
||||
|
||||
#ifdef BINDINGS_LUABIND
|
||||
#include "eressea/lua/alliance.cpp"
|
||||
#include "eressea/lua/building.cpp"
|
||||
#include "eressea/lua/eressea.cpp"
|
||||
#include "eressea/lua/event.cpp"
|
||||
#include "eressea/lua/faction.cpp"
|
||||
#include "eressea/lua/gamecode.cpp"
|
||||
#include "eressea/lua/gm.cpp"
|
||||
#include "eressea/lua/item.cpp"
|
||||
#include "eressea/lua/message.cpp"
|
||||
#include "eressea/lua/objects.cpp"
|
||||
#include "eressea/lua/region.cpp"
|
||||
#include "eressea/lua/script.cpp"
|
||||
#include "eressea/lua/ship.cpp"
|
||||
#include "eressea/lua/spell.cpp"
|
||||
#include "eressea/lua/test.cpp"
|
||||
#include "eressea/lua/unit.cpp"
|
||||
#endif
|
6
src/combined/curses.c
Normal file
6
src/combined/curses.c
Normal file
|
@ -0,0 +1,6 @@
|
|||
#include "common/settings.h"
|
||||
#include "common/config.h"
|
||||
#include "stdafx.h"
|
||||
|
||||
#include "eressea/curses/listbox.c"
|
||||
#include "eressea/gmtool.c"
|
100
src/combined/gamecode.c
Normal file
100
src/combined/gamecode.c
Normal file
|
@ -0,0 +1,100 @@
|
|||
#include "common/settings.h"
|
||||
#include "common/config.h"
|
||||
#include "stdafx.h"
|
||||
|
||||
#ifdef BINDINGS_TOLUA
|
||||
#include "eressea/tolua/bindings.c"
|
||||
#include "eressea/tolua/bind_attrib.c"
|
||||
#include "eressea/tolua/bind_sqlite.c"
|
||||
#include "eressea/tolua/bind_unit.c"
|
||||
#include "eressea/tolua/bind_ship.c"
|
||||
#include "eressea/tolua/bind_building.c"
|
||||
#include "eressea/tolua/bind_region.c"
|
||||
#include "eressea/tolua/bind_faction.c"
|
||||
#include "eressea/tolua/bind_message.c"
|
||||
#include "eressea/tolua/bind_hashtable.c"
|
||||
#include "eressea/tolua/bind_gmtool.c"
|
||||
#include "eressea/tolua/bind_storage.c"
|
||||
#include "eressea/tolua/helpers.c"
|
||||
#endif
|
||||
|
||||
#include "eressea/console.c"
|
||||
#include "eressea/editing.c"
|
||||
|
||||
#include "common/gamecode/archetype.c"
|
||||
#include "common/gamecode/creation.c"
|
||||
#include "common/gamecode/creport.c"
|
||||
#include "common/gamecode/economy.c"
|
||||
#include "common/gamecode/give.c"
|
||||
#include "common/gamecode/items.c"
|
||||
#include "common/gamecode/laws.c"
|
||||
#include "common/gamecode/luck.c"
|
||||
#include "common/gamecode/market.c"
|
||||
#include "common/gamecode/monster.c"
|
||||
#include "common/gamecode/randenc.c"
|
||||
#include "common/gamecode/report.c"
|
||||
#include "common/gamecode/spells.c"
|
||||
#include "common/gamecode/spy.c"
|
||||
#include "common/gamecode/study.c"
|
||||
#include "common/gamecode/summary.c"
|
||||
#include "common/gamecode/xmlreport.c"
|
||||
|
||||
#include "common/races/dragons.c"
|
||||
#include "common/races/illusion.c"
|
||||
#include "common/races/races.c"
|
||||
#include "common/races/zombies.c"
|
||||
|
||||
#include "common/attributes/alliance.c"
|
||||
#include "common/attributes/attributes.c"
|
||||
#include "common/attributes/fleechance.c"
|
||||
#include "common/attributes/follow.c"
|
||||
#include "common/attributes/giveitem.c"
|
||||
#include "common/attributes/gm.c"
|
||||
#include "common/attributes/hate.c"
|
||||
#include "common/attributes/iceberg.c"
|
||||
#include "common/attributes/key.c"
|
||||
#include "common/attributes/matmod.c"
|
||||
#include "common/attributes/movement.c"
|
||||
#include "common/attributes/moved.c"
|
||||
#include "common/attributes/object.c"
|
||||
#include "common/attributes/option.c"
|
||||
#include "common/attributes/orcification.c"
|
||||
#include "common/attributes/otherfaction.c"
|
||||
#include "common/attributes/overrideroads.c"
|
||||
#include "common/attributes/racename.c"
|
||||
#include "common/attributes/raceprefix.c"
|
||||
#include "common/attributes/reduceproduction.c"
|
||||
#include "common/attributes/targetregion.c"
|
||||
#include "common/attributes/viewrange.c"
|
||||
#include "common/attributes/variable.c"
|
||||
|
||||
#include "common/items/artrewards.c"
|
||||
#include "common/items/demonseye.c"
|
||||
#include "common/items/itemtypes.c"
|
||||
#include "common/items/phoenixcompass.c"
|
||||
#include "common/items/seed.c"
|
||||
#include "common/items/weapons.c"
|
||||
#include "common/items/xerewards.c"
|
||||
|
||||
#include "common/spells/alp.c"
|
||||
#include "common/spells/buildingcurse.c"
|
||||
#include "common/spells/combatspells.c"
|
||||
#include "common/spells/regioncurse.c"
|
||||
#include "common/spells/shipcurse.c"
|
||||
#include "common/spells/spells.c"
|
||||
#include "common/spells/unitcurse.c"
|
||||
|
||||
#include "common/triggers/changefaction.c"
|
||||
#include "common/triggers/changerace.c"
|
||||
#include "common/triggers/clonedied.c"
|
||||
#include "common/triggers/createcurse.c"
|
||||
#include "common/triggers/createunit.c"
|
||||
#include "common/triggers/gate.c"
|
||||
#include "common/triggers/giveitem.c"
|
||||
#include "common/triggers/killunit.c"
|
||||
#include "common/triggers/removecurse.c"
|
||||
#include "common/triggers/shock.c"
|
||||
#include "common/triggers/timeout.c"
|
||||
#include "common/triggers/triggers.c"
|
||||
#include "common/triggers/unguard.c"
|
||||
#include "common/triggers/unitmessage.c"
|
55
src/combined/kernel.c
Normal file
55
src/combined/kernel.c
Normal file
|
@ -0,0 +1,55 @@
|
|||
#include "common/settings.h"
|
||||
#include "common/config.h"
|
||||
#include "stdafx.h"
|
||||
|
||||
#include "common/kernel/alchemy.c"
|
||||
#include "common/kernel/alliance.c"
|
||||
#include "common/kernel/battle.c"
|
||||
#include "common/kernel/binarystore.c"
|
||||
#include "common/kernel/connection.c"
|
||||
#include "common/kernel/build.c"
|
||||
#include "common/kernel/building.c"
|
||||
#include "common/kernel/calendar.c"
|
||||
#include "common/kernel/command.c"
|
||||
#include "common/kernel/curse.c"
|
||||
#include "common/kernel/equipment.c"
|
||||
#include "common/kernel/eressea.c"
|
||||
#include "common/kernel/faction.c"
|
||||
#include "common/kernel/group.c"
|
||||
#include "common/kernel/item.c"
|
||||
#include "common/kernel/karma.c"
|
||||
#include "common/kernel/magic.c"
|
||||
#include "common/kernel/message.c"
|
||||
#include "common/kernel/move.c"
|
||||
#include "common/kernel/names.c"
|
||||
#include "common/kernel/order.c"
|
||||
#include "common/kernel/pathfinder.c"
|
||||
#include "common/kernel/plane.c"
|
||||
#include "common/kernel/player.c"
|
||||
#include "common/kernel/pool.c"
|
||||
#include "common/kernel/race.c"
|
||||
#include "common/kernel/region.c"
|
||||
#include "common/kernel/reports.c"
|
||||
#include "common/kernel/resources.c"
|
||||
#include "common/kernel/save.c"
|
||||
#include "common/kernel/ship.c"
|
||||
#include "common/kernel/skill.c"
|
||||
#include "common/kernel/spell.c"
|
||||
#include "common/kernel/teleport.c"
|
||||
#include "common/kernel/terrain.c"
|
||||
#include "common/kernel/textstore.c"
|
||||
#include "common/kernel/unit.c"
|
||||
#include "common/kernel/xmlreader.c"
|
||||
#include "common/kernel/sqlite.c"
|
||||
|
||||
#include "common/modules/arena.c"
|
||||
#include "common/modules/autoseed.c"
|
||||
#include "common/modules/dungeon.c"
|
||||
#include "common/modules/gmcmd.c"
|
||||
#include "common/modules/infocmd.c"
|
||||
#include "common/modules/museum.c"
|
||||
#include "common/modules/score.c"
|
||||
#include "common/modules/weather.c"
|
||||
#include "common/modules/wormhole.c"
|
||||
#include "common/modules/xecmd.c"
|
||||
#include "common/modules/xmas.c"
|
9
src/combined/main.c
Normal file
9
src/combined/main.c
Normal file
|
@ -0,0 +1,9 @@
|
|||
#include "common/settings.h"
|
||||
#include "common/config.h"
|
||||
#include "stdafx.h"
|
||||
|
||||
#include <eressea/server.c>
|
||||
#include <external/sqlite3.c>
|
||||
#include <external/md5.c>
|
||||
#include <external/bson/bson.c>
|
||||
#include <external/bson/numbers.c>
|
1
src/combined/malloc.c
Normal file
1
src/combined/malloc.c
Normal file
|
@ -0,0 +1 @@
|
|||
#include "util/dl/malloc.c"
|
1
src/combined/stdafx.c
Normal file
1
src/combined/stdafx.c
Normal file
|
@ -0,0 +1 @@
|
|||
#include "stdafx.h"
|
1
src/combined/stdafx.cpp
Normal file
1
src/combined/stdafx.cpp
Normal file
|
@ -0,0 +1 @@
|
|||
#include "stdafx.hpp"
|
2
src/combined/stdafx.h
Normal file
2
src/combined/stdafx.h
Normal file
|
@ -0,0 +1,2 @@
|
|||
#include "common/settings.h"
|
||||
#include "common/config.h"
|
2
src/combined/stdafx.hpp
Normal file
2
src/combined/stdafx.hpp
Normal file
|
@ -0,0 +1,2 @@
|
|||
#include "common/settings.h"
|
||||
#include "common/config.h"
|
36
src/combined/util.c
Normal file
36
src/combined/util.c
Normal file
|
@ -0,0 +1,36 @@
|
|||
#include "common/settings.h"
|
||||
#include "common/config.h"
|
||||
#include "stdafx.h"
|
||||
|
||||
#include "common/iniparser/iniparser.c"
|
||||
#include "common/util/attrib.c"
|
||||
#include "common/util/base36.c"
|
||||
#include "common/util/crmessage.c"
|
||||
#include "common/util/cvector.c"
|
||||
#include "common/util/dice.c"
|
||||
#include "common/util/event.c"
|
||||
#include "common/util/filereader.c"
|
||||
#include "common/util/functions.c"
|
||||
#include "common/util/goodies.c"
|
||||
#include "common/util/language.c"
|
||||
#include "common/util/lists.c"
|
||||
#include "common/util/log.c"
|
||||
#include "common/util/message.c"
|
||||
#include "common/util/mt19937ar.c"
|
||||
#include "common/util/nrmessage.c"
|
||||
#include "common/util/parser.c"
|
||||
#include "common/util/rand.c"
|
||||
#include "common/util/resolve.c"
|
||||
#include "common/util/sql.c"
|
||||
#include "common/util/translation.c"
|
||||
#include "common/util/umlaut.c"
|
||||
#include "common/util/unicode.c"
|
||||
#include "common/util/xml.c"
|
||||
|
||||
#ifndef HAVE_INLINE
|
||||
#include "common/util/bsdstring.c"
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
#include "common/util/strncpy.c"
|
||||
#endif
|
11
src/common/Jamfile
Normal file
11
src/common/Jamfile
Normal file
|
@ -0,0 +1,11 @@
|
|||
SubDir TOP common ;
|
||||
|
||||
SubInclude TOP common kernel ;
|
||||
SubInclude TOP common gamecode ;
|
||||
SubInclude TOP common spells ;
|
||||
SubInclude TOP common races ;
|
||||
SubInclude TOP common triggers ;
|
||||
SubInclude TOP common util ;
|
||||
SubInclude TOP common attributes ;
|
||||
SubInclude TOP common modules ;
|
||||
SubInclude TOP common items ;
|
36
src/common/attributes/Jamfile
Normal file
36
src/common/attributes/Jamfile
Normal file
|
@ -0,0 +1,36 @@
|
|||
SubDir TOP common attributes ;
|
||||
|
||||
TargetDirectory ;
|
||||
SubDirHdrs $(SUBDIR)/../gamecode ;
|
||||
SubDirHdrs $(SUBDIR)/../kernel ;
|
||||
SubDirHdrs $(SUBDIR)/../util ;
|
||||
SubDirHdrs $(SUBDIR)/.. ;
|
||||
SubDirHdrs $(SUBDIR)/../.. ;
|
||||
|
||||
SOURCES =
|
||||
alliance.c
|
||||
attributes.c
|
||||
fleechance.c
|
||||
follow.c
|
||||
giveitem.c
|
||||
gm.c
|
||||
hate.c
|
||||
iceberg.c
|
||||
key.c
|
||||
matmod.c
|
||||
movement.c
|
||||
moved.c
|
||||
object.c
|
||||
option.c
|
||||
orcification.c
|
||||
otherfaction.c
|
||||
overrideroads.c
|
||||
racename.c
|
||||
raceprefix.c
|
||||
reduceproduction.c
|
||||
targetregion.c
|
||||
viewrange.c
|
||||
variable.c
|
||||
;
|
||||
|
||||
Library attributes : $(SOURCES) ;
|
29
src/common/attributes/aggressive.h
Normal file
29
src/common/attributes/aggressive.h
Normal file
|
@ -0,0 +1,29 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
*
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2003
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
* Henning Peters (faroul@beyond.kn-bremen.de)
|
||||
* Enno Rehling (enno@eressea.de)
|
||||
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
|
||||
*
|
||||
* This program may not be used, modified or distributed without
|
||||
* prior permission by the authors of Eressea.
|
||||
*/
|
||||
|
||||
#ifndef H_ATTRIBUTE_AGGRESSIVE
|
||||
#define H_ATTRIBUTE_AGGRESSIVE
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern struct attrib_type at_aggressive;
|
||||
extern struct attrib * make_aggressive(double probability);
|
||||
extern void init_aggressive(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
33
src/common/attributes/alliance.c
Normal file
33
src/common/attributes/alliance.c
Normal file
|
@ -0,0 +1,33 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2005
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
* Enno Rehling (enno@eressea.de)
|
||||
*
|
||||
* This program may not be used, modified or distributed without
|
||||
* prior permission by the authors of Eressea.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <kernel/types.h>
|
||||
#include "alliance.h"
|
||||
|
||||
#include <kernel/save.h>
|
||||
#include <util/attrib.h>
|
||||
|
||||
attrib_type at_alliance = {
|
||||
"alliance",
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
a_writeint,
|
||||
a_readint,
|
||||
ATF_UNIQUE
|
||||
};
|
||||
|
||||
void
|
||||
init_alliance(void)
|
||||
{
|
||||
at_register(&at_alliance);
|
||||
}
|
26
src/common/attributes/alliance.h
Normal file
26
src/common/attributes/alliance.h
Normal file
|
@ -0,0 +1,26 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
*
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2005
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
* Enno Rehling (enno@eressea.de)
|
||||
*
|
||||
* This program may not be used, modified or distributed without
|
||||
* prior permission by the authors of Eressea.
|
||||
*/
|
||||
|
||||
#ifndef H_ATTRIBUTE_ALLIANCE
|
||||
#define H_ATTRIBUTE_ALLIANCE
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern struct attrib_type at_alliance;
|
||||
extern void init_alliance(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
84
src/common/attributes/attributes.c
Normal file
84
src/common/attributes/attributes.c
Normal file
|
@ -0,0 +1,84 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
*
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2003
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
* Henning Peters (faroul@beyond.kn-bremen.de)
|
||||
* Enno Rehling (enno@eressea.de)
|
||||
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
|
||||
*
|
||||
* This program may not be used, modified or distributed without
|
||||
* prior permission by the authors of Eressea.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <kernel/eressea.h>
|
||||
#include "attributes.h"
|
||||
|
||||
/* attributes includes */
|
||||
#include "follow.h"
|
||||
#include "gm.h"
|
||||
#include "hate.h"
|
||||
#include "iceberg.h"
|
||||
#include "key.h"
|
||||
#include "moved.h"
|
||||
#include "movement.h"
|
||||
#include "object.h"
|
||||
#include "orcification.h"
|
||||
#include "otherfaction.h"
|
||||
#include "overrideroads.h"
|
||||
#include "racename.h"
|
||||
#include "raceprefix.h"
|
||||
#include "reduceproduction.h"
|
||||
#include "targetregion.h"
|
||||
#include "variable.h"
|
||||
#ifdef AT_OPTION
|
||||
# include "option.h"
|
||||
#endif
|
||||
#ifdef WDW_PYRAMID
|
||||
# include "alliance.h"
|
||||
#endif
|
||||
|
||||
/* kernel includes */
|
||||
#include <kernel/unit.h>
|
||||
#include <kernel/faction.h>
|
||||
#include <kernel/region.h>
|
||||
#include <kernel/ship.h>
|
||||
#include <kernel/building.h>
|
||||
|
||||
/* util includes */
|
||||
#include <util/attrib.h>
|
||||
|
||||
/*
|
||||
* library initialization
|
||||
*/
|
||||
|
||||
void
|
||||
init_attributes(void)
|
||||
{
|
||||
at_register(&at_object);
|
||||
at_register(&at_overrideroads);
|
||||
at_register(&at_raceprefix);
|
||||
|
||||
init_iceberg();
|
||||
init_key();
|
||||
init_gm();
|
||||
init_follow(); /* only for old datafiles */
|
||||
init_targetregion();
|
||||
init_orcification();
|
||||
init_hate();
|
||||
init_reduceproduction();
|
||||
init_otherfaction();
|
||||
init_racename();
|
||||
init_movement();
|
||||
|
||||
init_moved();
|
||||
#ifdef AT_OPTION
|
||||
init_option();
|
||||
#endif
|
||||
init_variable();
|
||||
#ifdef WDW_PYRAMID
|
||||
init_alliance();
|
||||
#endif
|
||||
}
|
25
src/common/attributes/attributes.h
Normal file
25
src/common/attributes/attributes.h
Normal file
|
@ -0,0 +1,25 @@
|
|||
/* vi: set ts=2:
|
||||
+-------------------+ Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
| | Enno Rehling <enno@eressea.de>
|
||||
| Eressea PBEM host | Katja Zedel <katze@felidae.kn-bremen.de>
|
||||
| (c) 1998 - 2003 | Henning Peters <faroul@beyond.kn-bremen.de>
|
||||
| | Ingo Wilken <Ingo.Wilken@informatik.uni-oldenburg.de>
|
||||
+-------------------+ Stefan Reich <reich@halbling.de>
|
||||
|
||||
This program may not be used, modified or distributed
|
||||
without prior permission by the authors of Eressea.
|
||||
*/
|
||||
|
||||
#ifndef H_ATTRIBUTE_ATTRIBUTES
|
||||
#define H_ATTRIBUTE_ATTRIBUTES
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern void init_attributes(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
41
src/common/attributes/fleechance.c
Normal file
41
src/common/attributes/fleechance.c
Normal file
|
@ -0,0 +1,41 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
*
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2003
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
* Henning Peters (faroul@beyond.kn-bremen.de)
|
||||
* Enno Rehling (enno@eressea.de)
|
||||
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
|
||||
*
|
||||
* This program may not be used, modified or distributed without
|
||||
* prior permission by the authors of Eressea.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include "fleechance.h"
|
||||
|
||||
#include <util/attrib.h>
|
||||
|
||||
attrib_type at_fleechance = {
|
||||
"fleechance",
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
};
|
||||
|
||||
attrib *
|
||||
make_fleechance(float fleechance)
|
||||
{
|
||||
attrib * a = a_new(&at_fleechance);
|
||||
a->data.flt = fleechance;
|
||||
return a;
|
||||
}
|
||||
|
||||
void
|
||||
init_fleechance(void)
|
||||
{
|
||||
at_register(&at_fleechance);
|
||||
}
|
29
src/common/attributes/fleechance.h
Normal file
29
src/common/attributes/fleechance.h
Normal file
|
@ -0,0 +1,29 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
*
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2003
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
* Henning Peters (faroul@beyond.kn-bremen.de)
|
||||
* Enno Rehling (enno@eressea.de)
|
||||
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
|
||||
*
|
||||
* This program may not be used, modified or distributed without
|
||||
* prior permission by the authors of Eressea.
|
||||
*/
|
||||
|
||||
#ifndef H_ATTRIBUTE_FLEECHANCE
|
||||
#define H_ATTRIBUTE_FLEECHANCE
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern struct attrib_type at_fleechance;
|
||||
|
||||
extern struct attrib * make_fleechance(float fleechance);
|
||||
extern void init_fleechance(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
48
src/common/attributes/follow.c
Normal file
48
src/common/attributes/follow.c
Normal file
|
@ -0,0 +1,48 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
*
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2003
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
* Henning Peters (faroul@beyond.kn-bremen.de)
|
||||
* Enno Rehling (enno@eressea.de)
|
||||
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
|
||||
*
|
||||
* This program may not be used, modified or distributed without
|
||||
* prior permission by the authors of Eressea.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include "follow.h"
|
||||
|
||||
#include <kernel/eressea.h>
|
||||
#include <kernel/unit.h>
|
||||
|
||||
#include <util/attrib.h>
|
||||
#include <util/storage.h>
|
||||
#include <util/variant.h>
|
||||
|
||||
static int
|
||||
read_follow(attrib * a, struct storage * store)
|
||||
{
|
||||
read_unit_reference(store); /* skip it */
|
||||
return AT_READ_FAIL;
|
||||
}
|
||||
|
||||
attrib_type at_follow = {
|
||||
"follow", NULL, NULL, NULL, NULL, read_follow
|
||||
};
|
||||
|
||||
attrib *
|
||||
make_follow(struct unit * u)
|
||||
{
|
||||
attrib * a = a_new(&at_follow);
|
||||
a->data.v = u;
|
||||
return a;
|
||||
}
|
||||
|
||||
void
|
||||
init_follow(void)
|
||||
{
|
||||
at_register(&at_follow);
|
||||
}
|
32
src/common/attributes/follow.h
Normal file
32
src/common/attributes/follow.h
Normal file
|
@ -0,0 +1,32 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
*
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2003
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
* Henning Peters (faroul@beyond.kn-bremen.de)
|
||||
* Enno Rehling (enno@eressea.de)
|
||||
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
|
||||
*
|
||||
* This program may not be used, modified or distributed without
|
||||
* prior permission by the authors of Eressea.
|
||||
*/
|
||||
|
||||
#ifndef H_ATTRIBUTE_FOLLOW
|
||||
#define H_ATTRIBUTE_FOLLOW
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern struct attrib_type at_follow;
|
||||
|
||||
struct unit;
|
||||
|
||||
extern struct attrib * make_follow(struct unit * u);
|
||||
extern void init_follow(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
131
src/common/attributes/giveitem.c
Normal file
131
src/common/attributes/giveitem.c
Normal file
|
@ -0,0 +1,131 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
*
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2003
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
* Henning Peters (faroul@beyond.kn-bremen.de)
|
||||
* Enno Rehling (enno@eressea.de)
|
||||
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
|
||||
*
|
||||
* This program may not be used, modified or distributed without
|
||||
* prior permission by the authors of Eressea.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include "giveitem.h"
|
||||
#include <kernel/eressea.h>
|
||||
|
||||
/* kernel includes */
|
||||
#include <kernel/building.h>
|
||||
#include <kernel/region.h>
|
||||
#include <kernel/unit.h>
|
||||
#include <kernel/item.h>
|
||||
|
||||
/* util includes */
|
||||
#include <util/attrib.h>
|
||||
#include <util/base36.h>
|
||||
#include <util/resolve.h>
|
||||
#include <util/storage.h>
|
||||
#include <util/goodies.h>
|
||||
|
||||
/* libc includes */
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
typedef struct give_data {
|
||||
struct building * building;
|
||||
struct item * items;
|
||||
} give_data;
|
||||
|
||||
static void
|
||||
a_writegive(const attrib * a, struct storage * store)
|
||||
{
|
||||
give_data * gdata = (give_data*)a->data.v;
|
||||
item * itm;
|
||||
write_building_reference(gdata->building, store);
|
||||
for (itm=gdata->items;itm;itm=itm->next) {
|
||||
store->w_tok(store, resourcename(itm->type->rtype, 0));
|
||||
store->w_int(store, itm->number);
|
||||
}
|
||||
store->w_tok(store, "end");
|
||||
}
|
||||
|
||||
static int
|
||||
a_readgive(attrib * a, struct storage * store)
|
||||
{
|
||||
give_data * gdata = (give_data*)a->data.v;
|
||||
variant var;
|
||||
char zText[32];
|
||||
|
||||
var.i = store->r_id(store);
|
||||
if (var.i>0) {
|
||||
gdata->building = findbuilding(var.i);
|
||||
if (gdata->building==NULL) {
|
||||
ur_add(var, &gdata->building, resolve_building);
|
||||
}
|
||||
} else {
|
||||
gdata->building=NULL;
|
||||
}
|
||||
for (;;) {
|
||||
int i;
|
||||
store->r_tok_buf(store, zText, sizeof(zText));
|
||||
if (!strcmp("end", zText)) break;
|
||||
i = store->r_int(store);
|
||||
if (i==0) i_add(&gdata->items, i_new(it_find(zText), i));
|
||||
}
|
||||
return AT_READ_OK;
|
||||
}
|
||||
|
||||
static void
|
||||
a_initgive(struct attrib * a)
|
||||
{
|
||||
a->data.v = calloc(sizeof(give_data), 1);
|
||||
}
|
||||
|
||||
static void
|
||||
a_finalizegive(struct attrib * a)
|
||||
{
|
||||
free(a->data.v);
|
||||
}
|
||||
|
||||
static int
|
||||
a_giveitem(attrib * a)
|
||||
{
|
||||
give_data * gdata = (give_data*)a->data.v;
|
||||
region * r;
|
||||
unit * u;
|
||||
if (gdata->building==NULL || gdata->items==NULL) return 0;
|
||||
r = gdata->building->region;
|
||||
u = building_owner(gdata->building);
|
||||
if (u==NULL) return 1;
|
||||
while (gdata->items) {
|
||||
item * itm = gdata->items;
|
||||
i_change(&u->items, itm->type, itm->number);
|
||||
i_free(i_remove(&gdata->items, itm));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
attrib_type at_giveitem = {
|
||||
"giveitem",
|
||||
a_initgive, a_finalizegive,
|
||||
a_giveitem,
|
||||
a_writegive, a_readgive
|
||||
};
|
||||
|
||||
attrib *
|
||||
make_giveitem(struct building * b, struct item * ip)
|
||||
{
|
||||
attrib * a = a_new(&at_giveitem);
|
||||
give_data * gd = (give_data*)a->data.v;
|
||||
gd->building = b;
|
||||
gd->items = ip;
|
||||
return a;
|
||||
}
|
||||
|
||||
void
|
||||
init_giveitem(void)
|
||||
{
|
||||
at_register(&at_giveitem);
|
||||
}
|
31
src/common/attributes/giveitem.h
Normal file
31
src/common/attributes/giveitem.h
Normal file
|
@ -0,0 +1,31 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
*
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2003
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
* Henning Peters (faroul@beyond.kn-bremen.de)
|
||||
* Enno Rehling (enno@eressea.de)
|
||||
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
|
||||
*
|
||||
* This program may not be used, modified or distributed without
|
||||
* prior permission by the authors of Eressea.
|
||||
*/
|
||||
#ifndef H_ATTRIBUTE_GIVEITEM
|
||||
#define H_ATTRIBUTE_GIVEITEM
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct building;
|
||||
struct item;
|
||||
|
||||
extern struct attrib_type at_giveitem;
|
||||
|
||||
extern struct attrib * make_giveitem(struct building * b, struct item * items);
|
||||
extern void init_giveitem(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
63
src/common/attributes/gm.c
Normal file
63
src/common/attributes/gm.c
Normal file
|
@ -0,0 +1,63 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
*
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2003
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
* Henning Peters (faroul@beyond.kn-bremen.de)
|
||||
* Enno Rehling (enno@eressea.de)
|
||||
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
|
||||
*
|
||||
* This program may not be used, modified or distributed without
|
||||
* prior permission by the authors of Eressea.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <kernel/eressea.h>
|
||||
#include "gm.h"
|
||||
|
||||
/* kernel includes */
|
||||
#include <kernel/plane.h>
|
||||
|
||||
/* util includes */
|
||||
#include <util/attrib.h>
|
||||
#include <util/storage.h>
|
||||
|
||||
static void
|
||||
write_gm(const attrib * a, struct storage * store)
|
||||
{
|
||||
write_plane_reference((plane*)a->data.v, store);
|
||||
}
|
||||
|
||||
static int
|
||||
read_gm(attrib * a, struct storage * store)
|
||||
{
|
||||
plane * pl;
|
||||
int result = read_plane_reference(&pl, store);
|
||||
a->data.v = pl;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
attrib_type at_gm = {
|
||||
"gm",
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
write_gm,
|
||||
read_gm,
|
||||
};
|
||||
|
||||
attrib *
|
||||
make_gm(const struct plane * pl)
|
||||
{
|
||||
attrib * a = a_new(&at_gm);
|
||||
a->data.v = (void*)pl;
|
||||
return a;
|
||||
}
|
||||
|
||||
void
|
||||
init_gm(void)
|
||||
{
|
||||
at_register(&at_gm);
|
||||
}
|
33
src/common/attributes/gm.h
Normal file
33
src/common/attributes/gm.h
Normal file
|
@ -0,0 +1,33 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
*
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2003
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
* Henning Peters (faroul@beyond.kn-bremen.de)
|
||||
* Enno Rehling (enno@eressea.de)
|
||||
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
|
||||
*
|
||||
* This program may not be used, modified or distributed without
|
||||
* prior permission by the authors of Eressea.
|
||||
*/
|
||||
|
||||
#ifndef H_ATTRIBUTE_GM
|
||||
#define H_ATTRIBUTE_GM
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* this is an attribute used by the kernel (isallied) */
|
||||
|
||||
struct plane;
|
||||
extern struct attrib_type at_gm;
|
||||
|
||||
extern struct attrib * make_gm(const struct plane *pl);
|
||||
extern void init_gm(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
72
src/common/attributes/hate.c
Normal file
72
src/common/attributes/hate.c
Normal file
|
@ -0,0 +1,72 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
*
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2003
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
* Henning Peters (faroul@beyond.kn-bremen.de)
|
||||
* Enno Rehling (enno@eressea.de)
|
||||
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
|
||||
*
|
||||
* This program may not be used, modified or distributed without
|
||||
* prior permission by the authors of Eressea.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <kernel/eressea.h>
|
||||
#include "hate.h"
|
||||
|
||||
#include <kernel/unit.h>
|
||||
#include <kernel/version.h>
|
||||
|
||||
#include <util/attrib.h>
|
||||
#include <util/resolve.h>
|
||||
#include <util/storage.h>
|
||||
|
||||
static int
|
||||
verify_hate(attrib * a)
|
||||
{
|
||||
if (a->data.v==NULL) {
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
write_hate(const attrib * a, struct storage * store)
|
||||
{
|
||||
write_unit_reference((unit*)a->data.v, store);
|
||||
}
|
||||
|
||||
static int
|
||||
read_hate(attrib * a, struct storage * store)
|
||||
{
|
||||
int result = read_reference(&a->data.v, store, read_unit_reference, resolve_unit);
|
||||
if (result==0 && !a->data.v) {
|
||||
return AT_READ_FAIL;
|
||||
}
|
||||
return AT_READ_OK;
|
||||
}
|
||||
|
||||
attrib_type at_hate = {
|
||||
"hates",
|
||||
NULL,
|
||||
NULL,
|
||||
verify_hate,
|
||||
write_hate,
|
||||
read_hate,
|
||||
};
|
||||
|
||||
attrib *
|
||||
make_hate(struct unit * u)
|
||||
{
|
||||
attrib * a = a_new(&at_hate);
|
||||
a->data.v = u;
|
||||
return a;
|
||||
}
|
||||
|
||||
void
|
||||
init_hate(void)
|
||||
{
|
||||
at_register(&at_hate);
|
||||
}
|
32
src/common/attributes/hate.h
Normal file
32
src/common/attributes/hate.h
Normal file
|
@ -0,0 +1,32 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
*
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2003
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
* Henning Peters (faroul@beyond.kn-bremen.de)
|
||||
* Enno Rehling (enno@eressea.de)
|
||||
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
|
||||
*
|
||||
* This program may not be used, modified or distributed without
|
||||
* prior permission by the authors of Eressea.
|
||||
*/
|
||||
|
||||
#ifndef H_ATTRIBUTE_HATE
|
||||
#define H_ATTRIBUTE_HATE
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern struct attrib_type at_hate;
|
||||
|
||||
struct unit;
|
||||
|
||||
extern struct attrib * make_hate(struct unit * u);
|
||||
extern void init_hate(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
44
src/common/attributes/iceberg.c
Normal file
44
src/common/attributes/iceberg.c
Normal file
|
@ -0,0 +1,44 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
*
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2003
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
* Henning Peters (faroul@beyond.kn-bremen.de)
|
||||
* Enno Rehling (enno@eressea.de)
|
||||
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
|
||||
*
|
||||
* This program may not be used, modified or distributed without
|
||||
* prior permission by the authors of Eressea.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <kernel/eressea.h>
|
||||
#include "iceberg.h"
|
||||
|
||||
#include <kernel/save.h>
|
||||
#include <util/attrib.h>
|
||||
|
||||
attrib_type at_iceberg = {
|
||||
"iceberg_drift",
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
a_writeint,
|
||||
a_readint,
|
||||
ATF_UNIQUE
|
||||
};
|
||||
|
||||
attrib *
|
||||
make_iceberg(direction_t dir)
|
||||
{
|
||||
attrib * a = a_new(&at_iceberg);
|
||||
a->data.i = (int)dir;
|
||||
return a;
|
||||
}
|
||||
|
||||
void
|
||||
init_iceberg(void)
|
||||
{
|
||||
at_register(&at_iceberg);
|
||||
}
|
30
src/common/attributes/iceberg.h
Normal file
30
src/common/attributes/iceberg.h
Normal file
|
@ -0,0 +1,30 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
*
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2003
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
* Henning Peters (faroul@beyond.kn-bremen.de)
|
||||
* Enno Rehling (enno@eressea.de)
|
||||
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
|
||||
*
|
||||
* This program may not be used, modified or distributed without
|
||||
* prior permission by the authors of Eressea.
|
||||
*/
|
||||
|
||||
#ifndef H_ATTRIBUTE_ICEBERG
|
||||
#define H_ATTRIBUTE_ICEBERG
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern struct attrib_type at_iceberg;
|
||||
|
||||
extern struct attrib * make_iceberg(direction_t dir);
|
||||
extern void init_iceberg(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
61
src/common/attributes/key.c
Normal file
61
src/common/attributes/key.c
Normal file
|
@ -0,0 +1,61 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
*
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2003
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
* Henning Peters (faroul@beyond.kn-bremen.de)
|
||||
* Enno Rehling (enno@eressea.de)
|
||||
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
|
||||
*
|
||||
* This program may not be used, modified or distributed without
|
||||
* prior permission by the authors of Eressea.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <kernel/eressea.h>
|
||||
#include "key.h"
|
||||
|
||||
#include <kernel/save.h>
|
||||
#include <util/attrib.h>
|
||||
|
||||
attrib_type at_key = {
|
||||
"key",
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
a_writeint,
|
||||
a_readint,
|
||||
};
|
||||
|
||||
attrib *
|
||||
add_key(attrib ** alist, int key)
|
||||
{
|
||||
attrib * a = find_key(*alist, key);
|
||||
if (a==NULL) a = a_add(alist, make_key(key));
|
||||
return a;
|
||||
}
|
||||
|
||||
attrib *
|
||||
make_key(int key)
|
||||
{
|
||||
attrib * a = a_new(&at_key);
|
||||
a->data.i = key;
|
||||
return a;
|
||||
}
|
||||
|
||||
attrib *
|
||||
find_key(attrib * alist, int key)
|
||||
{
|
||||
attrib * a = a_find(alist, &at_key);
|
||||
while (a && a->type==&at_key && a->data.i != key) {
|
||||
a = a->next;
|
||||
}
|
||||
return (a && a->type==&at_key)?a:NULL;
|
||||
}
|
||||
|
||||
void
|
||||
init_key(void)
|
||||
{
|
||||
at_register(&at_key);
|
||||
}
|
32
src/common/attributes/key.h
Normal file
32
src/common/attributes/key.h
Normal file
|
@ -0,0 +1,32 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
*
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2003
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
* Henning Peters (faroul@beyond.kn-bremen.de)
|
||||
* Enno Rehling (enno@eressea.de)
|
||||
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
|
||||
*
|
||||
* This program may not be used, modified or distributed without
|
||||
* prior permission by the authors of Eressea.
|
||||
*/
|
||||
|
||||
#ifndef H_ATTRIBUTE_KEY
|
||||
#define H_ATTRIBUTE_KEY
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern struct attrib_type at_key;
|
||||
|
||||
extern struct attrib * make_key(int key);
|
||||
extern struct attrib * find_key(struct attrib * alist, int key);
|
||||
extern struct attrib * add_key(struct attrib ** alist, int key);
|
||||
extern void init_key(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
36
src/common/attributes/matmod.c
Normal file
36
src/common/attributes/matmod.c
Normal file
|
@ -0,0 +1,36 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
*
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2003
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
* Henning Peters (faroul@beyond.kn-bremen.de)
|
||||
* Enno Rehling (enno@eressea.de)
|
||||
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
|
||||
*
|
||||
* This program may not be used, modified or distributed without
|
||||
* prior permission by the authors of Eressea.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include "matmod.h"
|
||||
|
||||
#include <util/attrib.h>
|
||||
|
||||
attrib_type at_matmod = {
|
||||
"matmod",
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
ATF_PRESERVE
|
||||
};
|
||||
|
||||
attrib *
|
||||
make_matmod(mm_fun function)
|
||||
{
|
||||
attrib * a = a_new(&at_matmod);
|
||||
a->data.f = (void(*)(void))function;
|
||||
return a;
|
||||
}
|
32
src/common/attributes/matmod.h
Normal file
32
src/common/attributes/matmod.h
Normal file
|
@ -0,0 +1,32 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
*
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2003
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
* Henning Peters (faroul@beyond.kn-bremen.de)
|
||||
* Enno Rehling (enno@eressea.de)
|
||||
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
|
||||
*
|
||||
* This program may not be used, modified or distributed without
|
||||
* prior permission by the authors of Eressea.
|
||||
*/
|
||||
#ifndef H_ATTRIBUTE_MATMOD
|
||||
#define H_ATTRIBUTE_MATMOD
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct resource_type;
|
||||
struct unit;
|
||||
typedef int (*mm_fun)(const struct unit * u, const struct resource_type * rtype, int value);
|
||||
|
||||
extern struct attrib_type at_matmod;
|
||||
extern struct attrib * make_matmod(mm_fun function);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
65
src/common/attributes/moved.c
Normal file
65
src/common/attributes/moved.c
Normal file
|
@ -0,0 +1,65 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
*
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2003
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
* Henning Peters (faroul@beyond.kn-bremen.de)
|
||||
* Enno Rehling (enno@eressea.de)
|
||||
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
|
||||
*
|
||||
* This program may not be used, modified or distributed without
|
||||
* prior permission by the authors of Eressea.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <kernel/eressea.h>
|
||||
#include "moved.h"
|
||||
|
||||
#include <util/attrib.h>
|
||||
#include <util/storage.h>
|
||||
|
||||
static int
|
||||
age_moved(attrib * a)
|
||||
{
|
||||
--a->data.i;
|
||||
return a->data.i > 0;
|
||||
}
|
||||
|
||||
static void
|
||||
write_moved(const attrib * a, struct storage * store)
|
||||
{
|
||||
store->w_int(store, a->data.i);
|
||||
}
|
||||
|
||||
static int
|
||||
read_moved(attrib * a, struct storage * store)
|
||||
{
|
||||
a->data.i = store->r_int(store);
|
||||
if (a->data.i !=0 ) return AT_READ_OK;
|
||||
else return AT_READ_FAIL;
|
||||
}
|
||||
|
||||
attrib_type at_moved = {
|
||||
"moved", NULL, NULL, age_moved, write_moved, read_moved
|
||||
};
|
||||
|
||||
boolean
|
||||
get_moved(attrib ** alist)
|
||||
{
|
||||
return a_find(*alist, &at_moved) ? true : false;
|
||||
}
|
||||
|
||||
void
|
||||
set_moved(attrib ** alist)
|
||||
{
|
||||
attrib * a = a_find(*alist, &at_moved);
|
||||
if (a==NULL) a = a_add(alist, a_new(&at_moved));
|
||||
a->data.i = 2;
|
||||
}
|
||||
|
||||
void
|
||||
init_moved(void)
|
||||
{
|
||||
at_register(&at_moved);
|
||||
}
|
34
src/common/attributes/moved.h
Normal file
34
src/common/attributes/moved.h
Normal file
|
@ -0,0 +1,34 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
*
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2003
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
* Henning Peters (faroul@beyond.kn-bremen.de)
|
||||
* Enno Rehling (enno@eressea.de)
|
||||
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
|
||||
*
|
||||
* This program may not be used, modified or distributed without
|
||||
* prior permission by the authors of Eressea.
|
||||
*/
|
||||
|
||||
#ifndef H_ATTRIBUTE_MOVED
|
||||
#define H_ATTRIBUTE_MOVED
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct attrib;
|
||||
struct attrib_type;
|
||||
|
||||
extern boolean get_moved(struct attrib ** alist);
|
||||
extern void set_moved(struct attrib ** alist);
|
||||
extern void init_moved(void);
|
||||
|
||||
extern struct attrib_type at_moved;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
61
src/common/attributes/movement.c
Normal file
61
src/common/attributes/movement.c
Normal file
|
@ -0,0 +1,61 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
*
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2003
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
* Henning Peters (faroul@beyond.kn-bremen.de)
|
||||
* Enno Rehling (enno@eressea.de)
|
||||
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
|
||||
*
|
||||
* This program may not be used, modified or distributed without
|
||||
* prior permission by the authors of Eressea.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <kernel/eressea.h>
|
||||
#include "movement.h"
|
||||
|
||||
#include <util/attrib.h>
|
||||
#include <util/storage.h>
|
||||
|
||||
static void
|
||||
write_movement(const attrib * a, struct storage * store)
|
||||
{
|
||||
store->w_int(store, a->data.i);
|
||||
}
|
||||
|
||||
static int
|
||||
read_movement(attrib * a, struct storage * store)
|
||||
{
|
||||
a->data.i = store->r_int(store);
|
||||
if (a->data.i !=0 ) return AT_READ_OK;
|
||||
else return AT_READ_FAIL;
|
||||
}
|
||||
|
||||
attrib_type at_movement = {
|
||||
"movement", NULL, NULL, NULL, write_movement, read_movement
|
||||
};
|
||||
|
||||
boolean
|
||||
get_movement(attrib * const * alist, int type)
|
||||
{
|
||||
const attrib * a = a_findc(*alist, &at_movement);
|
||||
if (a==NULL) return false;
|
||||
if (a->data.i & type) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
set_movement(attrib ** alist, int type)
|
||||
{
|
||||
attrib * a = a_find(*alist, &at_movement);
|
||||
if (a==NULL) a = a_add(alist, a_new(&at_movement));
|
||||
a->data.i |= type;
|
||||
}
|
||||
|
||||
void
|
||||
init_movement(void)
|
||||
{
|
||||
at_register(&at_movement);
|
||||
}
|
30
src/common/attributes/movement.h
Normal file
30
src/common/attributes/movement.h
Normal file
|
@ -0,0 +1,30 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
*
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2003
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
* Henning Peters (faroul@beyond.kn-bremen.de)
|
||||
* Enno Rehling (enno@eressea.de)
|
||||
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
|
||||
*
|
||||
* This program may not be used, modified or distributed without
|
||||
* prior permission by the authors of Eressea.
|
||||
*/
|
||||
|
||||
#ifndef H_ATTRIBUTE_MOVEMENT
|
||||
#define H_ATTRIBUTE_MOVEMENT
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern boolean get_movement(struct attrib * const * alist, int type);
|
||||
extern void set_movement(struct attrib ** alist, int type);
|
||||
extern void init_movement(void);
|
||||
|
||||
extern struct attrib_type at_movement;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
263
src/common/attributes/object.c
Normal file
263
src/common/attributes/object.c
Normal file
|
@ -0,0 +1,263 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
*
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2003
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
* Henning Peters (faroul@beyond.kn-bremen.de)
|
||||
* Enno Rehling (enno@eressea.de)
|
||||
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
|
||||
*
|
||||
* This program may not be used, modified or distributed without
|
||||
* prior permission by the authors of Eressea.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <kernel/eressea.h>
|
||||
#include "object.h"
|
||||
|
||||
/* kernel includes */
|
||||
#include <kernel/building.h>
|
||||
#include <kernel/faction.h>
|
||||
#include <kernel/region.h>
|
||||
#include <kernel/save.h>
|
||||
#include <kernel/ship.h>
|
||||
#include <kernel/unit.h>
|
||||
#include <kernel/version.h>
|
||||
|
||||
/* util includes */
|
||||
#include <util/attrib.h>
|
||||
#include <util/resolve.h>
|
||||
#include <util/storage.h>
|
||||
|
||||
/* stdc includes */
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
typedef struct object_data {
|
||||
object_type type;
|
||||
char * name;
|
||||
union {
|
||||
int i;
|
||||
char * str;
|
||||
double real;
|
||||
struct unit * u;
|
||||
struct region * r;
|
||||
struct building * b;
|
||||
struct ship * sh;
|
||||
struct faction * f;
|
||||
} data;
|
||||
} object_data;
|
||||
|
||||
static void
|
||||
object_write(const attrib *a, struct storage * store)
|
||||
{
|
||||
const object_data * data = (object_data *)a->data.v;
|
||||
int type = (int)data->type;
|
||||
store->w_tok(store, data->name);
|
||||
store->w_int(store, type);
|
||||
switch (data->type) {
|
||||
case TINTEGER:
|
||||
store->w_int(store, data->data.i);
|
||||
break;
|
||||
case TREAL:
|
||||
store->w_flt(store, (float)data->data.real);
|
||||
break;
|
||||
case TSTRING:
|
||||
store->w_str(store, data->data.str);
|
||||
break;
|
||||
case TUNIT:
|
||||
write_unit_reference(data->data.u, store );
|
||||
break;
|
||||
case TFACTION:
|
||||
write_faction_reference(data->data.f, store);
|
||||
break;
|
||||
case TBUILDING:
|
||||
write_building_reference(data->data.b, store);
|
||||
break;
|
||||
case TSHIP:
|
||||
/* write_ship_reference(data->data.sh, store); */
|
||||
assert(!"not implemented");
|
||||
break;
|
||||
case TREGION:
|
||||
write_region_reference(data->data.r, store);
|
||||
break;
|
||||
case TNONE:
|
||||
break;
|
||||
default:
|
||||
assert(!"illegal type in object-attribute");
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
object_read(attrib *a, struct storage * store)
|
||||
{
|
||||
object_data * data = (object_data *)a->data.v;
|
||||
int result;
|
||||
|
||||
data->name = store->r_str(store);
|
||||
data->type = (object_type)store->r_int(store);
|
||||
switch (data->type) {
|
||||
case TINTEGER:
|
||||
data->data.i = store->r_int(store);
|
||||
break;
|
||||
case TREAL:
|
||||
data->data.real = store->r_flt(store);
|
||||
break;
|
||||
case TSTRING:
|
||||
data->data.str = store->r_str(store);
|
||||
break;
|
||||
case TBUILDING:
|
||||
result = read_reference(&data->data.b, store, read_building_reference, resolve_building);
|
||||
if (result==0 && !data->data.b) {
|
||||
return AT_READ_FAIL;
|
||||
}
|
||||
break;
|
||||
case TUNIT:
|
||||
result = read_reference(&data->data.u, store, read_unit_reference, resolve_unit);
|
||||
if (result==0 && !data->data.u) {
|
||||
return AT_READ_FAIL;
|
||||
}
|
||||
break;
|
||||
case TFACTION:
|
||||
result = read_reference(&data->data.f, store, read_faction_reference, resolve_faction);
|
||||
if (result==0 && !data->data.f) {
|
||||
return AT_READ_FAIL;
|
||||
}
|
||||
break;
|
||||
case TREGION:
|
||||
result = read_reference(&data->data.r, store, read_region_reference, RESOLVE_REGION(store->version));
|
||||
if (result==0 && !data->data.r) {
|
||||
return AT_READ_FAIL;
|
||||
}
|
||||
break;
|
||||
case TSHIP:
|
||||
/* return read_ship_reference(&data->data.sh, store); */
|
||||
assert(!"not implemented");
|
||||
break;
|
||||
case TNONE:
|
||||
break;
|
||||
default:
|
||||
return AT_READ_FAIL;
|
||||
}
|
||||
return AT_READ_OK;
|
||||
}
|
||||
|
||||
static void
|
||||
object_init(attrib * a)
|
||||
{
|
||||
object_data * data;
|
||||
a->data.v = malloc(sizeof(object_data));
|
||||
data = (object_data *)a->data.v;
|
||||
data->type = TNONE;
|
||||
}
|
||||
|
||||
static void
|
||||
object_done(attrib * a)
|
||||
{
|
||||
object_data * data = (object_data *)a->data.v;
|
||||
if (data->type == TSTRING) free(data->data.str);
|
||||
free(data->name);
|
||||
free(a->data.v);
|
||||
}
|
||||
|
||||
attrib_type at_object = {
|
||||
"object", object_init, object_done, NULL,
|
||||
object_write, object_read
|
||||
};
|
||||
|
||||
const char *
|
||||
object_name(const attrib * a)
|
||||
{
|
||||
object_data * data = (object_data *)a->data.v;
|
||||
return data->name;
|
||||
}
|
||||
|
||||
struct attrib *
|
||||
object_create(const char * name, object_type type, variant value)
|
||||
{
|
||||
attrib * a = a_new(&at_object);
|
||||
object_data * data = (object_data *)a->data.v;
|
||||
data->name = strdup(name);
|
||||
|
||||
object_set(a, type, value);
|
||||
return a;
|
||||
}
|
||||
|
||||
void
|
||||
object_set(attrib * a, object_type type, variant value)
|
||||
{
|
||||
object_data * data = (object_data *)a->data.v;
|
||||
|
||||
if (data->type==TSTRING) free(data->data.str);
|
||||
data->type = type;
|
||||
switch (type) {
|
||||
case TSTRING:
|
||||
data->data.str = value.v?strdup(value.v):NULL;
|
||||
break;
|
||||
case TINTEGER:
|
||||
data->data.i = value.i;
|
||||
break;
|
||||
case TREAL:
|
||||
data->data.real = value.f;
|
||||
break;
|
||||
case TREGION:
|
||||
data->data.r = (region*)value.v;
|
||||
break;
|
||||
case TBUILDING:
|
||||
data->data.b = (building*)value.v;
|
||||
break;
|
||||
case TFACTION:
|
||||
data->data.f = (faction*)value.v;
|
||||
break;
|
||||
case TUNIT:
|
||||
data->data.u = (unit*)value.v;
|
||||
break;
|
||||
case TSHIP:
|
||||
data->data.sh = (ship*)value.v;
|
||||
break;
|
||||
case TNONE:
|
||||
break;
|
||||
default:
|
||||
assert(!"invalid object-type");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
object_get(const struct attrib * a, object_type * type, variant * value)
|
||||
{
|
||||
object_data * data = (object_data *)a->data.v;
|
||||
*type = data->type;
|
||||
switch (data->type) {
|
||||
case TSTRING:
|
||||
value->v = data->data.str;
|
||||
break;
|
||||
case TINTEGER:
|
||||
value->i = data->data.i;
|
||||
break;
|
||||
case TREAL:
|
||||
value->f = (float)data->data.real;
|
||||
break;
|
||||
case TREGION:
|
||||
value->v = data->data.r;
|
||||
break;
|
||||
case TBUILDING:
|
||||
value->v = data->data.b;
|
||||
break;
|
||||
case TFACTION:
|
||||
value->v = data->data.f;
|
||||
break;
|
||||
case TUNIT:
|
||||
value->v = data->data.u;
|
||||
break;
|
||||
case TSHIP:
|
||||
value->v = data->data.sh;
|
||||
break;
|
||||
case TNONE:
|
||||
break;
|
||||
default:
|
||||
assert(!"invalid object-type");
|
||||
break;
|
||||
}
|
||||
}
|
38
src/common/attributes/object.h
Normal file
38
src/common/attributes/object.h
Normal file
|
@ -0,0 +1,38 @@
|
|||
/* vi: set ts=2:
|
||||
+-------------------+ Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
| | Enno Rehling <enno@eressea.de>
|
||||
| Eressea PBEM host | Katja Zedel <katze@felidae.kn-bremen.de>
|
||||
| (c) 1998 - 2003 | Henning Peters <faroul@beyond.kn-bremen.de>
|
||||
| | Ingo Wilken <Ingo.Wilken@informatik.uni-oldenburg.de>
|
||||
+-------------------+ Stefan Reich <reich@halbling.de>
|
||||
|
||||
This program may not be used, modified or distributed
|
||||
without prior permission by the authors of Eressea.
|
||||
*/
|
||||
|
||||
#ifndef H_ATTRIBUTE_OBJECT
|
||||
#define H_ATTRIBUTE_OBJECT
|
||||
|
||||
#include <util/variant.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
TNONE = 0, TINTEGER = 1, TREAL = 2, TSTRING = 3,
|
||||
TUNIT = 10, TFACTION = 11, TREGION = 12, TBUILDING = 13, TSHIP = 14,
|
||||
} object_type;
|
||||
|
||||
extern struct attrib_type at_object;
|
||||
|
||||
extern struct attrib * object_create(const char * name, object_type type, variant value);
|
||||
extern void object_get(const struct attrib * a, object_type * type, variant * value);
|
||||
extern void object_set(struct attrib * a, object_type type, variant value);
|
||||
extern const char * object_name(const struct attrib * a);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
36
src/common/attributes/option.c
Normal file
36
src/common/attributes/option.c
Normal file
|
@ -0,0 +1,36 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
*
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2003
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
* Henning Peters (faroul@beyond.kn-bremen.de)
|
||||
* Enno Rehling (enno@eressea.de)
|
||||
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
|
||||
*
|
||||
* This program may not be used, modified or distributed without
|
||||
* prior permission by the authors of Eressea.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <kernel/eressea.h>
|
||||
#include "option.h"
|
||||
|
||||
#include <kernel/save.h>
|
||||
#include <util/attrib.h>
|
||||
|
||||
attrib_type at_option_news = {
|
||||
"option_news",
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
a_writeint,
|
||||
a_readint,
|
||||
ATF_UNIQUE
|
||||
};
|
||||
|
||||
void
|
||||
init_option(void)
|
||||
{
|
||||
at_register(&at_option_news);
|
||||
}
|
28
src/common/attributes/option.h
Normal file
28
src/common/attributes/option.h
Normal file
|
@ -0,0 +1,28 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
*
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2003
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
* Henning Peters (faroul@beyond.kn-bremen.de)
|
||||
* Enno Rehling (enno@eressea.de)
|
||||
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
|
||||
*
|
||||
* This program may not be used, modified or distributed without
|
||||
* prior permission by the authors of Eressea.
|
||||
*/
|
||||
|
||||
#ifndef H_ATTRIBUTE_OPTION
|
||||
#define H_ATTRIBUTE_OPTION
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern struct attrib_type at_option_news;
|
||||
extern void init_option(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
42
src/common/attributes/orcification.c
Normal file
42
src/common/attributes/orcification.c
Normal file
|
@ -0,0 +1,42 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
*
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2003
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
* Henning Peters (faroul@beyond.kn-bremen.de)
|
||||
* Enno Rehling (enno@eressea.de)
|
||||
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
|
||||
*
|
||||
* This program may not be used, modified or distributed without
|
||||
* prior permission by the authors of Eressea.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <kernel/eressea.h>
|
||||
#include "orcification.h"
|
||||
|
||||
#include <kernel/save.h>
|
||||
#include <util/attrib.h>
|
||||
|
||||
/*
|
||||
* simple attributes that do not yet have their own file
|
||||
*/
|
||||
|
||||
attrib_type at_orcification = {
|
||||
"orcification", NULL, NULL, NULL, a_writeint, a_readint, ATF_UNIQUE
|
||||
};
|
||||
|
||||
attrib *
|
||||
make_orcification(int orcification)
|
||||
{
|
||||
attrib * a = a_new(&at_orcification);
|
||||
a->data.i = orcification;
|
||||
return a;
|
||||
}
|
||||
|
||||
void
|
||||
init_orcification(void)
|
||||
{
|
||||
at_register(&at_orcification);
|
||||
}
|
25
src/common/attributes/orcification.h
Normal file
25
src/common/attributes/orcification.h
Normal file
|
@ -0,0 +1,25 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
*
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2003
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
* Henning Peters (faroul@beyond.kn-bremen.de)
|
||||
* Enno Rehling (enno@eressea.de)
|
||||
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
|
||||
*
|
||||
* This program may not be used, modified or distributed without
|
||||
* prior permission by the authors of Eressea.
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
extern struct attrib_type at_orcification;
|
||||
|
||||
extern struct attrib * make_orcification(int orcification);
|
||||
extern void init_orcification(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
81
src/common/attributes/otherfaction.c
Normal file
81
src/common/attributes/otherfaction.c
Normal file
|
@ -0,0 +1,81 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2003
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
* Henning Peters (faroul@beyond.kn-bremen.de)
|
||||
* Enno Rehling (enno@eressea.de)
|
||||
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
|
||||
*
|
||||
* This program may not be used, modified or distributed without
|
||||
* prior permission by the authors of Eressea.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <kernel/eressea.h>
|
||||
#include "otherfaction.h"
|
||||
|
||||
#include <kernel/faction.h>
|
||||
#include <kernel/unit.h>
|
||||
#include <util/attrib.h>
|
||||
#include <util/storage.h>
|
||||
#include <assert.h>
|
||||
|
||||
/*
|
||||
* simple attributes that do not yet have their own file
|
||||
*/
|
||||
|
||||
|
||||
void
|
||||
write_of(const struct attrib * a, struct storage * store)
|
||||
{
|
||||
const faction * f = (faction*)a->data.v;
|
||||
store->w_int(store, f->no);
|
||||
}
|
||||
|
||||
int
|
||||
read_of(struct attrib * a, struct storage * store) /* return 1 on success, 0 if attrib needs removal */
|
||||
{
|
||||
int of = store->r_int(store);
|
||||
a->data.v = findfaction(of);
|
||||
if (a->data.v) return AT_READ_OK;
|
||||
return AT_READ_FAIL;
|
||||
}
|
||||
|
||||
attrib_type at_otherfaction = {
|
||||
"otherfaction", NULL, NULL, NULL, write_of, read_of, ATF_UNIQUE
|
||||
};
|
||||
|
||||
struct faction *
|
||||
get_otherfaction(const struct attrib * a)
|
||||
{
|
||||
return (faction*)(a->data.v);
|
||||
}
|
||||
|
||||
struct attrib *
|
||||
make_otherfaction(struct faction * f)
|
||||
{
|
||||
attrib * a = a_new(&at_otherfaction);
|
||||
a->data.v = (void*)f;
|
||||
return a;
|
||||
}
|
||||
|
||||
void
|
||||
init_otherfaction(void)
|
||||
{
|
||||
at_register(&at_otherfaction);
|
||||
}
|
||||
|
||||
faction *
|
||||
visible_faction(const faction *f, const unit * u)
|
||||
{
|
||||
if (f==NULL || !alliedunit(u, f, HELP_FSTEALTH)) {
|
||||
attrib *a = a_find(u->attribs, &at_otherfaction);
|
||||
if (a) {
|
||||
faction *fv = get_otherfaction(a);
|
||||
assert (fv != NULL); /* fv should never be NULL! */
|
||||
return fv;
|
||||
}
|
||||
}
|
||||
return u->faction;
|
||||
}
|
28
src/common/attributes/otherfaction.h
Normal file
28
src/common/attributes/otherfaction.h
Normal file
|
@ -0,0 +1,28 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2003
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
* Henning Peters (faroul@beyond.kn-bremen.de)
|
||||
* Enno Rehling (enno@eressea.de)
|
||||
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
|
||||
*
|
||||
* This program may not be used, modified or distributed without
|
||||
* prior permission by the authors of Eressea.
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct faction;
|
||||
struct attrib;
|
||||
extern struct attrib_type at_otherfaction;
|
||||
extern void init_otherfaction(void);
|
||||
extern struct faction * get_otherfaction(const struct attrib * a);
|
||||
extern struct attrib * make_otherfaction(struct faction * f);
|
||||
extern struct faction * visible_faction(const struct faction *f, const struct unit * u);
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
25
src/common/attributes/overrideroads.c
Normal file
25
src/common/attributes/overrideroads.c
Normal file
|
@ -0,0 +1,25 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
*
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2003
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
* Henning Peters (faroul@beyond.kn-bremen.de)
|
||||
* Enno Rehling (enno@eressea.de)
|
||||
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
|
||||
*
|
||||
* This program may not be used, modified or distributed without
|
||||
* prior permission by the authors of Eressea.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <kernel/eressea.h>
|
||||
#include "overrideroads.h"
|
||||
|
||||
#include <kernel/save.h>
|
||||
#include <util/attrib.h>
|
||||
|
||||
attrib_type at_overrideroads = {
|
||||
"roads_override", NULL, NULL, NULL, &a_writestring, &a_readstring
|
||||
};
|
||||
|
28
src/common/attributes/overrideroads.h
Normal file
28
src/common/attributes/overrideroads.h
Normal file
|
@ -0,0 +1,28 @@
|
|||
|
||||
/* vi: set ts=2:
|
||||
*
|
||||
*
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2003
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
* Henning Peters (faroul@beyond.kn-bremen.de)
|
||||
* Enno Rehling (enno@eressea.de)
|
||||
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
|
||||
*
|
||||
* This program may not be used, modified or distributed without
|
||||
* prior permission by the authors of Eressea.
|
||||
*/
|
||||
|
||||
#ifndef H_ATTRIBUTE_OVERRRIDEROADS
|
||||
#define H_ATTRIBUTE_OVERRRIDEROADS
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern struct attrib_type at_overrideroads;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
59
src/common/attributes/racename.c
Normal file
59
src/common/attributes/racename.c
Normal file
|
@ -0,0 +1,59 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
*
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2003
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
* Henning Peters (faroul@beyond.kn-bremen.de)
|
||||
* Enno Rehling (enno@eressea.de)
|
||||
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
|
||||
*
|
||||
* This program may not be used, modified or distributed without
|
||||
* prior permission by the authors of Eressea.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <kernel/eressea.h>
|
||||
#include "racename.h"
|
||||
|
||||
#include <kernel/save.h>
|
||||
#include <util/attrib.h>
|
||||
|
||||
/* libc includes */
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
attrib_type at_racename = {
|
||||
"racename", NULL, a_finalizestring, NULL, a_writestring, a_readstring
|
||||
};
|
||||
|
||||
const char *
|
||||
get_racename(attrib * alist)
|
||||
{
|
||||
attrib * a = a_find(alist, &at_racename);
|
||||
if (a) return (const char *)a->data.v;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
set_racename(attrib ** palist, const char * name)
|
||||
{
|
||||
attrib * a = a_find(*palist, &at_racename);
|
||||
if (!a && name) {
|
||||
a = a_add(palist, a_new(&at_racename));
|
||||
a->data.v = strdup(name);
|
||||
} else if (a && !name) {
|
||||
a_remove(palist, a);
|
||||
} else if (a) {
|
||||
if (strcmp(a->data.v, name)!=0) {
|
||||
free(a->data.v);
|
||||
a->data.v = strdup(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
init_racename(void)
|
||||
{
|
||||
at_register(&at_racename);
|
||||
}
|
34
src/common/attributes/racename.h
Normal file
34
src/common/attributes/racename.h
Normal file
|
@ -0,0 +1,34 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
*
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2003
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
* Henning Peters (faroul@beyond.kn-bremen.de)
|
||||
* Enno Rehling (enno@eressea.de)
|
||||
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
|
||||
*
|
||||
* This program may not be used, modified or distributed without
|
||||
* prior permission by the authors of Eressea.
|
||||
*/
|
||||
|
||||
#ifndef H_ATTRIBUTE_RACENAME_H
|
||||
#define H_ATTRIBUTE_RACENAME_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct attrib_type;
|
||||
struct attrib;
|
||||
|
||||
extern void set_racename(struct attrib ** palist, const char * name);
|
||||
extern const char * get_racename(struct attrib * alist);
|
||||
extern void init_racename(void);
|
||||
|
||||
extern struct attrib_type at_racename;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
56
src/common/attributes/raceprefix.c
Normal file
56
src/common/attributes/raceprefix.c
Normal file
|
@ -0,0 +1,56 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
*
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2003
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
* Henning Peters (faroul@beyond.kn-bremen.de)
|
||||
* Enno Rehling (enno@eressea.de)
|
||||
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
|
||||
*
|
||||
* This program may not be used, modified or distributed without
|
||||
* prior permission by the authors of Eressea.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <kernel/eressea.h>
|
||||
#include "raceprefix.h"
|
||||
#include <kernel/save.h>
|
||||
|
||||
#include <util/attrib.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
attrib_type at_raceprefix = {
|
||||
"raceprefix", NULL, a_finalizestring, NULL, a_writestring, a_readstring, ATF_UNIQUE
|
||||
};
|
||||
|
||||
void
|
||||
set_prefix(attrib ** ap, const char * str)
|
||||
{
|
||||
attrib * a = a_find(*ap, &at_raceprefix);
|
||||
if (a==NULL) {
|
||||
a = a_add(ap, a_new(&at_raceprefix));
|
||||
} else {
|
||||
free(a->data.v);
|
||||
}
|
||||
assert(a->type==&at_raceprefix);
|
||||
a->data.v = strdup(str);
|
||||
}
|
||||
|
||||
const char *
|
||||
get_prefix(const attrib * a)
|
||||
{
|
||||
char * str;
|
||||
a = a_findc(a, &at_raceprefix);
|
||||
if (a==NULL) return NULL;
|
||||
str = (char *)a->data.v;
|
||||
/* conversion of old prefixes */
|
||||
if (strncmp(str, "prefix_", 7)==0) {
|
||||
((attrib*)a)->data.v = strdup(str+7);
|
||||
free(str);
|
||||
str = (char *)a->data.v;
|
||||
}
|
||||
return str;
|
||||
}
|
30
src/common/attributes/raceprefix.h
Normal file
30
src/common/attributes/raceprefix.h
Normal file
|
@ -0,0 +1,30 @@
|
|||
|
||||
/* vi: set ts=2:
|
||||
*
|
||||
*
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2003
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
* Henning Peters (faroul@beyond.kn-bremen.de)
|
||||
* Enno Rehling (enno@eressea.de)
|
||||
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
|
||||
*
|
||||
* This program may not be used, modified or distributed without
|
||||
* prior permission by the authors of Eressea.
|
||||
*/
|
||||
|
||||
#ifndef H_ATTRIBUTE_RACEPREFIX
|
||||
#define H_ATTRIBUTE_RACEPREFIX
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern struct attrib_type at_raceprefix;
|
||||
extern void set_prefix(struct attrib ** ap, const char * str);
|
||||
extern const char * get_prefix(const struct attrib * a);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
53
src/common/attributes/reduceproduction.c
Normal file
53
src/common/attributes/reduceproduction.c
Normal file
|
@ -0,0 +1,53 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
*
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2003
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
* Henning Peters (faroul@beyond.kn-bremen.de)
|
||||
* Enno Rehling (enno@eressea.de)
|
||||
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
|
||||
*
|
||||
* This program may not be used, modified or distributed without
|
||||
* prior permission by the authors of Eressea.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <kernel/eressea.h>
|
||||
#include "reduceproduction.h"
|
||||
#include <kernel/save.h>
|
||||
#include <util/attrib.h>
|
||||
|
||||
static int
|
||||
age_reduceproduction(attrib *a)
|
||||
{
|
||||
int reduce = 100 - (5 * --a->data.sa[1]);
|
||||
if (reduce < 10) reduce = 10;
|
||||
a->data.sa[0] = (short)reduce;
|
||||
return (a->data.sa[1]>0)?AT_AGE_KEEP:AT_AGE_REMOVE;
|
||||
}
|
||||
|
||||
attrib_type at_reduceproduction = {
|
||||
"reduceproduction",
|
||||
NULL,
|
||||
NULL,
|
||||
age_reduceproduction,
|
||||
a_writeshorts,
|
||||
a_readshorts,
|
||||
ATF_UNIQUE
|
||||
};
|
||||
|
||||
attrib *
|
||||
make_reduceproduction(int percent, int time)
|
||||
{
|
||||
attrib * a = a_new(&at_reduceproduction);
|
||||
a->data.sa[0] = (short)percent;
|
||||
a->data.sa[1] = (short)time;
|
||||
return a;
|
||||
}
|
||||
|
||||
void
|
||||
init_reduceproduction(void)
|
||||
{
|
||||
at_register(&at_reduceproduction);
|
||||
}
|
29
src/common/attributes/reduceproduction.h
Normal file
29
src/common/attributes/reduceproduction.h
Normal file
|
@ -0,0 +1,29 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
*
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2003
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
* Henning Peters (faroul@beyond.kn-bremen.de)
|
||||
* Enno Rehling (enno@eressea.de)
|
||||
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
|
||||
*
|
||||
* This program may not be used, modified or distributed without
|
||||
* prior permission by the authors of Eressea.
|
||||
*/
|
||||
|
||||
#ifndef H_ATTRIBUTE_REDUCEPRODUCTION
|
||||
#define H_ATTRIBUTE_REDUCEPRODUCTION
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern struct attrib * make_reduceproduction(int percent, int time);
|
||||
extern struct attrib_type at_reduceproduction;
|
||||
extern void init_reduceproduction(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
63
src/common/attributes/targetregion.c
Normal file
63
src/common/attributes/targetregion.c
Normal file
|
@ -0,0 +1,63 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
*
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2003
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
* Henning Peters (faroul@beyond.kn-bremen.de)
|
||||
* Enno Rehling (enno@eressea.de)
|
||||
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
|
||||
*
|
||||
* This program may not be used, modified or distributed without
|
||||
* prior permission by the authors of Eressea.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include "targetregion.h"
|
||||
|
||||
#include <kernel/eressea.h>
|
||||
#include <kernel/region.h>
|
||||
#include <kernel/save.h>
|
||||
#include <kernel/version.h>
|
||||
|
||||
#include <util/attrib.h>
|
||||
#include <util/resolve.h>
|
||||
#include <util/storage.h>
|
||||
|
||||
static void
|
||||
write_targetregion(const attrib * a, struct storage * store)
|
||||
{
|
||||
write_region_reference((region*)a->data.v, store);
|
||||
}
|
||||
|
||||
static int
|
||||
read_targetregion(attrib * a, struct storage * store)
|
||||
{
|
||||
int result = read_reference(&a->data.v, store, read_region_reference, RESOLVE_REGION(store->version));
|
||||
if (result==0 && !a->data.v) return AT_READ_FAIL;
|
||||
return AT_READ_OK;
|
||||
}
|
||||
|
||||
attrib_type at_targetregion = {
|
||||
"targetregion",
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
write_targetregion,
|
||||
read_targetregion,
|
||||
ATF_UNIQUE
|
||||
};
|
||||
|
||||
attrib *
|
||||
make_targetregion(struct region * r)
|
||||
{
|
||||
attrib * a = a_new(&at_targetregion);
|
||||
a->data.v = r;
|
||||
return a;
|
||||
}
|
||||
|
||||
void
|
||||
init_targetregion(void)
|
||||
{
|
||||
at_register(&at_targetregion);
|
||||
}
|
31
src/common/attributes/targetregion.h
Normal file
31
src/common/attributes/targetregion.h
Normal file
|
@ -0,0 +1,31 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
*
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2003
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
* Henning Peters (faroul@beyond.kn-bremen.de)
|
||||
* Enno Rehling (enno@eressea.de)
|
||||
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
|
||||
*
|
||||
* This program may not be used, modified or distributed without
|
||||
* prior permission by the authors of Eressea.
|
||||
*/
|
||||
|
||||
#ifndef H_ATTRIBUTE_TARGETREGION
|
||||
#define H_ATTRIBUTE_TARGETREGION
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern struct attrib_type at_targetregion;
|
||||
|
||||
struct region;
|
||||
extern struct attrib * make_targetregion(struct region *);
|
||||
extern void init_targetregion(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
47
src/common/attributes/variable.c
Normal file
47
src/common/attributes/variable.c
Normal file
|
@ -0,0 +1,47 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
*
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2004
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
* Enno Rehling (enno@eressea.de)
|
||||
*
|
||||
* This program may not be used, modified or distributed without
|
||||
* prior permission by the authors of Eressea.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <kernel/eressea.h>
|
||||
#include "variable.h"
|
||||
|
||||
#include <kernel/save.h>
|
||||
|
||||
#include <util/attrib.h>
|
||||
#include <util/storage.h>
|
||||
|
||||
/* libc includes */
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
static int
|
||||
read_variable(struct attrib *a, storage * store)
|
||||
{
|
||||
char * key = store->r_tok(store);
|
||||
char * value = store->r_str(store);
|
||||
free(key);
|
||||
free(value);
|
||||
|
||||
return AT_READ_FAIL;
|
||||
}
|
||||
|
||||
attrib_type at_variable = {
|
||||
"variable", NULL, NULL, NULL,
|
||||
NULL, read_variable
|
||||
};
|
||||
void
|
||||
init_variable(void)
|
||||
{
|
||||
at_register(&at_variable);
|
||||
}
|
27
src/common/attributes/variable.h
Normal file
27
src/common/attributes/variable.h
Normal file
|
@ -0,0 +1,27 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
*
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2004
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
* Enno Rehling (enno@eressea.de)
|
||||
*
|
||||
* This program may not be used, modified or distributed without
|
||||
* prior permission by the authors of Eressea.
|
||||
*/
|
||||
|
||||
#ifndef H_ATTRIBUTE_VARIABLE
|
||||
#define H_ATTRIBUTE_VARIABLE
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void init_variable(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
73
src/common/attributes/viewrange.c
Normal file
73
src/common/attributes/viewrange.c
Normal file
|
@ -0,0 +1,73 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
*
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2003
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
* Henning Peters (faroul@beyond.kn-bremen.de)
|
||||
* Enno Rehling (enno@eressea.de)
|
||||
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
|
||||
*
|
||||
* This program may not be used, modified or distributed without
|
||||
* prior permission by the authors of Eressea.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include "viewrange.h"
|
||||
|
||||
/* util includes */
|
||||
#include <util/attrib.h>
|
||||
#include <util/functions.h>
|
||||
#include <util/storage.h>
|
||||
|
||||
/* libc includes */
|
||||
#include <assert.h>
|
||||
|
||||
static void
|
||||
a_writefunction(const struct attrib * a, storage * store)
|
||||
{
|
||||
const char * str = get_functionname((pf_generic)a->data.f);
|
||||
store->w_tok(store, str);
|
||||
}
|
||||
|
||||
static int
|
||||
a_readfunction(struct attrib *a, storage * store)
|
||||
/* return 1 on success, 0 if attrib needs removal */
|
||||
{
|
||||
char buf[64];
|
||||
store->r_tok_buf(store, buf, sizeof(buf));
|
||||
a->data.f = get_function(buf);
|
||||
return AT_READ_OK;
|
||||
}
|
||||
|
||||
attrib_type at_viewrange = {
|
||||
"viewrange",
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
a_writefunction,
|
||||
a_readfunction,
|
||||
};
|
||||
|
||||
attrib *
|
||||
add_viewrange(attrib ** alist, const char *function)
|
||||
{
|
||||
attrib * a = a_find(*alist, &at_viewrange);
|
||||
if (a==NULL) a = a_add(alist, make_viewrange(function));
|
||||
return a;
|
||||
}
|
||||
|
||||
attrib *
|
||||
make_viewrange(const char *function)
|
||||
{
|
||||
attrib * a = a_new(&at_viewrange);
|
||||
a->data.f = get_function(function);
|
||||
assert(a->data.f);
|
||||
return a;
|
||||
}
|
||||
|
||||
void
|
||||
init_viewrange(void)
|
||||
{
|
||||
at_register(&at_viewrange);
|
||||
}
|
31
src/common/attributes/viewrange.h
Normal file
31
src/common/attributes/viewrange.h
Normal file
|
@ -0,0 +1,31 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
*
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2003
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
* Henning Peters (faroul@beyond.kn-bremen.de)
|
||||
* Enno Rehling (enno@eressea.de)
|
||||
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
|
||||
*
|
||||
* This program may not be used, modified or distributed without
|
||||
* prior permission by the authors of Eressea.
|
||||
*/
|
||||
|
||||
#ifndef H_ATTRIBUTE_VIEWRANGE
|
||||
#define H_ATTRIBUTE_VIEWRANGE
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern struct attrib_type at_viewrange;
|
||||
|
||||
extern struct attrib * make_viewrange(const char *function);
|
||||
extern struct attrib * add_viewrange(struct attrib ** alist, const char *function);
|
||||
extern void init_viewrange(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
285
src/common/config.h
Normal file
285
src/common/config.h
Normal file
|
@ -0,0 +1,285 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
*
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2000
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
* Henning Peters (faroul@beyond.kn-bremen.de)
|
||||
* Enno Rehling (enno@eressea.de)
|
||||
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
|
||||
*
|
||||
* based on:
|
||||
*
|
||||
* Atlantis v1.0 13 September 1993 Copyright 1993 by Russell Wallace
|
||||
* Atlantis v1.7 Copyright 1996 by Alex Schröder
|
||||
*
|
||||
* This program may not be used, modified or distributed without
|
||||
* prior permission by the authors of Eressea.
|
||||
* This program may not be sold or used commercially without prior written
|
||||
* permission from the authors.
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_H
|
||||
#define CONFIG_H
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# define VC_EXTRALEAN
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
# include <Windows.h>
|
||||
# undef MOUSE_MOVED
|
||||
# define STDIO_CP 1252 /* log.c, convert to console character set */
|
||||
# pragma warning (disable: 4201 4214 4514 4115 4711)
|
||||
# pragma warning(disable: 4056)
|
||||
/* warning C4056: overflow in floating point constant arithmetic */
|
||||
# pragma warning(disable: 4201)
|
||||
/* warning C4201: nonstandard extension used : nameless struct/union */
|
||||
# pragma warning(disable: 4214)
|
||||
/* warning C4214: nonstandard extension used : bit field types other than int */
|
||||
# pragma warning(disable: 4100)
|
||||
/* warning C4100: <name> : unreferenced formal parameter */
|
||||
# pragma warning(disable: 4996)
|
||||
|
||||
/* warning C4100: <name> was declared deprecated */
|
||||
#ifndef _CRT_SECURE_NO_DEPRECATE
|
||||
# define _CRT_SECURE_NO_DEPRECATE
|
||||
#endif
|
||||
|
||||
/* http://msdn2.microsoft.com/en-us/library/ms235505(VS.80).aspx */
|
||||
#ifndef _CRT_DISABLE_PERFCRIT_LOCKS
|
||||
# define _CRT_DISABLE_PERFCRIT_LOCKS
|
||||
#endif
|
||||
|
||||
#endif /* _MSC_VER_ */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
# include <cstdio>
|
||||
# include <cstdlib>
|
||||
extern "C" {
|
||||
#else
|
||||
# include <stdio.h>
|
||||
# include <stdlib.h>
|
||||
#endif
|
||||
|
||||
/**** ****
|
||||
** Debugging Libraries **
|
||||
**** ****/
|
||||
#if defined __GNUC__
|
||||
# define HAVE_INLINE
|
||||
# define INLINE_FUNCTION static __inline
|
||||
#endif
|
||||
|
||||
/* define USE_DMALLOC to enable use of the dmalloc library */
|
||||
#ifdef USE_DMALLOC
|
||||
# include <stdlib.h>
|
||||
# include <string.h>
|
||||
# include <dmalloc.h>
|
||||
#endif
|
||||
|
||||
/* define CRTDBG to enable MSVC CRT Debug library functions */
|
||||
#if defined(_DEBUG) && defined(_MSC_VER) && defined(CRTDBG)
|
||||
# include <crtdbg.h>
|
||||
# define _CRTDBG_MAP_ALLOC
|
||||
#endif
|
||||
|
||||
/**** ****
|
||||
** Architecture Dependent **
|
||||
**** ****/
|
||||
|
||||
/* für solaris: */
|
||||
#ifdef SOLARIS
|
||||
# define _SYS_PROCSET_H
|
||||
# define _XOPEN_SOURCE
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
# ifndef _BSD_SOURCE
|
||||
# define _BSD_SOURCE
|
||||
# define __USE_BSD
|
||||
# endif
|
||||
/* # include <features.h> */
|
||||
# include <strings.h> /* strncasecmp-Prototyp */
|
||||
#endif
|
||||
|
||||
#ifdef _BSD_SOURCE
|
||||
# define __EXTENSIONS__
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
# define HAVE__MKDIR_WITHOUT_PERMISSION
|
||||
# define HAVE__SLEEP_MSEC
|
||||
#endif
|
||||
|
||||
#if defined(__USE_SVID) || defined(_BSD_SOURCE) || defined(__USE_XOPEN_EXTENDED) || defined(_BE_SETUP_H) || defined(CYGWIN)
|
||||
# include <unistd.h>
|
||||
# define HAVE_UNISTD_H
|
||||
# define HAVE_STRCASECMP
|
||||
# define HAVE_STRNCASECMP
|
||||
# define HAVE_ACCESS
|
||||
# define HAVE_STAT
|
||||
typedef struct stat stat_type;
|
||||
# include <string.h>
|
||||
# define HAVE_STRDUP
|
||||
# define HAVE_SNPRINTF
|
||||
#ifdef _POSIX_SOURCE /* MINGW doesn't seem to have these */
|
||||
# define HAVE_EXECINFO
|
||||
# define HAVE_MKDIR_WITH_PERMISSION
|
||||
# define HAVE_SIGACTION
|
||||
# define HAVE_LINK
|
||||
# define HAVE_SLEEP
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* egcpp 4 dos */
|
||||
#ifdef MSDOS
|
||||
# include <dir.h>
|
||||
# define HAVE_MKDIR_WITH_PERMISSION
|
||||
#endif
|
||||
|
||||
/* lcc-win32 */
|
||||
#ifdef __LCC__
|
||||
# include <string.h>
|
||||
# include <direct.h>
|
||||
# include <io.h>
|
||||
# define HAVE_ACCESS
|
||||
# define HAVE_STAT
|
||||
typedef struct stat stat_type;
|
||||
# define HAVE_STRICMP
|
||||
# define HAVE_STRNICMP
|
||||
# define HAVE_STRDUP
|
||||
# define HAVE_SLEEP
|
||||
# define snprintf _snprintf
|
||||
# define HAVE_SNPRINTF
|
||||
# undef HAVE_STRCASECMP
|
||||
# undef HAVE_STRNCASECMP
|
||||
# define R_OK 4
|
||||
#endif
|
||||
|
||||
/* Microsoft Visual C */
|
||||
#ifdef _MSC_VER
|
||||
# include <string.h> /* must be included here so strdup is not redefined */
|
||||
# define R_OK 4
|
||||
# define HAVE_INLINE
|
||||
# define INLINE_FUNCTION __inline
|
||||
|
||||
# define snprintf _snprintf
|
||||
# define HAVE_SNPRINTF
|
||||
|
||||
/* MSVC has _access, not access */
|
||||
#ifndef access
|
||||
# define access(f, m) _access(f, m)
|
||||
#endif
|
||||
#define HAVE_ACCESS
|
||||
|
||||
/* MSVC has _stat, not stat */
|
||||
# define HAVE_STAT
|
||||
#include <sys/stat.h>
|
||||
# define stat(a, b) _stat(a, b)
|
||||
typedef struct _stat stat_type;
|
||||
|
||||
/* MSVC has _strdup */
|
||||
# define strdup _strdup
|
||||
# define HAVE_STRDUP
|
||||
|
||||
# define stricmp(a, b) _stricmp(a, b)
|
||||
# define HAVE_STRICMP
|
||||
|
||||
# define strnicmp(a, b, c) _strnicmp(a, b, c)
|
||||
# define HAVE_STRNICMP
|
||||
# undef HAVE_STRCASECMP
|
||||
# undef HAVE_STRNCASECMP
|
||||
#endif
|
||||
|
||||
/* replacements for missing functions: */
|
||||
|
||||
#ifndef HAVE_STRCASECMP
|
||||
# if defined(HAVE_STRICMP)
|
||||
# define strcasecmp stricmp
|
||||
# elif defined(HAVE__STRICMP)
|
||||
# define strcasecmp _stricmp
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRNCASECMP
|
||||
# if defined(HAVE_STRNICMP)
|
||||
# define strncasecmp strnicmp
|
||||
# elif defined(HAVE__STRNICMP)
|
||||
# define strncasecmp _strnicmp
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MKDIR_WITH_PERMISSION
|
||||
# define makedir(d, p) mkdir(d, p)
|
||||
#elif defined(HAVE_MKDIR_WITHOUT_PERMISSION)
|
||||
# define makedir(d, p) mkdir(d)
|
||||
#elif defined(HAVE__MKDIR_WITHOUT_PERMISSION)
|
||||
_CRTIMP int __cdecl _mkdir(const char *);
|
||||
# define makedir(d, p) _mkdir(d)
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRDUP
|
||||
extern char * strdup(const char *s);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_SLEEP
|
||||
#ifdef HAVE__SLEEP_MSEC
|
||||
# define sleep(sec) _sleep(1000*sec)
|
||||
#elif defined(HAVE__SLEEP)
|
||||
# define sleep(sec) _sleep(sec)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if !defined(MAX_PATH)
|
||||
# if defined(PATH_MAX)
|
||||
# define MAX_PATH PATH_MAX
|
||||
# else
|
||||
# define MAX_PATH 1024
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/**** ****
|
||||
** min/max macros **
|
||||
**** ****/
|
||||
#ifndef NOMINMAX
|
||||
#ifndef MIN
|
||||
# define MIN(a,b) ((a) < (b) ? (a) : (b))
|
||||
#endif
|
||||
#ifndef MAX
|
||||
# define MAX(a,b) ((a) > (b) ? (a) : (b))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined (__GNUC__)
|
||||
# define unused(a) /* unused: a */
|
||||
#elif defined (ghs) || defined (__hpux) || defined (__sgi) || defined (__DECCXX) || defined (__KCC) || defined (__rational__) || defined (__USLC__) || defined (ACE_RM544)
|
||||
# define unused(a) do {/* null */} while (&a == 0)
|
||||
#else /* ghs || __GNUC__ || ..... */
|
||||
# define unused(a) (a)
|
||||
#endif /* ghs || __GNUC__ || ..... */
|
||||
|
||||
/**** ****
|
||||
** The Eressea boolean type **
|
||||
**** ****/
|
||||
#if defined(BOOLEAN)
|
||||
# define boolean BOOLEAN
|
||||
#else
|
||||
typedef int boolean; /* not bool! wrong size. */
|
||||
#endif
|
||||
#ifndef __cplusplus
|
||||
# define false ((boolean)0)
|
||||
# define true ((boolean)!false)
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef INLINE_FUNCTION
|
||||
# define INLINE_FUNCTION
|
||||
#endif
|
||||
|
||||
#define iswxspace(c) (c==160 || iswspace(c))
|
||||
#define isxspace(c) (c==160 || isspace(c))
|
||||
|
||||
#define TOLUA_CAST (char*)
|
||||
#endif
|
||||
|
403
src/common/gamecode.vcproj
Normal file
403
src/common/gamecode.vcproj
Normal file
|
@ -0,0 +1,403 @@
|
|||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="8.00"
|
||||
Name="gamecode"
|
||||
ProjectGUID="{1E8BFF9E-3044-0742-992F-C5765B80FE65}"
|
||||
RootNamespace="gamecode"
|
||||
Keyword="Win32Proj"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="Debug/gamecode"
|
||||
IntermediateDirectory="Debug/gamecode"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalOptions="/MP"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..;."
|
||||
PreprocessorDefinitions="WIN32;_CRT_SECURE_NO_DEPRECATE"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
EnableFunctionLevelLinking="true"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="4"
|
||||
WarnAsError="true"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="WIN32;_CRT_SECURE_NO_DEPRECATE"
|
||||
AdditionalIncludeDirectories="..;."
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile="$(OutDir)/gamecode.lib"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Profile|Win32"
|
||||
OutputDirectory="Profile/gamecode"
|
||||
IntermediateDirectory="Profile/gamecode"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..;."
|
||||
PreprocessorDefinitions="WIN32;_CRT_SECURE_NO_DEPRECATE;NDEBUG"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
EnableFunctionLevelLinking="true"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="4"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="WIN32;_CRT_SECURE_NO_DEPRECATE;NDEBUG"
|
||||
AdditionalIncludeDirectories="..;."
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile="$(OutDir)/gamecode.lib"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="Release/gamecode"
|
||||
IntermediateDirectory="Release/gamecode"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="3"
|
||||
AdditionalIncludeDirectories="..;."
|
||||
PreprocessorDefinitions="WIN32;_CRT_SECURE_NO_DEPRECATE;NDEBUG"
|
||||
StringPooling="true"
|
||||
RuntimeLibrary="2"
|
||||
EnableFunctionLevelLinking="true"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="4"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="0"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="WIN32;_CRT_SECURE_NO_DEPRECATE;NDEBUG"
|
||||
AdditionalIncludeDirectories="..;."
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile="$(OutDir)/gamecode.lib"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="gamecode"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\gamecode\archetype.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\gamecode\archetype.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\gamecode\creation.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\gamecode\creation.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\gamecode\creport.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\gamecode\creport.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\gamecode\economy.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\gamecode\economy.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\gamecode\give.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\gamecode\give.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\gamecode\items.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\gamecode\items.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\gamecode\laws.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\gamecode\laws.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\gamecode\luck.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\gamecode\luck.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\gamecode\market.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\gamecode\market.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\gamecode\monster.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\gamecode\monster.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\gamecode\randenc.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\gamecode\randenc.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\gamecode\report.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\gamecode\report.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\gamecode\spells.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\gamecode\spells.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\gamecode\spy.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\gamecode\spy.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\gamecode\study.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\gamecode\study.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\gamecode\summary.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\gamecode\summary.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\gamecode\xmlreport.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\gamecode\xmlreport.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="races"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\races\dragons.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\races\dragons.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\races\illusion.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\races\illusion.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\races\races.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\races\races.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\races\zombies.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\races\zombies.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
30
src/common/gamecode/Jamfile
Normal file
30
src/common/gamecode/Jamfile
Normal file
|
@ -0,0 +1,30 @@
|
|||
SubDir TOP common gamecode ;
|
||||
|
||||
TargetDirectory ;
|
||||
SubDirHdrs $(SUBDIR)/../kernel ;
|
||||
SubDirHdrs $(SUBDIR)/../util ;
|
||||
SubDirHdrs $(SUBDIR)/.. ;
|
||||
SubDirHdrs $(SUBDIR)/../.. ;
|
||||
SubDirHdrs $(XMLHDRS) ;
|
||||
|
||||
SOURCES =
|
||||
archetype.c
|
||||
creation.c
|
||||
creport.c
|
||||
economy.c
|
||||
give.c
|
||||
items.c
|
||||
laws.c
|
||||
luck.c
|
||||
market.c
|
||||
monster.c
|
||||
randenc.c
|
||||
report.c
|
||||
spells.c
|
||||
spy.c
|
||||
study.c
|
||||
summary.c
|
||||
xmlreport.c
|
||||
;
|
||||
|
||||
Library gamecode : $(SOURCES) ;
|
165
src/common/gamecode/archetype.c
Normal file
165
src/common/gamecode/archetype.c
Normal file
|
@ -0,0 +1,165 @@
|
|||
#include <config.h>
|
||||
#include <kernel/eressea.h>
|
||||
#include "archetype.h"
|
||||
|
||||
/* kernel includes */
|
||||
#include <kernel/equipment.h>
|
||||
#include <kernel/building.h>
|
||||
#include <kernel/xmlkernel.h>
|
||||
#include <kernel/xmlreader.h>
|
||||
|
||||
/* util includes */
|
||||
#include <util/attrib.h>
|
||||
#include <util/umlaut.h>
|
||||
#include <util/language.h>
|
||||
#include <util/xml.h>
|
||||
#include <util/functions.h>
|
||||
|
||||
/* libxml includes */
|
||||
#include <libxml/tree.h>
|
||||
#include <libxml/xpath.h>
|
||||
#include <libxml/encoding.h>
|
||||
|
||||
/* libc includes */
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
static struct archetype * archetypes;
|
||||
|
||||
struct attrib_type at_recruit = {
|
||||
"recruit", NULL, NULL, NULL, NULL, NULL, ATF_UNIQUE
|
||||
};
|
||||
|
||||
const struct archetype *
|
||||
find_archetype(const char * s, const struct locale * lang)
|
||||
{
|
||||
struct tnode * tokens = get_translations(lang, UT_ARCHETYPES);
|
||||
variant token;
|
||||
|
||||
if (findtoken(tokens, s, &token)==E_TOK_SUCCESS) {
|
||||
return (const struct archetype *)token.v;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
register_archetype(archetype * arch)
|
||||
{
|
||||
arch->next = archetypes;
|
||||
archetypes = arch;
|
||||
}
|
||||
|
||||
void
|
||||
init_archetypes(void)
|
||||
{
|
||||
const struct locale * lang = locales;
|
||||
for (;lang;lang=nextlocale(lang)) {
|
||||
variant var;
|
||||
archetype * arch = archetypes;
|
||||
struct tnode * tokens = get_translations(lang, UT_ARCHETYPES);
|
||||
for (;arch;arch=arch->next) {
|
||||
const char *s1, *s2;
|
||||
var.v = arch;
|
||||
|
||||
s1 = LOC(lang, arch->name[0]);
|
||||
addtoken(tokens, s1, var);
|
||||
s2 = LOC(lang, arch->name[1]);
|
||||
if (strcmp(s2, s1)!=0) {
|
||||
addtoken(tokens, s2, var);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
parse_archetypes(xmlDocPtr doc)
|
||||
{
|
||||
char zName[64];
|
||||
xmlXPathContextPtr xpath = xmlXPathNewContext(doc);
|
||||
xmlXPathObjectPtr result = xmlXPathEvalExpression(BAD_CAST "/eressea/archetypes/archetype", xpath);
|
||||
xmlNodeSetPtr nodes = result->nodesetval;
|
||||
|
||||
xmlChar * propValue;
|
||||
if (nodes) {
|
||||
int i;
|
||||
for (i=0;i!=nodes->nodeNr;++i) {
|
||||
xmlNodePtr node = nodes->nodeTab[i];
|
||||
xmlNodePtr child;
|
||||
archetype * arch = calloc(1, sizeof(archetype));
|
||||
xmlXPathObjectPtr sub;
|
||||
|
||||
propValue = xmlGetProp(node, BAD_CAST "name");
|
||||
assert(propValue!=NULL);
|
||||
arch->name[0] = strdup((const char *)propValue);
|
||||
sprintf(zName, "%s_p", arch->name[0]);
|
||||
arch->name[1] = strdup(zName);
|
||||
xmlFree(propValue);
|
||||
|
||||
propValue = xmlGetProp(node, BAD_CAST "equip");
|
||||
if (propValue!=NULL) {
|
||||
arch->equip = get_equipment((const char*)propValue);
|
||||
xmlFree(propValue);
|
||||
} else {
|
||||
arch->equip = get_equipment(arch->name[0]);
|
||||
}
|
||||
|
||||
propValue = xmlGetProp(node, BAD_CAST "building");
|
||||
if (propValue!=NULL) {
|
||||
arch->btype = bt_find((const char*)propValue);
|
||||
xmlFree(propValue);
|
||||
}
|
||||
|
||||
arch->size = xml_ivalue(node, "cost", 0);
|
||||
|
||||
for (child=node->children;child;child=child->next) {
|
||||
if (strcmp((const char *)child->name, "function")==0) {
|
||||
xmlChar * propName = xmlGetProp(child, BAD_CAST "name");
|
||||
xmlChar * propValue = xmlGetProp(child, BAD_CAST "value");
|
||||
if (strcmp((const char *)propName, "create")) {
|
||||
pf_generic foo = get_function((const char *)propValue);
|
||||
arch->exec = (archetype_function)foo;
|
||||
}
|
||||
xmlFree(propValue);
|
||||
xmlFree(propName);
|
||||
}
|
||||
}
|
||||
xpath->node = node;
|
||||
sub = xmlXPathEvalExpression(BAD_CAST "allow|deny", xpath);
|
||||
if (sub->nodesetval && sub->nodesetval->nodeNr) {
|
||||
int k;
|
||||
arch->rules = calloc(sub->nodesetval->nodeNr+1, sizeof(rule));
|
||||
for (k=0;k!=sub->nodesetval->nodeNr;++k) {
|
||||
xmlNodePtr rule = sub->nodesetval->nodeTab[k];
|
||||
arch->rules[k].allow = (rule->name[0]=='a');
|
||||
|
||||
propValue = xmlGetProp(rule, BAD_CAST "property");
|
||||
arch->rules[k].property = strdup((const char *)propValue);
|
||||
xmlFree(propValue);
|
||||
|
||||
propValue = xmlGetProp(rule, BAD_CAST "value");
|
||||
arch->rules[k].value = strdup((const char *)propValue);
|
||||
xmlFree(propValue);
|
||||
}
|
||||
}
|
||||
xmlXPathFreeObject(sub);
|
||||
|
||||
xpath->node = node;
|
||||
sub = xmlXPathEvalExpression(BAD_CAST "construction", xpath);
|
||||
if (sub->nodesetval) {
|
||||
xml_readconstruction(xpath, sub->nodesetval, &arch->ctype);
|
||||
}
|
||||
xmlXPathFreeObject(sub);
|
||||
register_archetype(arch);
|
||||
}
|
||||
}
|
||||
xmlXPathFreeObject(result);
|
||||
|
||||
xmlXPathFreeContext(xpath);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
register_archetypes(void)
|
||||
{
|
||||
xml_register_callback(parse_archetypes);
|
||||
}
|
51
src/common/gamecode/archetype.h
Normal file
51
src/common/gamecode/archetype.h
Normal file
|
@ -0,0 +1,51 @@
|
|||
/* vi: set ts=2:
|
||||
+-------------------+
|
||||
| | Enno Rehling <enno@eressea.de>
|
||||
| Eressea PBEM host | Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
| (c) 1998 - 2007 | Katja Zedel <katze@felidae.kn-bremen.de>
|
||||
| | Henning Peters <faroul@beyond.kn-bremen.de>
|
||||
+-------------------+
|
||||
|
||||
This program may not be used, modified or distributed
|
||||
without prior permission by the authors of Eressea.
|
||||
*/
|
||||
|
||||
#ifndef H_GC_ARCHETYPE
|
||||
#define H_GC_ARCHETYPE
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct rule {
|
||||
boolean allow;
|
||||
char * property;
|
||||
char * value;
|
||||
} rule;
|
||||
|
||||
struct archetype;
|
||||
typedef int (*archetype_function)(struct unit * u, const struct archetype *, int);
|
||||
|
||||
typedef struct archetype {
|
||||
struct archetype * next;
|
||||
char * name[2];
|
||||
int size;
|
||||
struct building_type * btype;
|
||||
struct equipment * equip;
|
||||
struct construction * ctype;
|
||||
struct rule * rules;
|
||||
archetype_function exec;
|
||||
} archetype;
|
||||
|
||||
extern const struct archetype * find_archetype(const char * s, const struct locale * lang);
|
||||
extern void init_archetypes(void);
|
||||
extern void register_archetype(struct archetype * arch);
|
||||
extern void register_archetypes(void);
|
||||
|
||||
extern struct attrib_type at_recruit;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
76
src/common/gamecode/creation.c
Normal file
76
src/common/gamecode/creation.c
Normal file
|
@ -0,0 +1,76 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
*
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2003
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
* Henning Peters (faroul@beyond.kn-bremen.de)
|
||||
* Enno Rehling (enno@eressea.de)
|
||||
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
|
||||
*
|
||||
* based on:
|
||||
*
|
||||
* Atlantis v1.0 13 September 1993 Copyright 1993 by Russell Wallace
|
||||
* Atlantis v1.7 Copyright 1996 by Alex Schröder
|
||||
*
|
||||
* This program may not be used, modified or distributed without
|
||||
* prior permission by the authors of Eressea.
|
||||
* This program may not be sold or used commercially without prior written
|
||||
* permission from the authors.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <kernel/eressea.h>
|
||||
#include "creation.h"
|
||||
#include "monster.h"
|
||||
|
||||
/* kernel includes */
|
||||
#include <kernel/alchemy.h>
|
||||
#include <kernel/build.h>
|
||||
#include <kernel/faction.h>
|
||||
#include <kernel/item.h>
|
||||
#include <kernel/magic.h>
|
||||
#include <kernel/plane.h>
|
||||
#include <kernel/race.h>
|
||||
#include <kernel/region.h>
|
||||
#include <kernel/save.h>
|
||||
#include <kernel/ship.h>
|
||||
#include <kernel/terrain.h>
|
||||
#include <kernel/unit.h>
|
||||
|
||||
/* util includes */
|
||||
#include <util/goodies.h>
|
||||
#include <util/lists.h>
|
||||
|
||||
/* libc includes */
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
#include <float.h>
|
||||
#include <limits.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
faction *
|
||||
createmonsters(int no)
|
||||
{
|
||||
faction *f = findfaction(no);
|
||||
|
||||
if (f) {
|
||||
puts("* Fehler! Die Monster Partei gibt es schon.");
|
||||
return f;
|
||||
}
|
||||
f = (faction *) calloc(1, sizeof(faction));
|
||||
f->no = no;
|
||||
/* alles ist auf null gesetzt, ausser dem folgenden. achtung - partei
|
||||
* no 0 muss keine orders einreichen! */
|
||||
|
||||
f->email = strdup("monsters@eressea.de");
|
||||
f->name = strdup("Monster");
|
||||
f->alive = 1;
|
||||
f->options = (char)(1<<O_REPORT);
|
||||
addlist(&factions, f);
|
||||
fhash(f);
|
||||
return f;
|
||||
}
|
25
src/common/gamecode/creation.h
Normal file
25
src/common/gamecode/creation.h
Normal file
|
@ -0,0 +1,25 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
*
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2007
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
* Henning Peters (faroul@beyond.kn-bremen.de)
|
||||
* Enno Rehling (enno@eressea.de)
|
||||
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
|
||||
*
|
||||
* This program may not be used, modified or distributed without
|
||||
* prior permission by the authors of Eressea.
|
||||
*/
|
||||
#ifndef H_GC_CREATION
|
||||
#define H_GC_CREATION
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct faction * createmonsters(int no);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
1611
src/common/gamecode/creport.c
Normal file
1611
src/common/gamecode/creport.c
Normal file
File diff suppressed because it is too large
Load diff
29
src/common/gamecode/creport.h
Normal file
29
src/common/gamecode/creport.h
Normal file
|
@ -0,0 +1,29 @@
|
|||
/* vi: set ts=2:
|
||||
+-------------------+ Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
| | Enno Rehling <enno@eressea.de>
|
||||
| Eressea PBEM host | Katja Zedel <katze@felidae.kn-bremen.de>
|
||||
| (c) 1998 - 2003 | Henning Peters <faroul@beyond.kn-bremen.de>
|
||||
| | Ingo Wilken <Ingo.Wilken@informatik.uni-oldenburg.de>
|
||||
+-------------------+ Stefan Reich <reich@halbling.de>
|
||||
|
||||
This program may not be used, modified or distributed
|
||||
without prior permission by the authors of Eressea.
|
||||
*/
|
||||
#ifndef H_GC_CREPORT
|
||||
#define H_GC_CREPORT
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <time.h>
|
||||
|
||||
extern void creport_cleanup(void);
|
||||
extern void creport_init(void);
|
||||
|
||||
extern int crwritemap(const char * filename);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
3489
src/common/gamecode/economy.c
Normal file
3489
src/common/gamecode/economy.c
Normal file
File diff suppressed because it is too large
Load diff
63
src/common/gamecode/economy.h
Normal file
63
src/common/gamecode/economy.h
Normal file
|
@ -0,0 +1,63 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
*
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2003
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
* Henning Peters (faroul@beyond.kn-bremen.de)
|
||||
* Enno Rehling (enno@eressea.de)
|
||||
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
|
||||
*
|
||||
* based on:
|
||||
*
|
||||
* Atlantis v1.0 13 September 1993 Copyright 1993 by Russell Wallace
|
||||
* Atlantis v1.7 Copyright 1996 by Alex Schröder
|
||||
*
|
||||
* This program may not be used, modified or distributed without
|
||||
* prior permission by the authors of Eressea.
|
||||
* This program may not be sold or used commercially without prior written
|
||||
* permission from the authors.
|
||||
*/
|
||||
|
||||
#ifndef H_GC_ECONOMY
|
||||
#define H_GC_ECONOMY
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Welchen Teil des Silbers die Bauern fuer Unterhaltung ausgeben (1/20), und
|
||||
* wiviel Silber ein Unterhalter pro Talentpunkt bekommt. */
|
||||
|
||||
/* Wieviele Silbermuenzen jeweils auf einmal "getaxed" werden. */
|
||||
|
||||
#define TAXFRACTION 10
|
||||
|
||||
/* Wieviel Silber pro Talentpunkt geklaut wird. */
|
||||
|
||||
#define STEALINCOME 50
|
||||
|
||||
/* Teil der Bauern, welche Luxusgueter kaufen und verkaufen (1/100). */
|
||||
|
||||
#define TRADE_FRACTION 100
|
||||
|
||||
extern int income(const struct unit * u);
|
||||
|
||||
/* Wieviel Fremde eine Partei pro Woche aufnehmen kann */
|
||||
#define MAXNEWBIES 5
|
||||
|
||||
void economics(struct region *r);
|
||||
void produce(struct region *r);
|
||||
void auto_work(struct region * r);
|
||||
|
||||
enum { IC_WORK, IC_ENTERTAIN, IC_TAX, IC_TRADE, IC_TRADETAX, IC_STEAL, IC_MAGIC };
|
||||
void maintain_buildings(struct region * r, boolean crash);
|
||||
extern void add_spende(struct faction * f1, struct faction * f2, int betrag, struct region * r);
|
||||
extern int make_cmd(struct unit * u, struct order * ord);
|
||||
extern void split_allocations(struct region * r);
|
||||
extern int recruit_archetypes(void);
|
||||
extern int give_control_cmd(struct unit * u, struct order * ord);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
431
src/common/gamecode/give.c
Normal file
431
src/common/gamecode/give.c
Normal file
|
@ -0,0 +1,431 @@
|
|||
/* vi: set ts=2:
|
||||
+-------------------+ Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
| | Enno Rehling <enno@eressea.de>
|
||||
| Eressea PBEM host | Katja Zedel <katze@felidae.kn-bremen.de>
|
||||
| (c) 1998 - 2003 | Henning Peters <faroul@beyond.kn-bremen.de>
|
||||
| | Ingo Wilken <Ingo.Wilken@informatik.uni-oldenburg.de>
|
||||
+-------------------+ Stefan Reich <reich@halbling.de>
|
||||
|
||||
This program may not be used, modified or distributed
|
||||
without prior permission by the authors of Eressea.
|
||||
|
||||
*/
|
||||
#include <config.h>
|
||||
#include <kernel/eressea.h>
|
||||
#include "give.h"
|
||||
|
||||
#include "economy.h"
|
||||
|
||||
/* kernel includes */
|
||||
#include <kernel/faction.h>
|
||||
#include <kernel/item.h>
|
||||
#include <kernel/magic.h>
|
||||
#include <kernel/message.h>
|
||||
#include <kernel/order.h>
|
||||
#include <kernel/pool.h>
|
||||
#include <kernel/race.h>
|
||||
#include <kernel/region.h>
|
||||
#include <kernel/reports.h>
|
||||
#include <kernel/ship.h>
|
||||
#include <kernel/skill.h>
|
||||
#include <kernel/terrain.h>
|
||||
#include <kernel/unit.h>
|
||||
|
||||
/* attributes includes */
|
||||
#include <attributes/racename.h>
|
||||
#include <attributes/orcification.h>
|
||||
|
||||
/* util includes */
|
||||
#include <util/attrib.h>
|
||||
#include <util/base36.h>
|
||||
#include <util/event.h>
|
||||
#include <util/log.h>
|
||||
|
||||
/* libc includes */
|
||||
#include <assert.h>
|
||||
#include <limits.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/* Wieviel Fremde eine Partei pro Woche aufnehmen kangiven */
|
||||
#define MAXNEWBIES 5
|
||||
#define RESERVE_DONATIONS /* shall we reserve objects given to us by other factions? */
|
||||
#define RESERVE_GIVE /* reserve anything that's given from one unit to another? */
|
||||
|
||||
|
||||
static int
|
||||
GiveRestriction(void) {
|
||||
static int value = -1;
|
||||
if (value<0) {
|
||||
const char * str = get_param(global.parameters, "GiveRestriction");
|
||||
value = str?atoi(str):0;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
static void
|
||||
add_give(unit * u, unit * u2, int given, int received, const resource_type * rtype, struct order * ord, int error)
|
||||
{
|
||||
if (error) {
|
||||
cmistake(u, ord, error, MSG_COMMERCE);
|
||||
}
|
||||
else if (u2==NULL) {
|
||||
ADDMSG(&u->faction->msgs,
|
||||
msg_message("give_peasants", "unit resource amount",
|
||||
u, rtype, given));
|
||||
} else if (u2->faction!=u->faction) {
|
||||
message * msg;
|
||||
|
||||
msg = msg_message("give", "unit target resource amount", u, u2, rtype, given);
|
||||
add_message(&u->faction->msgs, msg);
|
||||
msg_release(msg);
|
||||
|
||||
msg = msg_message("receive", "unit target resource amount", u, u2, rtype, received);
|
||||
add_message(&u2->faction->msgs, msg);
|
||||
msg_release(msg);
|
||||
}
|
||||
}
|
||||
|
||||
static boolean
|
||||
limited_give(const item_type * type)
|
||||
{
|
||||
/* trade only money 2:1, if at all */
|
||||
return (type == i_silver);
|
||||
}
|
||||
|
||||
int give_quota(const unit * src, const unit * dst, const item_type * type, int n)
|
||||
{
|
||||
static float divisor = -1;
|
||||
|
||||
if (divisor==0 || !limited_give(type)) {
|
||||
return n;
|
||||
}
|
||||
if (dst && src && src->faction!=dst->faction) {
|
||||
if (divisor<0) {
|
||||
divisor = get_param_flt(global.parameters, "rules.items.give_divisor", 1);
|
||||
assert(divisor==0 || divisor>=1);
|
||||
}
|
||||
if (divisor>=1) {
|
||||
/* predictable > correct: */
|
||||
int x = (int)(n/divisor);
|
||||
return x;
|
||||
}
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
int
|
||||
give_item(int want, const item_type * itype, unit * src, unit * dest, struct order * ord)
|
||||
{
|
||||
short error = 0;
|
||||
int n, r;
|
||||
|
||||
assert(itype!=NULL);
|
||||
n = get_pooled(src, item2resource(itype), GET_DEFAULT, want);
|
||||
n = MIN(want, n);
|
||||
r = n;
|
||||
if (dest && src->faction != dest->faction && src->faction->age < GiveRestriction()) {
|
||||
if (ord!=NULL) {
|
||||
ADDMSG(&src->faction->msgs, msg_feedback(src, ord, "giverestriction",
|
||||
"turns", GiveRestriction()));
|
||||
}
|
||||
return -1;
|
||||
} else if (n == 0) {
|
||||
int reserve = get_reservation(src, itype->rtype);
|
||||
if (reserve) {
|
||||
msg_feedback(src, ord, "nogive_reserved", "resource reservation",
|
||||
itype->rtype, reserve);
|
||||
return -1;
|
||||
}
|
||||
error = 36;
|
||||
} else if (itype->flags & ITF_CURSED) {
|
||||
error = 25;
|
||||
} else if (itype->give==NULL || itype->give(src, dest, itype, n, ord)!=0) {
|
||||
int use = use_pooled(src, item2resource(itype), GET_SLACK, n);
|
||||
if (use<n) use += use_pooled(src, item2resource(itype), GET_RESERVE|GET_POOLED_SLACK, n-use);
|
||||
if (dest) {
|
||||
r = give_quota(src, dest, itype, n);
|
||||
i_change(&dest->items, itype, r);
|
||||
#ifdef RESERVE_GIVE
|
||||
#ifdef RESERVE_DONATIONS
|
||||
change_reservation(dest, item2resource(itype), r);
|
||||
#else
|
||||
if (src->faction==dest->faction) {
|
||||
change_reservation(dest, item2resource(itype), r);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#if MUSEUM_MODULE && defined(TODO)
|
||||
/* TODO: use a trigger for the museum warden! */
|
||||
if (a_find(dest->attribs, &at_warden)) {
|
||||
warden_add_give(src, dest, itype, r);
|
||||
}
|
||||
#endif
|
||||
handle_event(dest->attribs, "receive", src);
|
||||
}
|
||||
handle_event(src->attribs, "give", dest);
|
||||
}
|
||||
add_give(src, dest, n, r, item2resource(itype), ord, error);
|
||||
if (error) return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
give_men(int n, unit * u, unit * u2, struct order * ord)
|
||||
{
|
||||
ship *sh;
|
||||
int k = 0;
|
||||
int error = 0;
|
||||
|
||||
if (u2 && u->faction != u2->faction && u->faction->age < GiveRestriction()) {
|
||||
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "giverestriction",
|
||||
"turns", GiveRestriction()));
|
||||
return;
|
||||
} else if (u == u2) {
|
||||
error = 10;
|
||||
} else if (!u2 && u->race == new_race[RC_SNOTLING]) {
|
||||
/* snotlings may not be given to the peasants. */
|
||||
error = 307;
|
||||
} else if (u2 && u2->number && (fval(u, UFL_HERO) != fval(u2, UFL_HERO))) {
|
||||
/* heroes may not be given to non-heroes and vice versa*/
|
||||
error = 75;
|
||||
} else if (unit_has_cursed_item(u) || (u2 && unit_has_cursed_item(u2))) {
|
||||
error = 78;
|
||||
} else if (fval(u, UFL_LOCKED) || is_cursed(u->attribs, C_SLAVE, 0)) {
|
||||
error = 74;
|
||||
} else if (u2 && fval(u, UFL_HUNGER)) {
|
||||
/* hungry people cannot be given away */
|
||||
error = 73;
|
||||
} else if (u2 && (fval(u2, UFL_LOCKED)|| is_cursed(u2->attribs, C_SLAVE, 0))) {
|
||||
error = 75;
|
||||
} else if (u2 && u2->faction != u->faction && !alliedunit(u2, u->faction, HELP_GIVE) && !ucontact(u2, u)) {
|
||||
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "feedback_no_contact", "target", u2));
|
||||
error = -1;
|
||||
} else if (u2 && (has_skill(u, SK_MAGIC) || has_skill(u2, SK_MAGIC))) {
|
||||
/* cannot give units to and from magicians */
|
||||
error = 158;
|
||||
} else if (u2 && (fval(u, UFL_WERE) != fval(u2, UFL_WERE))) {
|
||||
/* werewolves can't be given to non-werewolves and vice-versa */
|
||||
error = 312;
|
||||
} else if (u2 && u2->number!=0 && u2->race != u->race) {
|
||||
log_warning(("faction %s attempts to give %s to %s.\n",
|
||||
itoa36(u->faction->no), u->race->_name[0],
|
||||
u2->race->_name[1]));
|
||||
error = 139;
|
||||
} else if (u2!=NULL && (get_racename(u2->attribs) || get_racename(u->attribs))) {
|
||||
error = 139;
|
||||
} else {
|
||||
if (n > u->number) n = u->number;
|
||||
if (u2 && n+u2->number > UNIT_MAXSIZE) {
|
||||
n = UNIT_MAXSIZE-u2->number;
|
||||
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "error_unit_size", "maxsize", UNIT_MAXSIZE));
|
||||
assert(n>=0);
|
||||
}
|
||||
if (n == 0) {
|
||||
error = 96;
|
||||
} else if (u2 && u->faction != u2->faction) {
|
||||
if (u2->faction->newbies + n > MAXNEWBIES) {
|
||||
error = 129;
|
||||
} else if (u->race != u2->faction->race) {
|
||||
if (u2->faction->race != new_race[RC_HUMAN]) {
|
||||
error = 120;
|
||||
} else if (count_migrants(u2->faction) + n > count_maxmigrants(u2->faction)) {
|
||||
error = 128;
|
||||
}
|
||||
else if (has_limited_skills(u) || has_limited_skills(u2)) {
|
||||
error = 154;
|
||||
} else if (u2->number!=0) {
|
||||
error = 139;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (u2 && (has_skill(u, SK_ALCHEMY) || has_skill(u2, SK_ALCHEMY))) {
|
||||
k = count_skill(u2->faction, SK_ALCHEMY);
|
||||
|
||||
/* Falls die Zieleinheit keine Alchemisten sind, werden sie nun
|
||||
* welche. */
|
||||
if (!has_skill(u2, SK_ALCHEMY) && has_skill(u, SK_ALCHEMY))
|
||||
k += u2->number;
|
||||
|
||||
/* Wenn in eine Alchemisteneinheit Personen verschoben werden */
|
||||
if (has_skill(u2, SK_ALCHEMY) && !has_skill(u, SK_ALCHEMY))
|
||||
k += n;
|
||||
|
||||
/* Wenn Parteigrenzen überschritten werden */
|
||||
if (u2->faction != u->faction)
|
||||
k += n;
|
||||
|
||||
/* wird das Alchemistenmaximum ueberschritten ? */
|
||||
|
||||
if (k > skill_limit(u2->faction, SK_ALCHEMY)) {
|
||||
error = 156;
|
||||
}
|
||||
}
|
||||
|
||||
if (error==0) {
|
||||
if (u2 && u2->number == 0) {
|
||||
set_racename(&u2->attribs, get_racename(u->attribs));
|
||||
u2->race = u->race;
|
||||
u2->irace = u->irace;
|
||||
if (fval(u, UFL_HERO)) fset(u2, UFL_HERO);
|
||||
else freset(u2, UFL_HERO);
|
||||
}
|
||||
|
||||
if (u2) {
|
||||
if (u2->number!=0 && recruit_archetypes()) {
|
||||
/* must have same set of skills */
|
||||
boolean okay = false;
|
||||
if (u->skill_size==u2->skill_size) {
|
||||
int i;
|
||||
for (i=0;i!=u->skill_size;++i) {
|
||||
int j;
|
||||
for (j=0;j!=u2->skill_size;++j) {
|
||||
if (u->skills[i].id==u2->skills[j].id) break;
|
||||
}
|
||||
if (j!=u2->skill_size) break;
|
||||
}
|
||||
if (i==u->skill_size) okay = true;
|
||||
}
|
||||
if (!okay) {
|
||||
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "give_cannot_merge", ""));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Einheiten von Schiffen können nicht NACH in von
|
||||
* Nicht-alliierten bewachten Regionen ausführen */
|
||||
sh = leftship(u);
|
||||
if (sh) set_leftship(u2, sh);
|
||||
|
||||
transfermen(u, u2, n);
|
||||
if (u->faction != u2->faction) {
|
||||
u2->faction->newbies += n;
|
||||
}
|
||||
} else {
|
||||
if (getunitpeasants) {
|
||||
#ifdef ORCIFICATION
|
||||
if (u->race == new_race[RC_ORC] && !fval(u->region, RF_ORCIFIED)) {
|
||||
attrib *a = a_find(u->region->attribs, &at_orcification);
|
||||
if (!a) a = a_add(&u->region->attribs, a_new(&at_orcification));
|
||||
a->data.i += n;
|
||||
}
|
||||
#endif
|
||||
transfermen(u, NULL, n);
|
||||
} else {
|
||||
error = 159;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (error>0) {
|
||||
cmistake(u, ord, error, MSG_COMMERCE);
|
||||
} else if (!u2) {
|
||||
ADDMSG(&u->faction->msgs,
|
||||
msg_message("give_person_peasants", "unit amount", u, n));
|
||||
} else if (u2->faction!=u->faction) {
|
||||
message * msg = msg_message("give_person", "unit target amount", u, u2, n);
|
||||
add_message(&u->faction->msgs, msg);
|
||||
add_message(&u2->faction->msgs, msg);
|
||||
msg_release(msg);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
give_unit(unit * u, unit * u2, order * ord)
|
||||
{
|
||||
region * r = u->region;
|
||||
int n = u->number;
|
||||
|
||||
if (u && unit_has_cursed_item(u)) {
|
||||
cmistake(u, ord, 78, MSG_COMMERCE);
|
||||
return;
|
||||
}
|
||||
|
||||
if (fval(u, UFL_HERO)) {
|
||||
cmistake(u, ord, 75, MSG_COMMERCE);
|
||||
return;
|
||||
}
|
||||
if (fval(u, UFL_LOCKED) || fval(u, UFL_HUNGER)) {
|
||||
cmistake(u, ord, 74, MSG_COMMERCE);
|
||||
return;
|
||||
}
|
||||
|
||||
if (u2 == NULL) {
|
||||
if (fval(r->terrain, SEA_REGION)) {
|
||||
cmistake(u, ord, 152, MSG_COMMERCE);
|
||||
} else if (getunitpeasants) {
|
||||
unit *u3;
|
||||
|
||||
for(u3 = r->units; u3; u3 = u3->next)
|
||||
if(u3->faction == u->faction && u != u3) break;
|
||||
|
||||
if(u3) {
|
||||
while (u->items) {
|
||||
item * iold = i_remove(&u->items, u->items);
|
||||
item * inew = *i_find(&u3->items, iold->type);
|
||||
if (inew==NULL) i_add(&u3->items, iold);
|
||||
else {
|
||||
inew->number += iold->number;
|
||||
i_free(iold);
|
||||
}
|
||||
}
|
||||
}
|
||||
give_men(u->number, u, NULL, ord);
|
||||
cmistake(u, ord, 153, MSG_COMMERCE);
|
||||
} else {
|
||||
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "feedback_unit_not_found", ""));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (!alliedunit(u2, u->faction, HELP_GIVE) && ucontact(u2, u) == 0) {
|
||||
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "feedback_no_contact", "target", u2));
|
||||
return;
|
||||
}
|
||||
if (u->number == 0) {
|
||||
cmistake(u, ord, 105, MSG_COMMERCE);
|
||||
return;
|
||||
}
|
||||
if (u2->faction->newbies + n > MAXNEWBIES) {
|
||||
cmistake(u, ord, 129, MSG_COMMERCE);
|
||||
return;
|
||||
}
|
||||
if (u->race != u2->faction->race) {
|
||||
if (u2->faction->race != new_race[RC_HUMAN]) {
|
||||
cmistake(u, ord, 120, MSG_COMMERCE);
|
||||
return;
|
||||
}
|
||||
if (count_migrants(u2->faction) + u->number > count_maxmigrants(u2->faction)) {
|
||||
cmistake(u, ord, 128, MSG_COMMERCE);
|
||||
return;
|
||||
}
|
||||
if (has_limited_skills(u)) {
|
||||
cmistake(u, ord, 154, MSG_COMMERCE);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (has_skill(u, SK_MAGIC)) {
|
||||
sc_mage * mage;
|
||||
if (count_skill(u2->faction, SK_MAGIC) + u->number >
|
||||
skill_limit(u2->faction, SK_MAGIC))
|
||||
{
|
||||
cmistake(u, ord, 155, MSG_COMMERCE);
|
||||
return;
|
||||
}
|
||||
mage = get_mage(u);
|
||||
if (!mage || u2->faction->magiegebiet != mage->magietyp) {
|
||||
cmistake(u, ord, 157, MSG_COMMERCE);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (has_skill(u, SK_ALCHEMY)
|
||||
&& count_skill(u2->faction, SK_ALCHEMY) + u->number >
|
||||
skill_limit(u2->faction, SK_ALCHEMY))
|
||||
{
|
||||
cmistake(u, ord, 156, MSG_COMMERCE);
|
||||
return;
|
||||
}
|
||||
add_give(u, u2, 1, 1, r_unit, ord, 0);
|
||||
u_setfaction(u, u2->faction);
|
||||
u2->faction->newbies += n;
|
||||
}
|
26
src/common/gamecode/give.h
Normal file
26
src/common/gamecode/give.h
Normal file
|
@ -0,0 +1,26 @@
|
|||
/* vi: set ts=2:
|
||||
+-------------------+ Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
| | Enno Rehling <enno@eressea.de>
|
||||
| Eressea PBEM host | Katja Zedel <katze@felidae.kn-bremen.de>
|
||||
| (c) 1998 - 2003 | Henning Peters <faroul@beyond.kn-bremen.de>
|
||||
| | Ingo Wilken <Ingo.Wilken@informatik.uni-oldenburg.de>
|
||||
+-------------------+ Stefan Reich <reich@halbling.de>
|
||||
|
||||
This program may not be used, modified or distributed
|
||||
without prior permission by the authors of Eressea.
|
||||
|
||||
*/
|
||||
#ifndef H_GC_GIVE
|
||||
#define H_GC_GIVE
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern int give_item(int want, const struct item_type * itype, struct unit * src, struct unit * dest, struct order * ord);
|
||||
extern void give_men(int n, struct unit * u, struct unit * u2, struct order * ord);
|
||||
extern void give_unit(struct unit * u, struct unit * u2, struct order * ord);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
262
src/common/gamecode/items.c
Normal file
262
src/common/gamecode/items.c
Normal file
|
@ -0,0 +1,262 @@
|
|||
#include <config.h>
|
||||
#include <kernel/eressea.h>
|
||||
#include "items.h"
|
||||
|
||||
#include "study.h"
|
||||
|
||||
#include <kernel/curse.h>
|
||||
#include <kernel/building.h>
|
||||
#include <kernel/faction.h>
|
||||
#include <kernel/item.h>
|
||||
#include <kernel/magic.h>
|
||||
#include <kernel/message.h>
|
||||
#include <kernel/move.h>
|
||||
#include <kernel/order.h>
|
||||
#include <kernel/plane.h>
|
||||
#include <kernel/pool.h>
|
||||
#include <kernel/region.h>
|
||||
#include <kernel/ship.h>
|
||||
#include <kernel/skill.h>
|
||||
#include <kernel/spell.h>
|
||||
#include <kernel/unit.h>
|
||||
|
||||
#include <items/demonseye.h>
|
||||
|
||||
#include <util/attrib.h>
|
||||
#include <util/parser.h>
|
||||
#include <util/rand.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <limits.h>
|
||||
|
||||
/* BEGIN studypotion */
|
||||
#define MAXGAIN 15
|
||||
static int
|
||||
use_studypotion(struct unit * u, const struct item_type * itype, int amount, struct order * ord)
|
||||
{
|
||||
if (get_keyword(u->thisorder) == K_STUDY) {
|
||||
skill_t sk;
|
||||
skill * sv;
|
||||
|
||||
init_tokens(u->thisorder);
|
||||
skip_token();
|
||||
sk = findskill(getstrtoken(), u->faction->locale);
|
||||
sv = get_skill(u, sk);
|
||||
|
||||
if (sv && sv->level > 2) {
|
||||
/* TODO: message */
|
||||
} else if (study_cost(u, sk)>0) {
|
||||
/* TODO: message */
|
||||
} else {
|
||||
attrib * a = a_find(u->attribs, &at_learning);
|
||||
teaching_info * teach;
|
||||
if (a==NULL) {
|
||||
a = a_add(&u->attribs, a_new(&at_learning));
|
||||
}
|
||||
teach = (teaching_info*) a->data.v;
|
||||
if (amount>MAXGAIN) amount = MAXGAIN;
|
||||
teach->value += amount * 30;
|
||||
if (teach->value > MAXGAIN * 30) {
|
||||
teach->value = MAXGAIN * 30;
|
||||
}
|
||||
i_change(&u->items, itype, -amount);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return EUNUSABLE;
|
||||
}
|
||||
/* END studypotion */
|
||||
|
||||
/* BEGIN speedsail */
|
||||
#define SPEEDSAIL_EFFECT 1
|
||||
static int
|
||||
use_speedsail(struct unit * u, const struct item_type * itype, int amount, struct order * ord)
|
||||
{
|
||||
curse *c;
|
||||
double effect;
|
||||
ship * sh = u->ship;
|
||||
if (!sh) {
|
||||
cmistake(u, ord, 20, MSG_MOVE);
|
||||
return -1;
|
||||
}
|
||||
|
||||
effect = SPEEDSAIL_EFFECT;
|
||||
c = create_curse(u, &sh->attribs, ct_find("shipspeedup"), 20, INT_MAX, effect, 0);
|
||||
c_setflag(c, CURSE_NOAGE);
|
||||
|
||||
ADDMSG(&u->faction->msgs, msg_message("use_speedsail", "unit speed", u, SPEEDSAIL_EFFECT));
|
||||
use_pooled(u, itype->rtype, GET_DEFAULT, 1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
/* END speedsail */
|
||||
|
||||
/* ------------------------------------------------------------- */
|
||||
/* Kann auch von Nichtmagiern benutzt werden, erzeugt eine
|
||||
* Antimagiezone, die zwei Runden bestehen bleibt */
|
||||
static int
|
||||
use_antimagiccrystal(unit * u, const struct item_type * itype, int amount, struct order * ord)
|
||||
{
|
||||
region * r = u->region;
|
||||
const resource_type * rt_crystal = NULL;
|
||||
int i;
|
||||
|
||||
if (rt_crystal == NULL) {
|
||||
rt_crystal = rt_find("antimagic");
|
||||
assert(rt_crystal!=NULL);
|
||||
}
|
||||
for (i=0;i!=amount;++i) {
|
||||
int effect, duration = 2;
|
||||
double force;
|
||||
spell *sp = find_spell(M_NONE, "antimagiczone");
|
||||
attrib ** ap = &r->attribs;
|
||||
unused(ord);
|
||||
assert(sp);
|
||||
|
||||
/* Reduziert die Stärke jedes Spruchs um effect */
|
||||
effect = sp->level;
|
||||
|
||||
/* Hält Sprüche bis zu einem summierten Gesamtlevel von power aus.
|
||||
* Jeder Zauber reduziert die 'Lebenskraft' (vigour) der Antimagiezone
|
||||
* um seine Stufe */
|
||||
force = sp->level * 20; /* Stufe 5 =~ 100 */
|
||||
|
||||
/* Regionszauber auflösen */
|
||||
while (*ap && force > 0) {
|
||||
curse * c;
|
||||
attrib * a = *ap;
|
||||
if (!fval(a->type, ATF_CURSE)) {
|
||||
do { ap = &(*ap)->next; } while (*ap && a->type==(*ap)->type);
|
||||
continue;
|
||||
}
|
||||
c = (curse*)a->data.v;
|
||||
|
||||
/* Immunität prüfen */
|
||||
if (c_flags(c) & CURSE_IMMUNE) {
|
||||
do { ap = &(*ap)->next; } while (*ap && a->type==(*ap)->type);
|
||||
continue;
|
||||
}
|
||||
|
||||
force = destr_curse(c, effect, force);
|
||||
if(c->vigour <= 0) {
|
||||
a_remove(&r->attribs, a);
|
||||
}
|
||||
if(*ap) ap = &(*ap)->next;
|
||||
}
|
||||
|
||||
if (force > 0) {
|
||||
create_curse(u, &r->attribs, ct_find("antimagiczone"), force, duration, effect, 0);
|
||||
}
|
||||
}
|
||||
use_pooled(u, rt_crystal, GET_DEFAULT, amount);
|
||||
ADDMSG(&u->faction->msgs, msg_message("use_antimagiccrystal",
|
||||
"unit region", u, r));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
use_instantartsculpture(struct unit * u, const struct item_type * itype,
|
||||
int amount, struct order * ord)
|
||||
{
|
||||
building *b;
|
||||
|
||||
if(u->region->land == NULL) {
|
||||
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "error_onlandonly", ""));
|
||||
return -1;
|
||||
}
|
||||
|
||||
b = new_building(bt_find("artsculpture"), u->region, u->faction->locale);
|
||||
b->size = 100;
|
||||
|
||||
ADDMSG(&u->region->msgs, msg_message("artsculpture_create", "unit region",
|
||||
u, u->region));
|
||||
|
||||
use_pooled(u, itype->rtype, GET_DEFAULT, 1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
use_instantartacademy(struct unit * u, const struct item_type * itype,
|
||||
int amount, struct order * ord)
|
||||
{
|
||||
building *b;
|
||||
|
||||
if(u->region->land == NULL) {
|
||||
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "error_onlandonly", ""));
|
||||
return -1;
|
||||
}
|
||||
|
||||
b = new_building(bt_find("artacademy"), u->region, u->faction->locale);
|
||||
b->size = 100;
|
||||
|
||||
ADDMSG(&u->region->msgs, msg_message(
|
||||
"artacademy_create", "unit region", u, u->region));
|
||||
|
||||
use_pooled(u, itype->rtype, GET_DEFAULT, 1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define BAGPIPEFRACTION dice_rand("2d4+2")
|
||||
#define BAGPIPEDURATION dice_rand("2d10+4")
|
||||
|
||||
static int
|
||||
use_bagpipeoffear(struct unit * u, const struct item_type * itype,
|
||||
int amount, struct order * ord)
|
||||
{
|
||||
int money;
|
||||
|
||||
if (get_curse(u->region->attribs, ct_find("depression"))) {
|
||||
cmistake(u, ord, 58, MSG_MAGIC);
|
||||
return -1;
|
||||
}
|
||||
|
||||
money = entertainmoney(u->region)/BAGPIPEFRACTION;
|
||||
change_money(u, money);
|
||||
rsetmoney(u->region, rmoney(u->region) - money);
|
||||
|
||||
create_curse(u, &u->region->attribs, ct_find("depression"),
|
||||
20, BAGPIPEDURATION, 0.0, 0);
|
||||
|
||||
ADDMSG(&u->faction->msgs, msg_message("bagpipeoffear_faction",
|
||||
"unit region command money", u, u->region, ord, money));
|
||||
|
||||
ADDMSG(&u->region->msgs, msg_message("bagpipeoffear_region",
|
||||
"unit money", u, money));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
use_aurapotion50(struct unit * u, const struct item_type * itype,
|
||||
int amount, struct order * ord)
|
||||
{
|
||||
if (!is_mage(u)) {
|
||||
cmistake(u, ord, 214, MSG_MAGIC);
|
||||
return -1;
|
||||
}
|
||||
|
||||
change_spellpoints(u, 50);
|
||||
|
||||
ADDMSG(&u->faction->msgs, msg_message("aurapotion50",
|
||||
"unit region command", u, u->region, ord));
|
||||
|
||||
use_pooled(u, itype->rtype, GET_DEFAULT, 1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
register_itemfunctions(void)
|
||||
{
|
||||
register_demonseye();
|
||||
register_item_use(use_antimagiccrystal, "use_antimagiccrystal");
|
||||
register_item_use(use_instantartsculpture, "use_instantartsculpture");
|
||||
register_item_use(use_studypotion, "use_studypotion");
|
||||
register_item_use(use_speedsail, "use_speedsail");
|
||||
register_item_use(use_instantartacademy, "use_instantartacademy");
|
||||
register_item_use(use_bagpipeoffear, "use_bagpipeoffear");
|
||||
register_item_use(use_aurapotion50, "use_aurapotion50");
|
||||
}
|
24
src/common/gamecode/items.h
Normal file
24
src/common/gamecode/items.h
Normal file
|
@ -0,0 +1,24 @@
|
|||
/* vi: set ts=2:
|
||||
+-------------------+ Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
| | Enno Rehling <enno@eressea.de>
|
||||
| Eressea PBEM host | Katja Zedel <katze@felidae.kn-bremen.de>
|
||||
| (c) 1998 - 2003 | Henning Peters <faroul@beyond.kn-bremen.de>
|
||||
| | Ingo Wilken <Ingo.Wilken@informatik.uni-oldenburg.de>
|
||||
+-------------------+ Stefan Reich <reich@halbling.de>
|
||||
|
||||
This program may not be used, modified or distributed
|
||||
without prior permission by the authors of Eressea.
|
||||
*/
|
||||
|
||||
#ifndef H_KRNL_ITEMS
|
||||
#define H_KRNL_ITEMS
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern void register_itemfunctions(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
4238
src/common/gamecode/laws.c
Normal file
4238
src/common/gamecode/laws.c
Normal file
File diff suppressed because it is too large
Load diff
49
src/common/gamecode/laws.h
Normal file
49
src/common/gamecode/laws.h
Normal file
|
@ -0,0 +1,49 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
*
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2003
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
* Henning Peters (faroul@beyond.kn-bremen.de)
|
||||
* Enno Rehling (enno@eressea.de)
|
||||
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
|
||||
*
|
||||
* based on:
|
||||
*
|
||||
* Atlantis v1.0 13 September 1993 Copyright 1993 by Russell Wallace
|
||||
* Atlantis v1.7 Copyright 1996 by Alex Schröder
|
||||
*
|
||||
* This program may not be used, modified or distributed without
|
||||
* prior permission by the authors of Eressea.
|
||||
* This program may not be sold or used commercially without prior written
|
||||
* permission from the authors.
|
||||
*/
|
||||
|
||||
#ifndef H_GC_LAWS
|
||||
#define H_GC_LAWS
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern int writepasswd(void);
|
||||
int getoption(void);
|
||||
int wanderoff(struct region * r, int p);
|
||||
void demographics(void);
|
||||
void last_orders(void);
|
||||
void find_address(void);
|
||||
void update_guards(void);
|
||||
void update_subscriptions(void);
|
||||
void deliverMail(struct faction * f, struct region * r, struct unit * u, const char *s, struct unit * receiver);
|
||||
|
||||
/* eressea-specific. put somewhere else, please. */
|
||||
void processorders(void);
|
||||
extern struct attrib_type at_germs;
|
||||
|
||||
extern int dropouts[2];
|
||||
extern int * age;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
187
src/common/gamecode/luck.c
Normal file
187
src/common/gamecode/luck.c
Normal file
|
@ -0,0 +1,187 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
*
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2003
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
* Henning Peters (faroul@beyond.kn-bremen.de)
|
||||
* Enno Rehling (enno@eressea.de)
|
||||
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
|
||||
*
|
||||
* based on:
|
||||
*
|
||||
* Atlantis v1.0 13 September 1993 Copyright 1993 by Russell Wallace
|
||||
* Atlantis v1.7 Copyright 1996 by Alex Schröder
|
||||
*
|
||||
* This program may not be used, modified or distributed without
|
||||
* prior permission by the authors of Eressea.
|
||||
* This program may not be sold or used commercially without prior written
|
||||
* permission from the authors.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <kernel/eressea.h>
|
||||
|
||||
#include "luck.h"
|
||||
|
||||
/* attributes includes */
|
||||
#include <attributes/racename.h>
|
||||
#include <items/weapons.h>
|
||||
|
||||
#include "economy.h"
|
||||
#include "randenc.h"
|
||||
|
||||
/* kernel include */
|
||||
#include <kernel/unit.h>
|
||||
#include <kernel/faction.h>
|
||||
#include <kernel/item.h>
|
||||
#include <kernel/message.h>
|
||||
#include <kernel/race.h>
|
||||
#include <kernel/pool.h>
|
||||
#include <kernel/region.h>
|
||||
#include <kernel/skill.h>
|
||||
#include <kernel/karma.h>
|
||||
|
||||
/* util includes */
|
||||
#include <util/rand.h>
|
||||
#include <util/rng.h>
|
||||
#include <util/message.h>
|
||||
|
||||
/* libc includes */
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
|
||||
#if KARMA_MODULE
|
||||
|
||||
#define STANDARD_LUCK 0
|
||||
|
||||
static void
|
||||
lucky_silver(const unit *u)
|
||||
{
|
||||
int i = 0, r, max = 0;
|
||||
int luck = fspecial(u->faction, FS_LUCKY);
|
||||
|
||||
do {
|
||||
r = 1 + rng_int()%(10000*(luck+STANDARD_LUCK));
|
||||
if(r > max) max = r;
|
||||
i++;
|
||||
} while(i <= luck);
|
||||
|
||||
i_change(&((unit *)u)->items, i_silver, max);
|
||||
|
||||
ADDMSG(&u->faction->msgs, msg_message("lucky_item",
|
||||
"unit item amount", u, i_silver->rtype, max));
|
||||
}
|
||||
|
||||
typedef struct luckyitem {
|
||||
const char * name;
|
||||
int weight; /* weighting the item */
|
||||
} luckyitem;
|
||||
|
||||
static void
|
||||
lucky_item(const unit *u)
|
||||
{
|
||||
int i = 0, r, max = 0;
|
||||
item_type *itype;
|
||||
int amount;
|
||||
int luck = fspecial(u->faction, FS_LUCKY);
|
||||
/* Das ist schöner so, denke ich... */
|
||||
static int nitems = 0;
|
||||
static int maxweight = 0;
|
||||
struct luckyitem it_list[] = {
|
||||
{ "mallorn", 1 },
|
||||
{ NULL, 0 }
|
||||
};
|
||||
if (nitems==0) {
|
||||
while (it_list[nitems].name) {
|
||||
maxweight +=it_list[nitems].weight;
|
||||
++nitems;
|
||||
}
|
||||
}
|
||||
/* weight is unused */
|
||||
r = rng_int()%nitems;
|
||||
|
||||
do {
|
||||
r = rng_int()%nitems;
|
||||
if(r > max) max = r;
|
||||
i++;
|
||||
} while(i <= luck);
|
||||
|
||||
itype = it_find(it_list[r].name);
|
||||
|
||||
if(luck)
|
||||
amount = 10 + rng_int()%(luck*40) + rng_int()%(luck*40);
|
||||
else
|
||||
amount = 5 + rng_int()%10 +rng_int()%10;
|
||||
|
||||
i_change(&((unit *)u)->items, itype, amount);
|
||||
ADDMSG(&u->faction->msgs, msg_message("lucky_item",
|
||||
"unit item amount", u, itype->rtype, amount));
|
||||
}
|
||||
|
||||
static void
|
||||
lucky_magic_item(const unit *u)
|
||||
{
|
||||
#if defined(__GNUC__) && !defined(__STDC__)
|
||||
item_type *itype;
|
||||
int amount;
|
||||
int luck = fspecial(u->faction, FS_LUCKY);
|
||||
const int n_items = 13;
|
||||
item_type *it_list[] = {
|
||||
olditemtype[I_AMULET_OF_HEALING],
|
||||
olditemtype[I_AMULET_OF_TRUE_SEEING],
|
||||
olditemtype[I_RING_OF_INVISIBILITY],
|
||||
olditemtype[I_RING_OF_POWER],
|
||||
olditemtype[I_FIRESWORD],
|
||||
olditemtype[I_CHASTITY_BELT],
|
||||
olditemtype[I_FEENSTIEFEL],
|
||||
olditemtype[I_ANTIMAGICCRYSTAL],
|
||||
olditemtype[I_RING_OF_NIMBLEFINGER],
|
||||
olditemtype[I_TROLLBELT],
|
||||
olditemtype[I_TACTICCRYSTAL],
|
||||
olditemtype[I_SACK_OF_CONSERVATION],
|
||||
};
|
||||
|
||||
itype = it_list[rng_int()%n_items];
|
||||
amount = 1 + rng_int()%luck;
|
||||
|
||||
i_change(&((unit *)u)->items, itype, amount);
|
||||
ADDMSG(&u->faction->msgs, msg_message("lucky_item",
|
||||
"unit item amount", u, itype->rtype, amount));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
lucky_event(const faction *f)
|
||||
{
|
||||
const unit *u = random_unit_in_faction(f);
|
||||
|
||||
if(!u) return;
|
||||
|
||||
switch(rng_int()%3) {
|
||||
case 0:
|
||||
lucky_silver(u);
|
||||
break;
|
||||
case 1:
|
||||
lucky_item(u);
|
||||
break;
|
||||
case 2:
|
||||
lucky_magic_item(u);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
check_luck(void)
|
||||
{
|
||||
faction *f;
|
||||
|
||||
for(f=factions; f; f=f->next) {
|
||||
if(rng_int()%100 < STANDARD_LUCK+fspecial(f, FS_LUCKY)*8)
|
||||
lucky_event(f);
|
||||
}
|
||||
}
|
||||
#endif /* KARMA_MODULE */
|
35
src/common/gamecode/luck.h
Normal file
35
src/common/gamecode/luck.h
Normal file
|
@ -0,0 +1,35 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
*
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2003
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
* Henning Peters (faroul@beyond.kn-bremen.de)
|
||||
* Enno Rehling (enno@eressea.de)
|
||||
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
|
||||
*
|
||||
* based on:
|
||||
*
|
||||
* Atlantis v1.0 13 September 1993 Copyright 1993 by Russell Wallace
|
||||
* Atlantis v1.7 Copyright 1996 by Alex Schröder
|
||||
*
|
||||
* This program may not be used, modified or distributed without
|
||||
* prior permission by the authors of Eressea.
|
||||
* This program may not be sold or used commercially without prior written
|
||||
* permission from the authors.
|
||||
*/
|
||||
|
||||
#ifndef H_GC_LUCK
|
||||
#define H_GC_LUCK
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern void check_luck(void);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
177
src/common/gamecode/market.c
Normal file
177
src/common/gamecode/market.c
Normal file
|
@ -0,0 +1,177 @@
|
|||
/* vi: set ts=2:
|
||||
+-------------------+ Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
| | Enno Rehling <enno@eressea.de>
|
||||
| Eressea PBEM host | Katja Zedel <katze@felidae.kn-bremen.de>
|
||||
| (c) 1998 - 2003 | Henning Peters <faroul@beyond.kn-bremen.de>
|
||||
| | Ingo Wilken <Ingo.Wilken@informatik.uni-oldenburg.de>
|
||||
+-------------------+ Stefan Reich <reich@halbling.de>
|
||||
|
||||
This program may not be used, modified or distributed
|
||||
without prior permission by the authors of Eressea.
|
||||
|
||||
*/
|
||||
#include <config.h>
|
||||
#include <kernel/eressea.h>
|
||||
#include "market.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include <util/attrib.h>
|
||||
#include <util/rng.h>
|
||||
|
||||
#include <kernel/building.h>
|
||||
#include <kernel/faction.h>
|
||||
#include <kernel/item.h>
|
||||
#include <kernel/message.h>
|
||||
#include <kernel/race.h>
|
||||
#include <kernel/region.h>
|
||||
#include <kernel/unit.h>
|
||||
|
||||
static unsigned int
|
||||
get_markets(region * r, unit ** results, size_t size)
|
||||
{
|
||||
unsigned int n = 0;
|
||||
building * b;
|
||||
static building_type * btype;
|
||||
if (!btype) btype = bt_find("market");
|
||||
if (!btype) return 0;
|
||||
for (b=r->buildings;n<size && b;b=b->next) {
|
||||
if (b->type==btype && (b->flags&BLD_WORKING) && b->size>=b->type->maxsize) {
|
||||
unit * u = building_owner(b);
|
||||
unsigned int i;
|
||||
for (i=0;u && i!=n;++i) {
|
||||
/* only one market per faction */
|
||||
if (results[i]->faction==u->faction) u = NULL;
|
||||
}
|
||||
if (u) {
|
||||
results[n++] = u;
|
||||
}
|
||||
}
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
free_market(attrib * a)
|
||||
{
|
||||
item * items = (item *)a->data.v;
|
||||
i_freeall(&items);
|
||||
a->data.v = 0;
|
||||
}
|
||||
|
||||
attrib_type at_market = {
|
||||
"script",
|
||||
NULL, free_market, NULL,
|
||||
NULL, NULL, ATF_UNIQUE
|
||||
};
|
||||
|
||||
static int rc_luxury_trade(const struct race * rc)
|
||||
{
|
||||
if (rc) {
|
||||
return get_param_int(rc->parameters, "luxury_trade", 1000);
|
||||
}
|
||||
return 1000;
|
||||
}
|
||||
|
||||
static int rc_herb_trade(const struct race * rc)
|
||||
{
|
||||
if (rc) {
|
||||
return get_param_int(rc->parameters, "herb_trade", 500);
|
||||
}
|
||||
return 500;
|
||||
}
|
||||
|
||||
#define MAX_MARKETS 128
|
||||
void do_markets(void)
|
||||
{
|
||||
unit_list * traders = 0;
|
||||
unit * markets[MAX_MARKETS];
|
||||
region * r;
|
||||
for (r=regions;r;r=r->next) {
|
||||
if (r->land) {
|
||||
faction * f = region_get_owner(r);
|
||||
const struct race * rc = f?f->race:NULL;
|
||||
int p = rpeasants(r);
|
||||
int numlux, numherbs;
|
||||
numlux = p/rc_luxury_trade(rc);
|
||||
numherbs = p/rc_herb_trade(rc);
|
||||
if (numlux>0 || numherbs>0) {
|
||||
int d, nmarkets = 0;
|
||||
const item_type * lux = r_luxury(r);
|
||||
const item_type * herb = r->land->herbtype;
|
||||
|
||||
nmarkets += get_markets(r, markets+nmarkets, MAX_MARKETS-nmarkets);
|
||||
for (d=0;d!=MAXDIRECTIONS;++d) {
|
||||
region * r2 = rconnect(r, d);
|
||||
if (r2 && r2->buildings) {
|
||||
nmarkets += get_markets(r2, markets+nmarkets, MAX_MARKETS-nmarkets);
|
||||
}
|
||||
}
|
||||
if (nmarkets) {
|
||||
while (lux && numlux--) {
|
||||
int n = rng_int() % nmarkets;
|
||||
unit * u = markets[n];
|
||||
item * items;
|
||||
attrib * a = a_find(u->attribs, &at_market);
|
||||
if (a==NULL) {
|
||||
unit_list * ulist = malloc(sizeof(unit_list));
|
||||
a = a_add(&u->attribs, a_new(&at_market));
|
||||
ulist->next = traders;
|
||||
ulist->data = u;
|
||||
traders = ulist;
|
||||
}
|
||||
items = (item *)a->data.v;
|
||||
i_change(&items, lux, 1);
|
||||
a->data.v = items;
|
||||
/* give 1 luxury */
|
||||
}
|
||||
while (herb && numherbs--) {
|
||||
int n = rng_int() % nmarkets;
|
||||
unit * u = markets[n];
|
||||
item * items;
|
||||
attrib * a = a_find(u->attribs, &at_market);
|
||||
if (a==NULL) {
|
||||
unit_list * ulist = malloc(sizeof(unit_list));
|
||||
a = a_add(&u->attribs, a_new(&at_market));
|
||||
ulist->next = traders;
|
||||
ulist->data = u;
|
||||
traders = ulist;
|
||||
}
|
||||
items = (item *)a->data.v;
|
||||
i_change(&items, herb, 1);
|
||||
a->data.v = items;
|
||||
/* give 1 herb */
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while (traders) {
|
||||
unit_list * trade = traders;
|
||||
unit * u = trade->data;
|
||||
attrib * a = a_find(u->attribs, &at_market);
|
||||
item * items = a->data.v;
|
||||
|
||||
a->data.v = NULL;
|
||||
while (items) {
|
||||
item * itm = items;
|
||||
items = itm->next;
|
||||
|
||||
if (itm->number) {
|
||||
ADDMSG(&u->faction->msgs, msg_message("buyamount",
|
||||
"unit amount resource", u, itm->number, itm->type->rtype));
|
||||
itm->next = NULL;
|
||||
i_add(&u->items, itm);
|
||||
} else {
|
||||
i_free(itm);
|
||||
}
|
||||
}
|
||||
|
||||
traders = trade->next;
|
||||
|
||||
a_remove(&u->attribs, a);
|
||||
free(trade);
|
||||
}
|
||||
}
|
25
src/common/gamecode/market.h
Normal file
25
src/common/gamecode/market.h
Normal file
|
@ -0,0 +1,25 @@
|
|||
/* vi: set ts=2:
|
||||
+-------------------+ Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
| | Enno Rehling <enno@eressea.de>
|
||||
| Eressea PBEM host | Katja Zedel <katze@felidae.kn-bremen.de>
|
||||
| (c) 1998 - 2003 | Henning Peters <faroul@beyond.kn-bremen.de>
|
||||
| | Ingo Wilken <Ingo.Wilken@informatik.uni-oldenburg.de>
|
||||
+-------------------+ Stefan Reich <reich@halbling.de>
|
||||
|
||||
This program may not be used, modified or distributed
|
||||
without prior permission by the authors of Eressea.
|
||||
|
||||
*/
|
||||
#ifndef H_GC_MARKET
|
||||
#define H_GC_MARKET
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
struct building;
|
||||
|
||||
extern void do_markets(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
1192
src/common/gamecode/monster.c
Normal file
1192
src/common/gamecode/monster.c
Normal file
File diff suppressed because it is too large
Load diff
42
src/common/gamecode/monster.h
Normal file
42
src/common/gamecode/monster.h
Normal file
|
@ -0,0 +1,42 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
*
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2003
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
* Henning Peters (faroul@beyond.kn-bremen.de)
|
||||
* Enno Rehling (enno@eressea.de)
|
||||
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
|
||||
*
|
||||
* based on:
|
||||
*
|
||||
* Atlantis v1.0 13 September 1993 Copyright 1993 by Russell Wallace
|
||||
* Atlantis v1.7 Copyright 1996 by Alex Schröder
|
||||
*
|
||||
* This program may not be used, modified or distributed without
|
||||
* prior permission by the authors of Eressea.
|
||||
* This program may not be sold or used commercially without prior written
|
||||
* permission from the authors.
|
||||
*/
|
||||
|
||||
#ifndef H_GC_MONSTER
|
||||
#define H_GC_MONSTER
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define DRAGON_RANGE 20 /* Max. Distanz zum nächsten Drachenziel */
|
||||
|
||||
void age_illusion(struct unit *u);
|
||||
|
||||
void monsters_kill_peasants(struct unit * u);
|
||||
void plan_monsters(void);
|
||||
struct unit *random_unit(const struct region * r);
|
||||
|
||||
extern void spawn_undead(void);
|
||||
extern void spawn_dragons(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
1313
src/common/gamecode/randenc.c
Normal file
1313
src/common/gamecode/randenc.c
Normal file
File diff suppressed because it is too large
Load diff
34
src/common/gamecode/randenc.h
Normal file
34
src/common/gamecode/randenc.h
Normal file
|
@ -0,0 +1,34 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
*
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2003
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
* Henning Peters (faroul@beyond.kn-bremen.de)
|
||||
* Enno Rehling (enno@eressea.de)
|
||||
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
|
||||
*
|
||||
* based on:
|
||||
*
|
||||
* Atlantis v1.0 13 September 1993 Copyright 1993 by Russell Wallace
|
||||
* Atlantis v1.7 Copyright 1996 by Alex Schröder
|
||||
*
|
||||
* This program may not be used, modified or distributed without
|
||||
* prior permission by the authors of Eressea.
|
||||
* This program may not be sold or used commercially without prior written
|
||||
* permission from the authors.
|
||||
*/
|
||||
|
||||
#ifndef H_GC_RANDENC
|
||||
#define H_GC_RANDENC
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern void encounters(void);
|
||||
extern void randomevents(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
2476
src/common/gamecode/report.c
Normal file
2476
src/common/gamecode/report.c
Normal file
File diff suppressed because it is too large
Load diff
25
src/common/gamecode/report.h
Normal file
25
src/common/gamecode/report.h
Normal file
|
@ -0,0 +1,25 @@
|
|||
/* vi: set ts=2:
|
||||
+-------------------+ Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
| | Enno Rehling <enno@eressea.de>
|
||||
| Eressea PBEM host | Katja Zedel <katze@felidae.kn-bremen.de>
|
||||
| (c) 1998 - 2003 | Henning Peters <faroul@beyond.kn-bremen.de>
|
||||
| | Ingo Wilken <Ingo.Wilken@informatik.uni-oldenburg.de>
|
||||
+-------------------+ Stefan Reich <reich@halbling.de>
|
||||
|
||||
This program may not be used, modified or distributed
|
||||
without prior permission by the authors of Eressea.
|
||||
*/
|
||||
#ifndef H_GC_REPORT
|
||||
#define H_GC_REPORT
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern void report_init(void);
|
||||
extern void report_cleanup(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
127
src/common/gamecode/spells.c
Normal file
127
src/common/gamecode/spells.c
Normal file
|
@ -0,0 +1,127 @@
|
|||
/* vi: set ts=2:
|
||||
* +-------------------+ Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
* | | Enno Rehling <enno@eressea.de>
|
||||
* | Eressea PBEM host | Katja Zedel <katze@felidae.kn-bremen.de>
|
||||
* | (c) 1998 - 2005 |
|
||||
* | | This program may not be used, modified or distributed
|
||||
* +-------------------+ without prior permission by the authors of Eressea.
|
||||
*
|
||||
* This file contains spells that aren't referenced by the kernel. That should
|
||||
* really be most if not all the spells, but they are in spells/spells.c
|
||||
* because it's so much work to get them out of the big array.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <kernel/eressea.h>
|
||||
#include "spy.h"
|
||||
|
||||
#include <kernel/faction.h>
|
||||
#include <kernel/magic.h>
|
||||
#include <kernel/message.h>
|
||||
#include <kernel/region.h>
|
||||
#include <kernel/objtypes.h>
|
||||
#include <kernel/spell.h>
|
||||
#include <kernel/unit.h>
|
||||
|
||||
#include <util/functions.h>
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
/* ------------------------------------------------------------- */
|
||||
/* Name: Plappermaul
|
||||
* Stufe: 4
|
||||
* Gebiet: Cerddor
|
||||
* Kategorie: Einheit
|
||||
*
|
||||
* Wirkung:
|
||||
* Einheit ausspionieren. Gibt auch Zauber und Kampfstatus aus. Wirkt
|
||||
* gegen Magieresistenz. Ist diese zu hoch, so wird der Zauber entdeckt
|
||||
* (Meldung) und der Zauberer erhält nur die Talente, nicht die Werte
|
||||
* der Einheit und auch keine Zauber.
|
||||
*
|
||||
* Flag:
|
||||
* (UNITSPELL | TESTCANSEE)
|
||||
*/
|
||||
static int
|
||||
sp_babbler(castorder *co)
|
||||
{
|
||||
unit *target;
|
||||
region *r = co->rt;
|
||||
unit *mage = co->magician.u;
|
||||
int cast_level = co->level;
|
||||
spellparameter *pa = co->par;
|
||||
message * msg;
|
||||
|
||||
/* wenn kein Ziel gefunden, Zauber abbrechen */
|
||||
if (pa->param[0]->flag == TARGET_NOTFOUND) return 0;
|
||||
|
||||
target = pa->param[0]->data.u;
|
||||
|
||||
if (target->faction == mage->faction) {
|
||||
/* Die Einheit ist eine der unsrigen */
|
||||
cmistake(mage, co->order, 45, MSG_MAGIC);
|
||||
}
|
||||
|
||||
/* Magieresistenz Unit */
|
||||
if (target_resists_magic(mage, target, TYP_UNIT, 0)) {
|
||||
spy_message(5, mage, target);
|
||||
msg = msg_message("babbler_resist", "unit mage", target, mage);
|
||||
} else {
|
||||
spy_message(100, mage, target);
|
||||
msg = msg_message("babbler_effect", "unit", target);
|
||||
}
|
||||
r_addmessage(r, target->faction, msg);
|
||||
msg_release(msg);
|
||||
return cast_level;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------- */
|
||||
/* Name: Traumdeuten
|
||||
* Stufe: 7
|
||||
* Kategorie: Einheit
|
||||
*
|
||||
* Wirkung:
|
||||
* Wirkt gegen Magieresistenz. Spioniert die Einheit aus. Gibt alle
|
||||
* Gegenstände, Talente mit Stufe, Zauber und Kampfstatus an.
|
||||
*
|
||||
* Magieresistenz hier prüfen, wegen Fehlermeldung
|
||||
*
|
||||
* Flag:
|
||||
* (UNITSPELL)
|
||||
*/
|
||||
static int
|
||||
sp_readmind(castorder *co)
|
||||
{
|
||||
unit *target;
|
||||
unit *mage = co->magician.u;
|
||||
int cast_level = co->level;
|
||||
spellparameter *pa = co->par;
|
||||
|
||||
/* wenn kein Ziel gefunden, Zauber abbrechen */
|
||||
if (pa->param[0]->flag == TARGET_NOTFOUND) return 0;
|
||||
|
||||
target = pa->param[0]->data.u;
|
||||
|
||||
if (target->faction == mage->faction) {
|
||||
/* Die Einheit ist eine der unsrigen */
|
||||
cmistake(mage, co->order, 45, MSG_MAGIC);
|
||||
}
|
||||
|
||||
/* Magieresistenz Unit */
|
||||
if (target_resists_magic(mage, target, TYP_UNIT, 0)) {
|
||||
cmistake(mage, co->order, 180, MSG_MAGIC);
|
||||
/* "Fühlt sich beobachtet"*/
|
||||
ADDMSG(&target->faction->msgs, msg_message("stealdetect", "unit", target));
|
||||
return 0;
|
||||
}
|
||||
spy_message(2, mage, target);
|
||||
|
||||
return cast_level;
|
||||
}
|
||||
|
||||
void
|
||||
register_gcspells(void)
|
||||
{
|
||||
register_function((pf_generic)&sp_babbler, "cast_babbler");
|
||||
register_function((pf_generic)&sp_readmind, "cast_readmind");
|
||||
}
|
21
src/common/gamecode/spells.h
Normal file
21
src/common/gamecode/spells.h
Normal file
|
@ -0,0 +1,21 @@
|
|||
/* vi: set ts=2:
|
||||
* +-------------------+ Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
* | | Enno Rehling <enno@eressea.de>
|
||||
* | Eressea PBEM host | Katja Zedel <katze@felidae.kn-bremen.de>
|
||||
* | (c) 1998 - 2007 |
|
||||
* | | This program may not be used, modified or distributed
|
||||
* +-------------------+ without prior permission by the authors of Eressea.
|
||||
*/
|
||||
|
||||
#ifndef GC_SPELLS_H
|
||||
#define GC_SPELLS_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern void register_gcspells(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
561
src/common/gamecode/spy.c
Normal file
561
src/common/gamecode/spy.c
Normal file
|
@ -0,0 +1,561 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
*
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2003
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
* Henning Peters (faroul@beyond.kn-bremen.de)
|
||||
* Enno Rehling (enno@eressea.de)
|
||||
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
|
||||
*
|
||||
* based on:
|
||||
*
|
||||
* Atlantis v1.0 13 September 1993 Copyright 1993 by Russell Wallace
|
||||
* Atlantis v1.7 Copyright 1996 by Alex Schröder
|
||||
*
|
||||
* This program may not be used, modified or distributed without
|
||||
* prior permission by the authors of Eressea.
|
||||
* This program may not be sold or used commercially without prior written
|
||||
* permission from the authors.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <kernel/eressea.h>
|
||||
#include "spy.h"
|
||||
|
||||
/* kernel includes */
|
||||
#include <kernel/build.h>
|
||||
#include <kernel/reports.h>
|
||||
#include <kernel/item.h>
|
||||
#include <kernel/karma.h>
|
||||
#include <kernel/faction.h>
|
||||
#include <kernel/magic.h>
|
||||
#include <kernel/message.h>
|
||||
#include <kernel/move.h>
|
||||
#include <kernel/race.h>
|
||||
#include <kernel/region.h>
|
||||
#include <kernel/ship.h>
|
||||
#include <kernel/skill.h>
|
||||
#include <kernel/terrain.h>
|
||||
#include <kernel/unit.h>
|
||||
|
||||
/* attributes includes */
|
||||
#include <attributes/racename.h>
|
||||
|
||||
/* util includes */
|
||||
#include <util/attrib.h>
|
||||
#include <util/base36.h>
|
||||
#include <util/parser.h>
|
||||
#include <util/rand.h>
|
||||
#include <util/rng.h>
|
||||
|
||||
/* libc includes */
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <attributes/otherfaction.h>
|
||||
|
||||
/* in spy steht der Unterschied zwischen Wahrnehmung des Opfers und
|
||||
* Spionage des Spions */
|
||||
void
|
||||
spy_message(int spy, const unit *u, const unit *target)
|
||||
{
|
||||
const char * str = report_kampfstatus(target, u->faction->locale);
|
||||
|
||||
ADDMSG(&u->faction->msgs, msg_message("spyreport", "spy target status", u, target, str));
|
||||
if (spy > 20) {
|
||||
sc_mage * mage = get_mage(target);
|
||||
/* bei Magiern Zaubersprüche und Magiegebiet */
|
||||
if (mage) {
|
||||
ADDMSG(&u->faction->msgs, msg_message("spyreport_mage", "target type", target, magic_school[mage->magietyp]));
|
||||
}
|
||||
}
|
||||
if (spy > 6) {
|
||||
faction * fv = visible_faction(u->faction,target);
|
||||
if (fv && fv!=target->faction) {
|
||||
/* wahre Partei */
|
||||
ADDMSG(&u->faction->msgs, msg_message("spyreport_faction", "target faction", target, target->faction));
|
||||
}
|
||||
}
|
||||
if (spy > 0) {
|
||||
int first = 1;
|
||||
int found = 0;
|
||||
skill * sv;
|
||||
char buf[4096];
|
||||
|
||||
buf[0] = 0;
|
||||
for (sv = target->skills;sv!=target->skills+target->skill_size;++sv) {
|
||||
if (sv->level>0) {
|
||||
found++;
|
||||
if (first == 1) {
|
||||
first = 0;
|
||||
} else {
|
||||
strncat(buf, ", ", sizeof(buf));
|
||||
}
|
||||
strncat(buf, (const char *)skillname(sv->id, u->faction->locale), sizeof(buf));
|
||||
strncat(buf, " ", sizeof(buf));
|
||||
strncat(buf, itoa10(eff_skill(target, sv->id, target->region)), sizeof(buf));
|
||||
}
|
||||
}
|
||||
if (found) {
|
||||
ADDMSG(&u->faction->msgs, msg_message("spyreport_skills", "target skills", target, buf));
|
||||
}
|
||||
|
||||
if (target->items) {
|
||||
ADDMSG(&u->faction->msgs, msg_message("spyreport_items", "target items", target, target->items));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
spy_cmd(unit * u, struct order * ord)
|
||||
{
|
||||
unit *target;
|
||||
int spy, observe;
|
||||
double spychance, observechance;
|
||||
region * r = u->region;
|
||||
|
||||
init_tokens(ord);
|
||||
skip_token();
|
||||
target = getunit(r, u->faction);
|
||||
|
||||
if (!target) {
|
||||
ADDMSG(&u->faction->msgs, msg_feedback(u, u->thisorder, "feedback_unit_not_found", ""));
|
||||
return 0;
|
||||
}
|
||||
if (!can_contact(r, u, target)) {
|
||||
cmistake(u, u->thisorder, 24, MSG_EVENT);
|
||||
return 0;
|
||||
}
|
||||
if (eff_skill(u, SK_SPY, r) < 1) {
|
||||
cmistake(u, u->thisorder, 39, MSG_EVENT);
|
||||
return 0;
|
||||
}
|
||||
/* Die Grundchance für einen erfolgreichen Spionage-Versuch ist 10%.
|
||||
* Für jeden Talentpunkt, den das Spionagetalent das Tarnungstalent
|
||||
* des Opfers übersteigt, erhöht sich dieses um 5%*/
|
||||
spy = eff_skill(u, SK_SPY, r) - eff_skill(target, SK_STEALTH, r);
|
||||
spychance = 0.1 + MAX(spy*0.05, 0.0);
|
||||
|
||||
if (chance(spychance)) {
|
||||
produceexp(u, SK_SPY, u->number);
|
||||
spy_message(spy, u, target);
|
||||
} else {
|
||||
ADDMSG(&u->faction->msgs, msg_message("spyfail", "spy target", u, target));
|
||||
}
|
||||
|
||||
/* der Spion kann identifiziert werden, wenn das Opfer bessere
|
||||
* Wahrnehmung als das Ziel Tarnung + Spionage/2 hat */
|
||||
observe = eff_skill(target, SK_PERCEPTION, r)
|
||||
- (effskill(u, SK_STEALTH) + eff_skill(u, SK_SPY, r)/2);
|
||||
|
||||
if (invisible(u, target) >= u->number) {
|
||||
observe = MIN(observe, 0);
|
||||
}
|
||||
|
||||
/* Anschließend wird - unabhängig vom Erfolg - gewürfelt, ob der
|
||||
* Spionageversuch bemerkt wurde. Die Wahrscheinlich dafür ist (100 -
|
||||
* SpionageSpion*5 + WahrnehmungOpfer*2)%. */
|
||||
observechance = 1.0 - (eff_skill(u, SK_SPY, r) * 0.05)
|
||||
+ (eff_skill(target, SK_PERCEPTION, r) * 0.02);
|
||||
|
||||
if (chance(observechance)) {
|
||||
ADDMSG(&target->faction->msgs, msg_message("spydetect",
|
||||
"spy target", observe>0?u:NULL, target));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
setwere_cmd(unit *u, struct order * ord)
|
||||
{
|
||||
#if KARMA_MODULE
|
||||
int level = fspecial(u->faction, FS_LYCANTROPE);
|
||||
const char *s;
|
||||
|
||||
if (!level) {
|
||||
cmistake(u, ord, 311, MSG_EVENT);
|
||||
return 0;
|
||||
}
|
||||
|
||||
init_tokens(ord);
|
||||
skip_token();
|
||||
s = getstrtoken();
|
||||
|
||||
if (s == NULL || *s == '\0') {
|
||||
if(fval(u, UFL_WERE)) {
|
||||
cmistake(u, ord, 309, MSG_EVENT);
|
||||
} else if(rng_int()%100 < 35+(level-1)*20) { /* 35, 55, 75, 95% */
|
||||
fset(u, UFL_WERE);
|
||||
} else {
|
||||
cmistake(u, ord, 311, MSG_EVENT);
|
||||
}
|
||||
} else if (findparam(s, u->faction->locale) == P_NOT) {
|
||||
if(fval(u, UFL_WERE)) {
|
||||
cmistake(u, ord, 310, MSG_EVENT);
|
||||
} else if(rng_int()%100 < 90-level*20) { /* 70, 50, 30, 10% */
|
||||
freset(u, UFL_WERE);
|
||||
} else {
|
||||
cmistake(u, ord, 311, MSG_EVENT);
|
||||
}
|
||||
|
||||
}
|
||||
#endif /* KARMA_MODULE */
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
set_factionstealth(unit * u, faction * f)
|
||||
{
|
||||
region * lastr = NULL;
|
||||
/* for all units mu of our faction, check all the units in the region
|
||||
* they are in, if their visible faction is f, it's ok. use lastr to
|
||||
* avoid testing the same region twice in a row. */
|
||||
unit * mu = u->faction->units;
|
||||
while (mu!=NULL) {
|
||||
if (mu->number && mu->region!=lastr) {
|
||||
unit * ru = mu->region->units;
|
||||
lastr = mu->region;
|
||||
while (ru!=NULL) {
|
||||
if (ru->number) {
|
||||
faction * fv = visible_faction(f, ru);
|
||||
if (fv==f) {
|
||||
if (cansee(f, lastr, ru, 0)) break;
|
||||
}
|
||||
}
|
||||
ru = ru->next;
|
||||
}
|
||||
if (ru!=NULL) break;
|
||||
}
|
||||
mu = mu->nextF;
|
||||
}
|
||||
if (mu!=NULL) {
|
||||
attrib * a = a_find(u->attribs, &at_otherfaction);
|
||||
if (!a) a = a_add(&u->attribs, make_otherfaction(f));
|
||||
else a->data.v = f;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
setstealth_cmd(unit * u, struct order * ord)
|
||||
{
|
||||
const char *s;
|
||||
int level;
|
||||
const race * trace;
|
||||
|
||||
init_tokens(ord);
|
||||
skip_token();
|
||||
s = getstrtoken();
|
||||
|
||||
/* Tarne ohne Parameter: Setzt maximale Tarnung */
|
||||
|
||||
if (s == NULL || *s == 0) {
|
||||
u_seteffstealth(u, -1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
trace = findrace(s, u->faction->locale);
|
||||
if (trace) {
|
||||
/* Dämonen können sich nur als andere Spielerrassen tarnen */
|
||||
if (u->race == new_race[RC_DAEMON]) {
|
||||
race_t allowed[] = { RC_DWARF, RC_ELF, RC_ORC, RC_GOBLIN, RC_HUMAN,
|
||||
RC_TROLL, RC_DAEMON, RC_INSECT, RC_HALFLING, RC_CAT, RC_AQUARIAN,
|
||||
RC_URUK, NORACE };
|
||||
int i;
|
||||
for (i=0;allowed[i]!=NORACE;++i) if (new_race[allowed[i]]==trace) break;
|
||||
if (new_race[allowed[i]]==trace) {
|
||||
u->irace = trace;
|
||||
if (u->race->flags & RCF_SHAPESHIFTANY && get_racename(u->attribs))
|
||||
set_racename(&u->attribs, NULL);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Singdrachen können sich nur als Drachen tarnen */
|
||||
if (u->race == new_race[RC_SONGDRAGON] || u->race == new_race[RC_BIRTHDAYDRAGON]) {
|
||||
if (trace==new_race[RC_SONGDRAGON]||trace==new_race[RC_FIREDRAGON]||trace==new_race[RC_DRAGON]||trace==new_race[RC_WYRM]) {
|
||||
u->irace = trace;
|
||||
if (u->race->flags & RCF_SHAPESHIFTANY && get_racename(u->attribs))
|
||||
set_racename(&u->attribs, NULL);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Dämomen und Illusionsparteien können sich als andere race tarnen */
|
||||
if (u->race->flags & RCF_SHAPESHIFT) {
|
||||
if (playerrace(trace)) {
|
||||
u->irace = trace;
|
||||
if ((u->race->flags & RCF_SHAPESHIFTANY) && get_racename(u->attribs))
|
||||
set_racename(&u->attribs, NULL);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
switch(findparam(s, u->faction->locale)) {
|
||||
case P_FACTION:
|
||||
/* TARNE PARTEI [NICHT|NUMMER abcd] */
|
||||
if (!rule_stealth_faction()) break;
|
||||
s = getstrtoken();
|
||||
if(!s || *s == 0) {
|
||||
fset(u, UFL_ANON_FACTION);
|
||||
} else if (findparam(s, u->faction->locale) == P_NOT) {
|
||||
freset(u, UFL_ANON_FACTION);
|
||||
} else if (findkeyword(s, u->faction->locale) == K_NUMBER) {
|
||||
const char *s2 = (const char *)getstrtoken();
|
||||
int nr = -1;
|
||||
|
||||
if (s2) nr = atoi36(s2);
|
||||
if (!s2 || *s2 == 0 || nr == u->faction->no) {
|
||||
a_removeall(&u->attribs, &at_otherfaction);
|
||||
} else {
|
||||
struct faction * f = findfaction(nr);
|
||||
if (f==NULL) {
|
||||
cmistake(u, ord, 66, MSG_EVENT);
|
||||
} else {
|
||||
set_factionstealth(u, f);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
cmistake(u, ord, 289, MSG_EVENT);
|
||||
}
|
||||
break;
|
||||
case P_ANY:
|
||||
/* TARNE ALLES (was nicht so alles geht?) */
|
||||
u_seteffstealth(u, -1);
|
||||
break;
|
||||
#if KARMA_MODULE
|
||||
case P_NUMBER:
|
||||
/* TARNE ANZAHL [NICHT] */
|
||||
if (!fspecial(u->faction, FS_HIDDEN)) {
|
||||
cmistake(u, ord, 277, MSG_EVENT);
|
||||
return 0;
|
||||
}
|
||||
s = getstrtoken();
|
||||
if (findparam(s, u->faction->locale) == P_NOT) {
|
||||
attrib * a = a_find(u->attribs, &at_fshidden);
|
||||
if (a==NULL) a->data.ca[0] = 0;
|
||||
if (a->data.i == 0) a_remove(&u->attribs, a);
|
||||
} else {
|
||||
attrib * a = a_find(u->attribs, &at_fshidden);
|
||||
if (a!=NULL) a = a_add(&u->attribs, a_new(&at_fshidden));
|
||||
a->data.ca[0] = 1;
|
||||
}
|
||||
break;
|
||||
#endif /* KARMA_MODULE */
|
||||
#if KARMA_MODULE
|
||||
case P_ITEMS:
|
||||
/* TARNE GEGENSTÄNDE [NICHT] */
|
||||
if(!fspecial(u->faction, FS_HIDDEN)) {
|
||||
cmistake(u, ord, 277, MSG_EVENT);
|
||||
return 0;
|
||||
}
|
||||
if (findparam(s, u->faction->locale) == P_NOT) {
|
||||
attrib * a = a_find(u->attribs, &at_fshidden);
|
||||
if (a!=NULL) a->data.ca[1] = 0;
|
||||
if (a->data.i == 0) a_remove(&u->attribs, a);
|
||||
} else {
|
||||
attrib * a = a_find(u->attribs, &at_fshidden);
|
||||
if (a==NULL) a = a_add(&u->attribs, a_new(&at_fshidden));
|
||||
a->data.ca[1] = 1;
|
||||
}
|
||||
break;
|
||||
#endif /* KARMA_MODULE */
|
||||
case P_NOT:
|
||||
u_seteffstealth(u, -1);
|
||||
break;
|
||||
default:
|
||||
if (isdigit(s[0])) {
|
||||
/* Tarnungslevel setzen */
|
||||
level = atoi((const char *)s);
|
||||
if (level > effskill(u, SK_STEALTH)) {
|
||||
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "error_lowstealth", ""));
|
||||
return 0;
|
||||
}
|
||||
u_seteffstealth(u, level);
|
||||
} else if (u->race->flags & RCF_SHAPESHIFTANY) {
|
||||
set_racename(&u->attribs, s);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
crew_skill(region * r, faction * f, ship * sh, skill_t sk)
|
||||
{
|
||||
int value = 0;
|
||||
unit *u;
|
||||
|
||||
for (u=r->units;u;u=u->next) {
|
||||
if (u->ship == sh && u->faction == f) {
|
||||
int s = eff_skill(u, sk, r);
|
||||
value = MAX(s, value);
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
static int
|
||||
try_destruction(unit * u, unit * u2, const ship *sh, int skilldiff)
|
||||
{
|
||||
const char *destruction_success_msg = "destroy_ship_0";
|
||||
const char *destruction_failed_msg = "destroy_ship_1";
|
||||
const char *destruction_detected_msg = "destroy_ship_2";
|
||||
const char *detect_failure_msg = "destroy_ship_3";
|
||||
const char *object_destroyed_msg = "destroy_ship_4";
|
||||
|
||||
if (skilldiff == 0) {
|
||||
/* tell the unit that the attempt failed: */
|
||||
ADDMSG(&u->faction->msgs, msg_message(destruction_failed_msg, "ship unit", sh, u));
|
||||
/* tell the enemy about the attempt: */
|
||||
if (u2) {
|
||||
ADDMSG(&u2->faction->msgs, msg_message(detect_failure_msg, "ship", sh));
|
||||
}
|
||||
return 0;
|
||||
} else if (skilldiff < 0) {
|
||||
/* tell the unit that the attempt was detected: */
|
||||
ADDMSG(&u2->faction->msgs, msg_message(destruction_detected_msg, "ship unit", sh, u));
|
||||
/* tell the enemy whodunit: */
|
||||
if (u2) {
|
||||
ADDMSG(&u2->faction->msgs, msg_message(detect_failure_msg, "ship", sh));
|
||||
}
|
||||
return 0;
|
||||
} else {
|
||||
/* tell the unit that the attempt succeeded */
|
||||
ADDMSG(&u->faction->msgs, msg_message(destruction_success_msg, "ship unit", sh, u));
|
||||
if (u2) {
|
||||
ADDMSG(&u2->faction->msgs, msg_message(object_destroyed_msg, "ship", sh));
|
||||
}
|
||||
}
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
static void
|
||||
sink_ship(region * r, ship * sh, const char *name, unit * saboteur)
|
||||
{
|
||||
unit **ui, *u;
|
||||
region *safety = r;
|
||||
int i;
|
||||
direction_t d;
|
||||
double probability = 0.0;
|
||||
message * sink_msg = NULL;
|
||||
faction * f;
|
||||
|
||||
for (f=NULL,u=r->units;u;u=u->next) {
|
||||
/* slight optimization to avoid dereferencing u->faction each time */
|
||||
if (f!=u->faction) {
|
||||
f = u->faction;
|
||||
freset(f, FFL_SELECT);
|
||||
}
|
||||
}
|
||||
|
||||
/* figure out what a unit's chances of survival are: */
|
||||
if (!fval(r->terrain, SEA_REGION)) {
|
||||
probability = CANAL_SWIMMER_CHANCE;
|
||||
} else {
|
||||
for (d = 0; d != MAXDIRECTIONS; ++d) {
|
||||
region * rn = rconnect(r, d);
|
||||
if (!fval(rn->terrain, SEA_REGION) && !move_blocked(NULL, r, rn)) {
|
||||
safety = rn;
|
||||
probability = OCEAN_SWIMMER_CHANCE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (ui = &r->units; *ui; ui = &(*ui)->next) {
|
||||
unit *u = *ui;
|
||||
|
||||
/* inform this faction about the sinking ship: */
|
||||
if (!fval(u->faction, FFL_SELECT)) {
|
||||
fset(u->faction, FFL_SELECT);
|
||||
if (sink_msg==NULL) {
|
||||
sink_msg = msg_message("sink_msg", "ship region", sh, r);
|
||||
}
|
||||
add_message(&f->msgs, sink_msg);
|
||||
}
|
||||
|
||||
if (u->ship == sh) {
|
||||
int dead = 0;
|
||||
message * msg;
|
||||
|
||||
/* if this fails, I misunderstood something: */
|
||||
for (i = 0; i != u->number; ++i)
|
||||
if (chance(probability))
|
||||
++dead;
|
||||
|
||||
if (dead != u->number) {
|
||||
/* she will live. but her items get stripped */
|
||||
if (dead > 0) {
|
||||
msg = msg_message("sink_lost_msg", "dead region unit", dead, safety, u);
|
||||
} else {
|
||||
msg = msg_message("sink_saved_msg", "region unit", safety, u);
|
||||
}
|
||||
set_leftship(u, u->ship);
|
||||
u->ship = 0;
|
||||
if (r != safety) {
|
||||
setguard(u, GUARD_NONE);
|
||||
}
|
||||
while (u->items) {
|
||||
i_remove(&u->items, u->items);
|
||||
}
|
||||
move_unit(u, safety, NULL);
|
||||
} else {
|
||||
msg = msg_message("sink_lost_msg", "dead region unit", dead, NULL, u);
|
||||
}
|
||||
add_message(&u->faction->msgs, msg);
|
||||
msg_release(msg);
|
||||
if (dead == u->number) {
|
||||
/* the poor creature, she dies */
|
||||
if (remove_unit(ui, u)!=0) {
|
||||
ui = &u->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (sink_msg) msg_release(sink_msg);
|
||||
/* finally, get rid of the ship */
|
||||
remove_ship(&sh->region->ships, sh);
|
||||
}
|
||||
|
||||
int
|
||||
sabotage_cmd(unit * u, struct order * ord)
|
||||
{
|
||||
const char *s;
|
||||
int i;
|
||||
ship *sh;
|
||||
unit *u2;
|
||||
char buffer[DISPLAYSIZE];
|
||||
region * r = u->region;
|
||||
int skdiff;
|
||||
|
||||
init_tokens(ord);
|
||||
skip_token();
|
||||
s = getstrtoken();
|
||||
|
||||
i = findparam(s, u->faction->locale);
|
||||
|
||||
switch (i) {
|
||||
case P_SHIP:
|
||||
sh = u->ship;
|
||||
if (!sh) {
|
||||
cmistake(u, u->thisorder, 144, MSG_EVENT);
|
||||
return 0;
|
||||
}
|
||||
u2 = shipowner(sh);
|
||||
skdiff = eff_skill(u, SK_SPY, r)-crew_skill(r, u2->faction, sh, SK_PERCEPTION);
|
||||
if (try_destruction(u, u2, sh, skdiff)) {
|
||||
sink_ship(r, sh, buffer, u);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
cmistake(u, u->thisorder, 9, MSG_EVENT);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
44
src/common/gamecode/spy.h
Normal file
44
src/common/gamecode/spy.h
Normal file
|
@ -0,0 +1,44 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
*
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2003
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
* Henning Peters (faroul@beyond.kn-bremen.de)
|
||||
* Enno Rehling (enno@eressea.de)
|
||||
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
|
||||
*
|
||||
* based on:
|
||||
*
|
||||
* Atlantis v1.0 13 September 1993 Copyright 1993 by Russell Wallace
|
||||
* Atlantis v1.7 Copyright 1996 by Alex Schröder
|
||||
*
|
||||
* This program may not be used, modified or distributed without
|
||||
* prior permission by the authors of Eressea.
|
||||
* This program may not be sold or used commercially without prior written
|
||||
* permission from the authors.
|
||||
*/
|
||||
|
||||
#ifndef H_KRNL_SPY
|
||||
#define H_KRNL_SPY
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct unit;
|
||||
struct region;
|
||||
struct strlist;
|
||||
|
||||
extern int setwere_cmd(struct unit * u, struct order * ord);
|
||||
extern int setstealth_cmd(struct unit * u, struct order * ord);
|
||||
extern int spy_cmd(struct unit * u, struct order * ord);
|
||||
extern int sabotage_cmd(struct unit * u, struct order * ord);
|
||||
extern void spy_message(int spy, const struct unit *u, const struct unit *target);
|
||||
|
||||
#define OCEAN_SWIMMER_CHANCE 0.1
|
||||
#define CANAL_SWIMMER_CHANCE 0.9
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
812
src/common/gamecode/study.c
Normal file
812
src/common/gamecode/study.c
Normal file
|
@ -0,0 +1,812 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
*
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2003
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
* Henning Peters (faroul@beyond.kn-bremen.de)
|
||||
* Enno Rehling (enno@eressea.de)
|
||||
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
|
||||
*
|
||||
* based on:
|
||||
*
|
||||
* Atlantis v1.0 13 September 1993 Copyright 1993 by Russell Wallace
|
||||
* Atlantis v1.7 Copyright 1996 by Alex Schröder
|
||||
*
|
||||
* This program may not be used, modified or distributed without
|
||||
* prior permission by the authors of Eressea.
|
||||
* This program may not be sold or used commercially without prior written
|
||||
* permission from the authors.
|
||||
*/
|
||||
|
||||
#define TEACH_ALL 1
|
||||
#define TEACH_FRIENDS
|
||||
|
||||
#include <config.h>
|
||||
#include <kernel/eressea.h>
|
||||
#include "study.h"
|
||||
|
||||
#include <kernel/alchemy.h>
|
||||
#include <kernel/building.h>
|
||||
#include <kernel/faction.h>
|
||||
#include <kernel/item.h>
|
||||
#include <kernel/karma.h>
|
||||
#include <kernel/magic.h>
|
||||
#include <kernel/message.h>
|
||||
#include <kernel/move.h>
|
||||
#include <kernel/order.h>
|
||||
#include <kernel/plane.h>
|
||||
#include <kernel/pool.h>
|
||||
#include <kernel/race.h>
|
||||
#include <kernel/region.h>
|
||||
#include <kernel/skill.h>
|
||||
#include <kernel/terrain.h>
|
||||
#include <kernel/unit.h>
|
||||
|
||||
/* util includes */
|
||||
#include <util/attrib.h>
|
||||
#include <util/base36.h>
|
||||
#include <util/language.h>
|
||||
#include <util/parser.h>
|
||||
#include <util/rand.h>
|
||||
#include <util/umlaut.h>
|
||||
|
||||
/* libc includes */
|
||||
#include <assert.h>
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
#define TEACHNUMBER 10
|
||||
|
||||
static skill_t
|
||||
getskill(const struct locale * lang)
|
||||
{
|
||||
return findskill(getstrtoken(), lang);
|
||||
}
|
||||
|
||||
magic_t
|
||||
getmagicskill(const struct locale * lang)
|
||||
{
|
||||
struct tnode * tokens = get_translations(lang, UT_MAGIC);
|
||||
variant token;
|
||||
const char * s = getstrtoken();
|
||||
|
||||
if (s && s[0]) {
|
||||
if (findtoken(tokens, s, &token)==E_TOK_SUCCESS) {
|
||||
return (magic_t)token.i;
|
||||
} else {
|
||||
char buffer[3];
|
||||
buffer[0] = s[0];
|
||||
buffer[1] = s[1];
|
||||
buffer[2] = '\0';
|
||||
if (findtoken(tokens, buffer, &token)==E_TOK_SUCCESS) {
|
||||
return (magic_t)token.i;
|
||||
}
|
||||
}
|
||||
}
|
||||
return M_NONE;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------- */
|
||||
/* Vertraute und Kröten sind keine Migranten */
|
||||
boolean
|
||||
is_migrant(unit *u)
|
||||
{
|
||||
if (u->race == u->faction->race) return false;
|
||||
|
||||
if (fval(u->race, RCF_UNDEAD|RCF_ILLUSIONARY)) return false;
|
||||
if (is_familiar(u)) return false;
|
||||
if (u->race == new_race[RC_TOAD]) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------- */
|
||||
boolean
|
||||
magic_lowskill(unit *u)
|
||||
{
|
||||
if (u->race == new_race[RC_TOAD]) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------- */
|
||||
|
||||
int
|
||||
study_cost(unit *u, skill_t sk)
|
||||
{
|
||||
static int cost[MAXSKILLS];
|
||||
int stufe, k = 50;
|
||||
|
||||
if (cost[sk]==0) {
|
||||
char buffer[256];
|
||||
sprintf(buffer, "skills.cost.%s", skillnames[sk]);
|
||||
cost[sk] = get_param_int(global.parameters, buffer, -1);
|
||||
}
|
||||
if (cost[sk]>=0) return cost[sk];
|
||||
|
||||
switch (sk) {
|
||||
case SK_SPY:
|
||||
return 100;
|
||||
break;
|
||||
case SK_TACTICS:
|
||||
case SK_HERBALISM:
|
||||
case SK_ALCHEMY:
|
||||
return 200;
|
||||
break;
|
||||
case SK_MAGIC: /* Die Magiekosten betragen 50+Summe(50*Stufe) */
|
||||
/* 'Stufe' ist dabei die nächste zu erreichende Stufe */
|
||||
stufe = 1 + get_level(u, SK_MAGIC);
|
||||
return k*(1+((stufe+1)*stufe/2));
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------- */
|
||||
|
||||
static void
|
||||
init_learning(struct attrib * a)
|
||||
{
|
||||
a->data.v = calloc(sizeof(teaching_info), 1);
|
||||
}
|
||||
|
||||
static void
|
||||
done_learning(struct attrib * a)
|
||||
{
|
||||
free(a->data.v);
|
||||
}
|
||||
|
||||
const attrib_type at_learning = {
|
||||
"learning",
|
||||
init_learning, done_learning, NULL, NULL, NULL,
|
||||
ATF_UNIQUE
|
||||
};
|
||||
|
||||
static int
|
||||
study_days(unit * student, skill_t sk)
|
||||
{
|
||||
int speed = 30;
|
||||
if (student->race->study_speed) {
|
||||
speed += student->race->study_speed[sk];
|
||||
if (speed<30) {
|
||||
skill * sv = get_skill(student, sk);
|
||||
if (sv==0) {
|
||||
speed = 30;
|
||||
}
|
||||
}
|
||||
}
|
||||
return student->number * speed;
|
||||
}
|
||||
|
||||
static int
|
||||
teach_unit(unit * teacher, unit * student, int nteaching, skill_t sk,
|
||||
boolean report, int * academy)
|
||||
{
|
||||
teaching_info * teach = NULL;
|
||||
attrib * a;
|
||||
int n;
|
||||
|
||||
/* learning sind die Tage, die sie schon durch andere Lehrer zugute
|
||||
* geschrieben bekommen haben. Total darf dies nicht über 30 Tage pro Mann
|
||||
* steigen.
|
||||
*
|
||||
* n ist die Anzahl zusätzlich gelernter Tage. n darf max. die Differenz
|
||||
* von schon gelernten Tagen zum MAX(30 Tage pro Mann) betragen. */
|
||||
|
||||
if (magic_lowskill(student)){
|
||||
cmistake(teacher, teacher->thisorder, 292, MSG_EVENT);
|
||||
return 0;
|
||||
}
|
||||
|
||||
n = 30;
|
||||
a = a_find(student->attribs, &at_learning);
|
||||
if (a!=NULL) {
|
||||
teach = (teaching_info*)a->data.v;
|
||||
n -= teach->value;
|
||||
}
|
||||
|
||||
n = MIN(n, nteaching);
|
||||
|
||||
if (n != 0) {
|
||||
struct building * b = inside_building(teacher);
|
||||
const struct building_type * btype = b?b->type:NULL;
|
||||
int index = 0;
|
||||
|
||||
if (teach==NULL) {
|
||||
a = a_add(&student->attribs, a_new(&at_learning));
|
||||
teach = (teaching_info*)a->data.v;
|
||||
} else {
|
||||
while (teach->teachers[index] && index!=MAXTEACHERS) ++index;
|
||||
}
|
||||
if (index<MAXTEACHERS) teach->teachers[index++] = teacher;
|
||||
if (index<MAXTEACHERS) teach->teachers[index] = NULL;
|
||||
teach->value += n;
|
||||
|
||||
/* Solange Akademien größenbeschränkt sind, sollte Lehrer und
|
||||
* Student auch in unterschiedlichen Gebäuden stehen dürfen */
|
||||
if (btype == bt_find("academy")
|
||||
&& student->building && student->building->type == bt_find("academy"))
|
||||
{
|
||||
int j = study_cost(student, sk);
|
||||
j = MAX(50, j * 2);
|
||||
/* kann Einheit das zahlen? */
|
||||
if (get_pooled(student, oldresourcetype[R_SILVER], GET_DEFAULT, j) >= j) {
|
||||
/* Jeder Schüler zusätzlich +10 Tage wenn in Uni. */
|
||||
teach->value += (n / 30) * 10; /* learning erhöhen */
|
||||
/* Lehrer zusätzlich +1 Tag pro Schüler. */
|
||||
if (academy) *academy += n;
|
||||
} /* sonst nehmen sie nicht am Unterricht teil */
|
||||
}
|
||||
|
||||
/* Teaching ist die Anzahl Leute, denen man noch was beibringen kann. Da
|
||||
* hier nicht n verwendet wird, werden die Leute gezählt und nicht die
|
||||
* effektiv gelernten Tage. -> FALSCH ? (ENNO)
|
||||
*
|
||||
* Eine Einheit A von 11 Mann mit Talent 0 profitiert vom ersten Lehrer B
|
||||
* also 10x30=300 tage, und der zweite Lehrer C lehrt für nur noch 1x30=30
|
||||
* Tage (damit das Maximum von 11x30=330 nicht überschritten wird).
|
||||
*
|
||||
* Damit es aber in der Ausführung nicht auf die Reihenfolge drauf ankommt,
|
||||
* darf der zweite Lehrer C keine weiteren Einheiten D mehr lehren. Also
|
||||
* wird student 30 Tage gutgeschrieben, aber teaching sinkt auf 0 (300-11x30 <=
|
||||
* 0).
|
||||
*
|
||||
* Sonst träte dies auf:
|
||||
*
|
||||
* A: lernt B: lehrt A C: lehrt A D D: lernt
|
||||
*
|
||||
* Wenn B vor C dran ist, lehrt C nur 30 Tage an A (wie oben) und
|
||||
* 270 Tage an D.
|
||||
*
|
||||
* Ist C aber vor B dran, lehrt C 300 tage an A, und 0 tage an D,
|
||||
* und B lehrt auch 0 tage an A.
|
||||
*
|
||||
* Deswegen darf C D nie lehren dürfen.
|
||||
*
|
||||
* -> Das ist wirr. wer hat das entworfen?
|
||||
* Besser wäre, man macht erst vorab alle zuordnungen, und dann
|
||||
* die Talentänderung (enno).
|
||||
*/
|
||||
|
||||
nteaching = MAX(0, nteaching - student->number * 30);
|
||||
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
int
|
||||
teach_cmd(unit * u, struct order * ord)
|
||||
{
|
||||
static const curse_type * gbdream_ct = NULL;
|
||||
plane * pl;
|
||||
region * r = u->region;
|
||||
int teaching, i, j, count, academy=0;
|
||||
unit *u2;
|
||||
skill_t sk = NOSKILL;
|
||||
|
||||
if (gbdream_ct==0) gbdream_ct = ct_find("gbdream");
|
||||
if (gbdream_ct) {
|
||||
if (get_curse(u->region->attribs, gbdream_ct)) {
|
||||
ADDMSG(&u->faction->msgs,
|
||||
msg_feedback(u, ord, "gbdream_noteach", ""));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if ((u->race->flags & RCF_NOTEACH) || fval(u, UFL_WERE)) {
|
||||
cmistake(u, ord, 274, MSG_EVENT);
|
||||
return 0;
|
||||
}
|
||||
|
||||
pl = rplane(r);
|
||||
if (pl && fval(pl, PFL_NOTEACH)) {
|
||||
cmistake(u, ord, 273, MSG_EVENT);
|
||||
return 0;
|
||||
}
|
||||
|
||||
teaching = u->number * 30 * TEACHNUMBER;
|
||||
|
||||
if ((i = get_effect(u, oldpotiontype[P_FOOL])) > 0) { /* Trank "Dumpfbackenbrot" */
|
||||
i = MIN(i, u->number * TEACHNUMBER);
|
||||
/* Trank wirkt pro Schüler, nicht pro Lehrer */
|
||||
teaching -= i * 30;
|
||||
change_effect(u, oldpotiontype[P_FOOL], -i);
|
||||
j = teaching / 30;
|
||||
ADDMSG(&u->faction->msgs, msg_message("teachdumb",
|
||||
"teacher amount", u, j));
|
||||
}
|
||||
if (teaching == 0) return 0;
|
||||
|
||||
|
||||
u2 = 0;
|
||||
count = 0;
|
||||
|
||||
init_tokens(ord);
|
||||
skip_token();
|
||||
|
||||
#if TEACH_ALL
|
||||
if (getparam(u->faction->locale)==P_ANY) {
|
||||
unit * student = r->units;
|
||||
skill_t teachskill[MAXSKILLS];
|
||||
int i = 0;
|
||||
do {
|
||||
sk = getskill(u->faction->locale);
|
||||
teachskill[i++]=sk;
|
||||
} while (sk!=NOSKILL);
|
||||
while (teaching && student) {
|
||||
if (student->faction == u->faction) {
|
||||
#ifdef NEW_DAEMONHUNGER_RULE
|
||||
if (LongHunger(student)) continue;
|
||||
#else
|
||||
if (fval(student, UFL_HUNGER)) continue;
|
||||
#endif
|
||||
if (get_keyword(student->thisorder) == K_STUDY) {
|
||||
/* Input ist nun von student->thisorder !! */
|
||||
init_tokens(student->thisorder);
|
||||
skip_token();
|
||||
sk = getskill(student->faction->locale);
|
||||
if (sk!=NOSKILL && teachskill[0]!=NOSKILL) {
|
||||
for (i=0;teachskill[i]!=NOSKILL;++i) if (sk==teachskill[i]) break;
|
||||
sk = teachskill[i];
|
||||
}
|
||||
if (sk != NOSKILL && eff_skill_study(u, sk, r)-TEACHDIFFERENCE > eff_skill_study(student, sk, r)) {
|
||||
teaching -= teach_unit(u, student, teaching, sk, true, &academy);
|
||||
}
|
||||
}
|
||||
}
|
||||
student = student->next;
|
||||
}
|
||||
#ifdef TEACH_FRIENDS
|
||||
while (teaching && student) {
|
||||
if (student->faction != u->faction && alliedunit(u, student->faction, HELP_GUARD)) {
|
||||
#ifdef NEW_DAEMONHUNGER_RULE
|
||||
if (LongHunger(student)) continue;
|
||||
#else
|
||||
if (fval(student, UFL_HUNGER)) continue;
|
||||
#endif
|
||||
if (get_keyword(student->thisorder) == K_STUDY) {
|
||||
/* Input ist nun von student->thisorder !! */
|
||||
init_tokens(student->thisorder);
|
||||
skip_token();
|
||||
sk = getskill(student->faction->locale);
|
||||
if (sk != NOSKILL && eff_skill_study(u, sk, r)-TEACHDIFFERENCE >= eff_skill(student, sk, r)) {
|
||||
teaching -= teach_unit(u, student, teaching, sk, true, &academy);
|
||||
}
|
||||
}
|
||||
}
|
||||
student = student->next;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
char zOrder[4096];
|
||||
order * new_order;
|
||||
|
||||
zOrder[0] = '\0';
|
||||
init_tokens(ord);
|
||||
skip_token();
|
||||
|
||||
while (!parser_end()) {
|
||||
unit * u2 = getunit(r, u->faction);
|
||||
boolean feedback;
|
||||
++count;
|
||||
|
||||
/* Falls die Unit nicht gefunden wird, Fehler melden */
|
||||
|
||||
if (!u2) {
|
||||
char tbuf[20];
|
||||
const char * uid;
|
||||
const char * token;
|
||||
/* Finde den string, der den Fehler verursacht hat */
|
||||
parser_pushstate();
|
||||
init_tokens(ord);
|
||||
skip_token();
|
||||
|
||||
for (j=0; j!=count-1; ++j) {
|
||||
/* skip over the first 'count' units */
|
||||
getunit(r, u->faction);
|
||||
}
|
||||
|
||||
token = getstrtoken();
|
||||
|
||||
/* Beginne die Fehlermeldung */
|
||||
if (findparam(token, u->faction->locale) != P_TEMP) {
|
||||
uid = token;
|
||||
} else {
|
||||
token = getstrtoken();
|
||||
sprintf(tbuf, "%s %s", LOC(u->faction->locale,
|
||||
parameters[P_TEMP]), token);
|
||||
uid = tbuf;
|
||||
}
|
||||
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "unitnotfound_id",
|
||||
"id", uid));
|
||||
|
||||
parser_popstate();
|
||||
continue;
|
||||
}
|
||||
|
||||
feedback = u->faction==u2->faction || alliedunit(u2, u->faction, HELP_GUARD);
|
||||
|
||||
/* Neuen Befehl zusammenbauen. TEMP-Einheiten werden automatisch in
|
||||
* ihre neuen Nummern übersetzt. */
|
||||
if (zOrder[0]) strcat(zOrder, " ");
|
||||
strcat(zOrder, unitid(u2));
|
||||
|
||||
if (get_keyword(u2->thisorder) != K_STUDY) {
|
||||
ADDMSG(&u->faction->msgs,
|
||||
msg_feedback(u, ord, "teach_nolearn", "student", u2));
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Input ist nun von u2->thisorder !! */
|
||||
parser_pushstate();
|
||||
init_tokens(u2->thisorder);
|
||||
skip_token();
|
||||
sk = getskill(u2->faction->locale);
|
||||
parser_popstate();
|
||||
|
||||
if (sk == NOSKILL) {
|
||||
ADDMSG(&u->faction->msgs,
|
||||
msg_feedback(u, ord, "teach_nolearn", "student", u2));
|
||||
continue;
|
||||
}
|
||||
|
||||
/* u is teacher, u2 is student */
|
||||
if (eff_skill_study(u2, sk, r) > eff_skill_study(u, sk, r)-TEACHDIFFERENCE) {
|
||||
if (feedback) {
|
||||
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "teach_asgood", "student", u2));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (sk == SK_MAGIC) {
|
||||
/* ist der Magier schon spezialisiert, so versteht er nur noch
|
||||
* Lehrer seines Gebietes */
|
||||
sc_mage * mage1 = get_mage(u);
|
||||
sc_mage * mage2 = get_mage(u2);
|
||||
if (!mage2 || !mage1 || (mage2->magietyp!=M_GRAY && mage1->magietyp!=mage2->magietyp)) {
|
||||
if (feedback) {
|
||||
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "error_different_magic", "target", u2));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
teaching -= teach_unit(u, u2, teaching, sk, false, &academy);
|
||||
}
|
||||
new_order = create_order(K_TEACH, u->faction->locale, "%s", zOrder);
|
||||
replace_order(&u->orders, ord, new_order);
|
||||
free_order(new_order); /* parse_order & set_order have each increased the refcount */
|
||||
}
|
||||
if (academy && sk!=NOSKILL) {
|
||||
academy = academy/30; /* anzahl gelehrter wochen, max. 10 */
|
||||
learn_skill(u, sk, academy/30.0/TEACHNUMBER);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static double
|
||||
study_speedup(unit * u)
|
||||
{
|
||||
#define MINTURN 5 /* 5 */
|
||||
#define OFSTURN 2 /* 2 */
|
||||
if (turn>MINTURN) {
|
||||
static int speed_rule = -1;
|
||||
if (speed_rule<0) {
|
||||
speed_rule = get_param_int(global.parameters, "study.speedup", 0);
|
||||
}
|
||||
if (speed_rule==1) {
|
||||
double learn_age = OFSTURN;
|
||||
int i;
|
||||
for (i=0;i!=u->skill_size;++i) {
|
||||
skill * sv = u->skills+i;
|
||||
double learn_time = sv->level*(sv->level+1)/2.0;
|
||||
learn_age += learn_time;
|
||||
}
|
||||
if (learn_age < turn) {
|
||||
return 2.0-learn_age/turn;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
int
|
||||
learn_cmd(unit * u, order * ord)
|
||||
{
|
||||
region *r = u->region;
|
||||
int p;
|
||||
magic_t mtyp;
|
||||
int l;
|
||||
int studycost, days;
|
||||
double multi = 1.0;
|
||||
attrib * a = NULL;
|
||||
teaching_info * teach = NULL;
|
||||
int money = 0;
|
||||
skill_t sk;
|
||||
int maxalchemy = 0;
|
||||
static int learn_newskills = -1;
|
||||
if (learn_newskills<0) {
|
||||
const char * str = get_param(global.parameters, "study.newskills");
|
||||
if (str && strcmp(str, "false")==0) learn_newskills = 0;
|
||||
else learn_newskills = 1;
|
||||
}
|
||||
|
||||
if ((u->race->flags & RCF_NOLEARN) || fval(u, UFL_WERE)) {
|
||||
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "error_race_nolearn", "race", u->race));
|
||||
return 0;
|
||||
}
|
||||
|
||||
init_tokens(ord);
|
||||
skip_token();
|
||||
sk = getskill(u->faction->locale);
|
||||
|
||||
if (sk < 0) {
|
||||
cmistake(u, ord, 77, MSG_EVENT);
|
||||
return 0;
|
||||
}
|
||||
if (SkillCap(sk) && SkillCap(sk) <= effskill(u, sk)) {
|
||||
cmistake(u, ord, 771, MSG_EVENT);
|
||||
return 0;
|
||||
}
|
||||
/* Hack: Talente mit Malus -99 können nicht gelernt werden */
|
||||
if (u->race->bonus[sk] == -99) {
|
||||
cmistake(u, ord, 771, MSG_EVENT);
|
||||
return 0;
|
||||
}
|
||||
if (learn_newskills==0) {
|
||||
skill * sv = get_skill(u, sk);
|
||||
if (sv==NULL) {
|
||||
/* we can only learn skills we already have */
|
||||
cmistake(u, ord, 771, MSG_EVENT);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* snotlings können Talente nur bis T8 lernen */
|
||||
if (u->race == new_race[RC_SNOTLING]){
|
||||
if (get_level(u, sk) >= 8){
|
||||
cmistake(u, ord, 308, MSG_EVENT);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
p = studycost = study_cost(u, sk);
|
||||
a = a_find(u->attribs, &at_learning);
|
||||
if (a!=NULL) {
|
||||
teach = (teaching_info*)a->data.v;
|
||||
}
|
||||
|
||||
/* keine kostenpflichtigen Talente für Migranten. Vertraute sind
|
||||
* keine Migranten, wird in is_migrant abgefangen. Vorsicht,
|
||||
* studycost darf hier noch nicht durch Akademie erhöht sein */
|
||||
if (studycost > 0 && !ExpensiveMigrants() && is_migrant(u)) {
|
||||
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "error_migrants_nolearn", ""));
|
||||
return 0;
|
||||
}
|
||||
/* Akademie: */
|
||||
{
|
||||
struct building * b = inside_building(u);
|
||||
const struct building_type * btype = b?b->type:NULL;
|
||||
|
||||
if (btype == bt_find("academy")) {
|
||||
studycost = MAX(50, studycost * 2);
|
||||
}
|
||||
}
|
||||
|
||||
if (sk == SK_MAGIC) {
|
||||
if (u->number > 1){
|
||||
cmistake(u, ord, 106, MSG_MAGIC);
|
||||
return 0;
|
||||
}
|
||||
if (is_familiar(u)){
|
||||
/* Vertraute zählen nicht zu den Magiern einer Partei,
|
||||
* können aber nur Graue Magie lernen */
|
||||
mtyp = M_GRAY;
|
||||
if (!is_mage(u)) create_mage(u, mtyp);
|
||||
} else if (!has_skill(u, SK_MAGIC)) {
|
||||
int mmax = skill_limit(u->faction, SK_MAGIC);
|
||||
/* Die Einheit ist noch kein Magier */
|
||||
if (count_skill(u->faction, SK_MAGIC) + u->number > mmax)
|
||||
{
|
||||
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "error_max_magicians", "amount", mmax));
|
||||
return 0;
|
||||
}
|
||||
mtyp = getmagicskill(u->faction->locale);
|
||||
if (mtyp == M_NONE || mtyp == M_GRAY) {
|
||||
/* wurde kein Magiegebiet angegeben, wird davon
|
||||
* ausgegangen, daß das normal gelernt werden soll */
|
||||
if(u->faction->magiegebiet != 0) {
|
||||
mtyp = u->faction->magiegebiet;
|
||||
} else {
|
||||
/* Es wurde kein Magiegebiet angegeben und die Partei
|
||||
* hat noch keins gewählt. */
|
||||
mtyp = getmagicskill(u->faction->locale);
|
||||
if (mtyp==M_NONE) {
|
||||
cmistake(u, ord, 178, MSG_MAGIC);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mtyp != u->faction->magiegebiet){
|
||||
/* Es wurde versucht, ein anderes Magiegebiet zu lernen
|
||||
* als das der Partei */
|
||||
if (u->faction->magiegebiet != 0){
|
||||
cmistake(u, ord, 179, MSG_MAGIC);
|
||||
return 0;
|
||||
} else {
|
||||
/* Lernt zum ersten mal Magie und legt damit das
|
||||
* Magiegebiet der Partei fest */
|
||||
u->faction->magiegebiet = mtyp;
|
||||
}
|
||||
}
|
||||
if (!is_mage(u)) create_mage(u, mtyp);
|
||||
} else {
|
||||
/* ist schon ein Magier und kein Vertrauter */
|
||||
if (u->faction->magiegebiet == 0) {
|
||||
/* die Partei hat noch kein Magiegebiet gewählt. */
|
||||
mtyp = getmagicskill(u->faction->locale);
|
||||
if (mtyp == M_NONE){
|
||||
mtyp = getmagicskill(u->faction->locale);
|
||||
if (mtyp==M_NONE) {
|
||||
cmistake(u, ord, 178, MSG_MAGIC);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
/* Legt damit das Magiegebiet der Partei fest */
|
||||
u->faction->magiegebiet = mtyp;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (sk == SK_ALCHEMY) {
|
||||
maxalchemy = eff_skill(u, SK_ALCHEMY, r);
|
||||
if (!has_skill(u, SK_ALCHEMY)) {
|
||||
int amax = skill_limit(u->faction, SK_ALCHEMY);
|
||||
if (count_skill(u->faction, SK_ALCHEMY) + u->number > amax) {
|
||||
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "error_max_alchemists", "amount", amax));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (studycost) {
|
||||
int cost = studycost * u->number;
|
||||
money = get_pooled(u, oldresourcetype[R_SILVER], GET_DEFAULT, cost);
|
||||
money = MIN(money, cost);
|
||||
}
|
||||
if (money < studycost * u->number) {
|
||||
studycost = p; /* Ohne Univertreurung */
|
||||
money = MIN(money, studycost);
|
||||
if (p>0 && money < studycost * u->number) {
|
||||
cmistake(u, ord, 65, MSG_EVENT);
|
||||
multi = money / (double)(studycost * u->number);
|
||||
}
|
||||
}
|
||||
|
||||
if (teach==NULL) {
|
||||
a = a_add(&u->attribs, a_new(&at_learning));
|
||||
teach = (teaching_info*)a->data.v;
|
||||
teach->teachers[0] = 0;
|
||||
}
|
||||
if (money>0) {
|
||||
use_pooled(u, oldresourcetype[R_SILVER], GET_DEFAULT, money);
|
||||
ADDMSG(&u->faction->msgs, msg_message("studycost",
|
||||
"unit region cost skill", u, u->region, money, sk));
|
||||
}
|
||||
|
||||
if (get_effect(u, oldpotiontype[P_WISE])) {
|
||||
l = MIN(u->number, get_effect(u, oldpotiontype[P_WISE]));
|
||||
teach->value += l * 10;
|
||||
change_effect(u, oldpotiontype[P_WISE], -l);
|
||||
}
|
||||
if (get_effect(u, oldpotiontype[P_FOOL])) {
|
||||
l = MIN(u->number, get_effect(u, oldpotiontype[P_FOOL]));
|
||||
teach->value -= l * 30;
|
||||
change_effect(u, oldpotiontype[P_FOOL], -l);
|
||||
}
|
||||
|
||||
#if KARMA_MODULE
|
||||
l = fspecial(u->faction, FS_WARRIOR);
|
||||
if (l > 0) {
|
||||
if (sk == SK_CROSSBOW || sk == SK_LONGBOW
|
||||
|| sk == SK_CATAPULT || sk == SK_MELEE || sk == SK_SPEAR
|
||||
|| sk == SK_STAMINA || sk == SK_WEAPONLESS)
|
||||
{
|
||||
teach->value += u->number * 5 * (l+1);
|
||||
} else {
|
||||
teach->value -= u->number * 5 * (l+1);
|
||||
teach->value = MAX(0, teach->value);
|
||||
}
|
||||
}
|
||||
#endif /* KARMA_MODULE */
|
||||
|
||||
if (p != studycost) {
|
||||
/* ist_in_gebaeude(r, u, BT_UNIVERSITAET) == 1) { */
|
||||
/* p ist Kosten ohne Uni, studycost mit; wenn
|
||||
* p!=studycost, ist die Einheit zwangsweise
|
||||
* in einer Uni */
|
||||
teach->value += u->number * 10;
|
||||
}
|
||||
|
||||
if (is_cursed(r->attribs, C_BADLEARN,0)) {
|
||||
teach->value -= u->number * 10;
|
||||
}
|
||||
|
||||
multi *= study_speedup(u);
|
||||
days = study_days(u, sk);
|
||||
days = (int)((days + teach->value) * multi);
|
||||
|
||||
/* the artacademy currently improves the learning of entertainment
|
||||
of all units in the region, to be able to make it cumulative with
|
||||
with an academy */
|
||||
|
||||
if (sk == SK_ENTERTAINMENT && buildingtype_exists(r, bt_find("artacademy"))) {
|
||||
days *= 2;
|
||||
}
|
||||
|
||||
if (fval(u, UFL_HUNGER)) days /= 2;
|
||||
|
||||
while (days) {
|
||||
if (days>=u->number*30) {
|
||||
learn_skill(u, sk, 1.0);
|
||||
days -= u->number*30;
|
||||
} else {
|
||||
double chance = (double)days/u->number/30;
|
||||
learn_skill(u, sk, chance);
|
||||
days = 0;
|
||||
}
|
||||
}
|
||||
if (a!=NULL) {
|
||||
if (teach!=NULL) {
|
||||
int index = 0;
|
||||
while (teach->teachers[index] && index!=MAXTEACHERS) {
|
||||
unit * teacher = teach->teachers[index++];
|
||||
if (teacher->faction != u->faction) {
|
||||
boolean feedback = alliedunit(u, teacher->faction, HELP_GUARD);
|
||||
if (feedback) {
|
||||
ADDMSG(&teacher->faction->msgs, msg_message("teach_teacher",
|
||||
"teacher student skill level", teacher, u, sk,
|
||||
effskill(u, sk)));
|
||||
}
|
||||
ADDMSG(&u->faction->msgs, msg_message("teach_student",
|
||||
"teacher student skill", teacher, u, sk));
|
||||
}
|
||||
}
|
||||
}
|
||||
a_remove(&u->attribs, a);
|
||||
a = NULL;
|
||||
}
|
||||
fset(u, UFL_LONGACTION|UFL_NOTMOVING);
|
||||
|
||||
/* Anzeigen neuer Tränke */
|
||||
/* Spruchlistenaktualiesierung ist in Regeneration */
|
||||
|
||||
if (sk == SK_ALCHEMY) {
|
||||
const potion_type * ptype;
|
||||
faction * f = u->faction;
|
||||
int skill = eff_skill(u, SK_ALCHEMY, r);
|
||||
if (skill>maxalchemy) {
|
||||
for (ptype=potiontypes; ptype; ptype=ptype->next) {
|
||||
if (skill == ptype->level * 2) {
|
||||
attrib * a = a_find(f->attribs, &at_showitem);
|
||||
while (a && a->type==&at_showitem && a->data.v != ptype) a=a->next;
|
||||
if (a==NULL || a->type!=&at_showitem) {
|
||||
a = a_add(&f->attribs, a_new(&at_showitem));
|
||||
a->data.v = (void*) ptype->itype;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (sk==SK_MAGIC) {
|
||||
sc_mage * mage = get_mage(u);
|
||||
if (!mage) {
|
||||
mage = create_mage(u, u->faction->magiegebiet);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue