3 * upkg: tool for manipulating Unreal Tournament packages.
4 * Copyright © 2011 Nick Bowler
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
27 #include <uobject/uobject.h>
29 /* Hack to work around broken type parsing in GOB2. */
30 typedef unsigned char engine_palette_rgba[4];
33 class Engine:Palette from U:Object (dynamic)
35 public unsigned entries = 0;
36 public engine_palette_rgba *rgba = NULL;
38 override (U:Object) int deserialize(U:Object *uo)
40 struct upkg_file *f = uo->pkg_file;
41 Self *self = SELF(uo);
42 unsigned char buf[16];
48 buflen = upkg_export_read(f, buf, sizeof buf);
49 rc = upkg_decode_index(&entries, buf, buflen);
50 if (rc == 0 || entries < 0)
52 self->entries = entries;
54 if (upkg_export_seek(f, rc, SEEK_SET) != 0)
56 buflen = entries * sizeof self->rgba[0];
57 self->rgba = malloc(buflen);
61 rc = upkg_export_read(f, self->rgba, buflen);