Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
146 lines (138 sloc) 4.25 KB
// Copyright (C) 2009, 2010 Brendon Duncan
/* This file is a part of UDMFConvert.
UDMFConvert is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation, either version
3 of the License or (at your option) any later version.
UDMFConvert is distributed in the hope that it will be useful
but WITHOUT ANY WARRANTY; without even the implied warranty
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
the GNU General Public License for more details.
You should have received a copy of the GNU General Public
License along with this program. If not, see
<http://www.gnu.org/licenses/>. */
#include "convert.h"
#include "udmf.h"
#include "hexenmap.h"
udmf::block convert(hexen::linedef l)
{
udmf::block ul;
ul["v1"].setint((unsigned short)l.start);
ul["v2"].setint((unsigned short)l.end);
if (l.flags & hexen::LDF_IMPASSIBLE)
ul["blocking"].setbool(1);
if (l.flags & hexen::LDF_BLOCKMONSTER)
ul["blockmonsters"].setbool(1);
if (l.flags & hexen::LDF_TWOSIDED)
ul["twosided"].setbool(1);
if (l.flags & hexen::LDF_UPPERUNPEGGED)
ul["dontpegtop"].setbool(1);
if (l.flags & hexen::LDF_LOWERUNPEGGED)
ul["dontpegbottom"].setbool(1);
if (l.flags & hexen::LDF_SECRET)
ul["secret"].setbool(1);
if (l.flags & hexen::LDF_BLOCKSOUND)
ul["blocksound"].setbool(1);
if (l.flags & hexen::LDF_NOAUTOMAP)
ul["dontdraw"].setbool(1);
if (l.flags & hexen::LDF_VISIBLE)
ul["mapped"].setbool(1);
if ((l.flags & 0x1C00) == hexen::LDA_PLAYERCROSS)
ul["playercross"].setbool(1);
if ((l.flags & 0x1C00) == hexen::LDA_PLAYERUSE)
ul["playeruse"].setbool(1);
if ((l.flags & 0x1C00) == hexen::LDA_MONSTERCROSS)
ul["monstercross"].setbool(1);
if (((l.flags & 0x1C00) == hexen::LDA_PLAYERCROSS) && (l.flags & hexen::LDF_MONSTERUSE))
ul["monsteruse"].setbool(1);
if ((l.flags & 0x1C00) == hexen::LDA_PROJECTILEHIT)
ul["impact"].setbool(1);
if ((l.flags & 0x1C00) == hexen::LDA_PLAYERBUMP)
ul["playerpush"].setbool(1);
if (((l.flags & 0x1C00) == hexen::LDA_PLAYERCROSS) && (l.flags & hexen::LDF_MONSTERUSE))
ul["monsterpush"].setbool(1);
if ((l.flags & 0x1C00) == hexen::LDA_PROJECTILECROSS)
ul["missilecross"].setbool(1);
if (l.flags & hexen::LDF_REPEATABLE)
ul["repeatspecial"].setbool(1);
if (l.special != 0)
ul["special"].setint(l.special);
if (l.arg[0] != 0)
ul["arg0"].setint(l.arg[0]);
if (l.arg[1] != 0)
ul["arg1"].setint(l.arg[1]);
if (l.arg[2] != 0)
ul["arg2"].setint(l.arg[2]);
if (l.arg[3] != 0)
ul["arg3"].setint(l.arg[3]);
if (l.arg[4] != 0)
ul["arg4"].setint(l.arg[4]);
ul["sidefront"].setint((unsigned short)l.right);
if (l.left != -1)
ul["sideback"].setint((unsigned short)l.left);
if (ul["special"] == 121)
{
ul["id"] = ul["arg0"];
ul["special"].nullify();
ul["arg0"].nullify();
ul["arg1"].nullify();
ul["arg2"].nullify();
ul["arg3"].nullify();
ul["arg4"].nullify();
}
return ul;
}
udmf::block convert(hexen::thing t,double xfactor,double yfactor,double zfactor)
{
udmf::block ut;
if (t.tid != 0)
ut["id"] = t.tid;
ut["x"].setfloat(t.x * xfactor);
ut["y"].setfloat(t.y * yfactor);
if (t.angle != 0)
ut["angle"] = t.angle;
ut["type"] = t.doomednum;
if (t.height != 0)
ut["height"].setfloat(t.height * zfactor);
if (t.flags & hexen::TF_EASY)
{
ut["skill1"].setbool(1);
ut["skill2"].setbool(1);
}
if (t.flags & hexen::TF_MEDIUM)
ut["skill3"].setbool(1);
if (t.flags & hexen::TF_HARD)
{
ut["skill4"].setbool(1);
ut["skill5"].setbool(1);
}
if (t.flags & hexen::TF_AMBUSH)
ut["ambush"].setbool(1);
if (t.flags & hexen::TF_SINGLE)
ut["single"].setbool(1);
if (t.flags & hexen::TF_DMATCH)
ut["dm"].setbool(1);
if (t.flags & hexen::TF_COOP)
ut["coop"].setbool(1);
if (t.flags & hexen::TF_DORMANT)
ut["dormant"].setbool(1);
if (t.flags & hexen::TF_FIGHTER)
ut["class1"].setbool(1);
if (t.flags & hexen::TF_CLERIC)
ut["class2"].setbool(1);
if (t.flags & hexen::TF_MAGE)
ut["class3"].setbool(1);
if (t.special != 0)
ut["special"].setint(t.special);
if (t.arg[0] != 0)
ut["arg0"].setint(t.arg[0]);
if (t.arg[1] != 0)
ut["arg1"].setint(t.arg[1]);
if (t.arg[2] != 0)
ut["arg2"].setint(t.arg[2]);
if (t.arg[3] != 0)
ut["arg3"].setint(t.arg[3]);
if (t.arg[4] != 0)
ut["arg4"].setint(t.arg[4]);
return ut;
}