mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-07-24 17:52:17 +00:00
Adds territory map to AI GameState, based on patch from quantumstate. Fixes #969.
Updates testbot and Jubot to support basic build restrictions. This was SVN commit r10408.
This commit is contained in:
@@ -236,3 +236,30 @@ template<> jsval ScriptInterface::ToJSVal<Grid<u16> >(JSContext* cx, const Grid<
|
||||
|
||||
return OBJECT_TO_JSVAL(obj);
|
||||
}
|
||||
|
||||
template<> jsval ScriptInterface::ToJSVal<Grid<u8> >(JSContext* cx, const Grid<u8>& val)
|
||||
{
|
||||
JSObject* obj = JS_NewObject(cx, NULL, NULL, NULL);
|
||||
if (!obj)
|
||||
return JSVAL_VOID;
|
||||
|
||||
jsuint len = val.m_W * val.m_H;
|
||||
JSObject *darray = js_CreateTypedArray(cx, js::TypedArray::TYPE_UINT8, len);
|
||||
if (!darray)
|
||||
return JSVAL_VOID;
|
||||
|
||||
js::TypedArray *tdest = js::TypedArray::fromJSObject(darray);
|
||||
ENSURE(tdest->byteLength == len*sizeof(u8));
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user