1
0
forked from mirrors/0ad

# Support AI construction of buildings.

Pass terrain passability data to AI scripts.
Expand pathfinder passability data to 16 bits per tile, to allow more
classes.
Support 16-bit ints in serializer.
Partially support JS typed arrays.
Allow foundations to be placed on top of units (fixes #499).
Stop farms and fishes blocking movement (fixes #534).
Add obstruction flags to allow finer control over what they block.
Associate entity IDs with obstruction shapes, to allow finding colliding
entities.
Support moving to the edge of a target entity with inactive obstruction.
Support foundation entities in AI.
Support playing as non-hele civs.

This was SVN commit r8899.
This commit is contained in:
Ykkrosh
2011-02-10 16:06:28 +00:00
parent 556664d477
commit b8925fbbc9
55 changed files with 1562 additions and 268 deletions
@@ -1,4 +1,4 @@
/* Copyright (C) 2010 Wildfire Games.
/* Copyright (C) 2011 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@@ -25,11 +25,16 @@
#include "ps/CLogger.h"
#include "ps/Overlay.h"
#include "ps/utf16string.h"
#include "simulation2/helpers/Grid.h"
#include "simulation2/system/IComponent.h"
#include "simulation2/system/ParamNode.h"
#include "js/jsapi.h"
#define signbit std::signbit
#include "js/jstypedarray.h"
#undef signbit
template<> jsval ScriptInterface::ToJSVal<IComponent*>(JSContext* cx, IComponent* const& val)
{
if (val == NULL)
@@ -207,3 +212,30 @@ template<> jsval ScriptInterface::ToJSVal<CFixedVector2D>(JSContext* cx, const C
return OBJECT_TO_JSVAL(obj);
}
template<> jsval ScriptInterface::ToJSVal<Grid<u16> >(JSContext* cx, const Grid<u16>& val)
{
JSObject* obj = JS_NewObject(cx, NULL, NULL, NULL);
if (!obj)
return JSVAL_VOID;
size_t len = val.m_W * val.m_H;
JSObject *darray = js_CreateTypedArray(cx, js::TypedArray::TYPE_UINT16, len);
if (!darray)
return JSVAL_VOID;
js::TypedArray *tdest = js::TypedArray::fromJSObject(darray);
debug_assert(tdest->byteLength == len*sizeof(u16));
memcpy(tdest->data, val.m_Data, tdest->byteLength);
jsval w = ToJSVal(cx, val.m_W);
jsval h = ToJSVal(cx, val.m_H);
jsval data = OBJECT_TO_JSVAL(darray);
JS_SetProperty(cx, obj, "width", &w);
JS_SetProperty(cx, obj, "height", &h);
JS_SetProperty(cx, obj, "data", &data);
return OBJECT_TO_JSVAL(obj);
}