Skip to content
Permalink
Browse files

Alpha 1.7, the "game tokens do something now" update

- Fixed some configs
- Started implementing secondary fire
- Started implementing impact grenades
- Require game token to change name
- Misc bug fixes
- Added new map "flux"
- Updated README
  • Loading branch information
YellowberryHN committed Sep 16, 2019
1 parent ff7ba49 commit 3f1abdef68192f44d7e9fff9897b9f959e1162d6
@@ -4,4 +4,4 @@ A live copy of our game engine, the Cardboard Engine!
It's pretty neat.

## Supported Systems
Windows: ✓ | Mac: ❌ | Linux:
Windows: ✓ | Mac: ❌ | Linux: ✓ (build required)
BIN +11.2 KB bin/cardboard_msvc.exp
Binary file not shown.
BIN +2.6 MB (140%) bin/cardboard_msvc.ilk
Binary file not shown.
BIN +19.6 KB bin/cardboard_msvc.lib
Binary file not shown.
BIN +0 Bytes (100%) bin/cardboard_msvc.pdb
Binary file not shown.
Binary file not shown.
BIN -123 KB (99%) bin64/cardboard_msvc.ilk
Binary file not shown.
Binary file not shown.
BIN +0 Bytes (100%) bin64/cardboard_msvc.pdb
Binary file not shown.
@@ -26,7 +26,7 @@ blobmargin 1
blobs 1
blobstattris 4096
blood 1
bloodcolor 6356991
bloodcolor 10420224
blurdepthfx 0
blurdepthfxsigma 50
blurglare 4
@@ -13,27 +13,28 @@ bind ESCAPE [togglemainmenu]
newgui gametoken [
guitext "Enter your game token here. Confused on where to find it?"
guitext "Go to ^fs^f3https://hnss.gq/gametoken^fr for more info!"
guitext "Go to ^fs^f3https://hnss.gq/gametoken ^frfor more info!"
guibar
guitext "Game token:"
if (!=s $__gametoken "") [
newtoken = $__gametoken
if (!=s (getgametoken) "") [
newtoken = (getgametoken)
] [
newtoken = ""
]
guifield newtoken 64 [__gametoken = $newtoken]
guifield newtoken 64 [gametoken $newtoken]
] "Game Token"
newgui main [
// if no game token defined
if (=s $__gametoken "") [
if (=s (getgametoken) "") [
showgui gametoken
]
guilist [
guitext "Name: " (playermodelicon)
newname = (getname)
guifield newname 15 [name $newname]
]
//guilist [
// guitext "Name: " (playermodelicon)
// newname = (getname)
// guifield newname 15 [name $newname]
//]
guitext (concat "Name:" (getname)) (playermodelicon)
guibutton (concat "Player:" (playermodelname)) [guirolloveraction = (playermodelbutton $playermodel); showgui playermodel] (playermodelicon)
guibar
// guibutton "Server browser" "showgui servers"
@@ -71,12 +72,12 @@ newgui alphaservers [
] "Alpha Servers"
newgui about [
guitext "Cardboard Engine"
guitext "Project Crimson"
guitext [by Zsolt "Yellowberry" Zitting, Jacob "Bounty.jpeg" Peterson]
guitext ["Detimilu", "NoobGuy", Johnathan "C0baltCooled", and many others.]
guitext "(for a full list of contributors see the readme)"
guitext
guitext "https://harpnetstudios.com/cardboard"
guitext "https://harpnetstudios.com/games/crimson"
guitab "Cube 2"
guitext "Cube 2: Sauerbraten"
@@ -85,7 +86,7 @@ newgui about [
guitext [John "geartrooper" Siar, Quinton "Quin" Reeves, and others]
guitext "(for a full list of contributors see the readme)"
guitext "http://sauerbraten.org/"
] "Cardboard"
] "Project Crimson"
genmapitems = [
looplist curmap $arg1 [
@@ -1394,6 +1395,7 @@ newentgui envmap "Radius" "0 400"
newentgui jumppad "Z Y X" "0 200 0 200 0 200"
newentgui sound "Type Radius Size" "0 20 0 500 0 500"
newentgui particles "Type" "0 3"
newentgui flag "Direction Team" "0 360 0 2"
contexteditgui = [
if $hmapedit [showgui brushes] [
@@ -103,6 +103,7 @@ ent_action_box = [ entproperty 1 ( * $arg1 1 ) ]
ent_action_barrel = [ entproperty 1 ( * $arg1 1 ) ]
ent_action_platform = [ entproperty 1 ( * $arg1 1 ) ]
ent_action_elevator = [ entproperty 1 ( * $arg1 1 ) ]
ent_action_flag = [ entproperty 0 ( * $arg1 1 ) ]

//////// Copy and Paste //////////////

@@ -311,6 +312,22 @@ genenthudplayerstart = [
]
]

genenthudflag = [
if (= (ea 1) 0) [
format "yaw: %1; team: %2" (ea 0) (ea 1) // general
] [
if (= (ea 1) 1) [
format "yaw: %1; team: ^f3%2 (red)" (ea 0) (ea 1) // red
] [
if (= (ea 1) 2) [
format "yaw: %1; team: ^f1%2 (blue)" (ea 0) (ea 1) // blue
] [
format "yaw: %1; team: %2" (ea 0) (ea 1) // invalid team
]
]
]
]

genenthudlight = [
if (= (ea 0) 0) [
entname = "^f0infinity^f7"
Binary file not shown.
@@ -75,6 +75,10 @@ VARP(connectport, 0, 0, 0xFFFF);

void connectserv(const char *servername, int serverport, const char *serverpassword)
{
#ifdef CURLENABLED
getuserinfo_(false);
#endif

globalgamestate = -1;

if(connpeer)
@@ -157,6 +161,7 @@ void disconnect(bool async, bool cleanup)
discmillis = 0;
conoutf("disconnected");
game::gamedisconnect(cleanup);
getuserinfo_(false);
mainmenu = 1;
#ifdef WIN32
discord::updatePresence(discord::D_MENU);
@@ -1,6 +1,7 @@
// main.cpp: initialisation & main loop

#include "engine.h"
#include <game.h>

extern void cleargamma();

@@ -684,7 +685,7 @@ void setupscreen()
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, config&2 ? 1 : 0);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, config&2 ? fsaa : 0);
}
screen = SDL_CreateWindow("Cardboard Engine", winx, winy, winw, winh, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_INPUT_FOCUS | SDL_WINDOW_MOUSE_FOCUS | flags);
screen = SDL_CreateWindow(game::gametitle, winx, winy, winw, winh, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_INPUT_FOCUS | SDL_WINDOW_MOUSE_FOCUS | flags);
if(!screen) continue;

#ifdef __APPLE__
@@ -1144,8 +1145,13 @@ struct memoryStruct {
#endif
#endif

#define MAXTOKENLEN 64
SVARP(__gametoken, ""); // game token time

#ifdef CURLENABLED

#define HNAPI "harpnetstudios.com/hnid/api/v1"

static size_t writeMemoryCallback(void* contents, size_t size, size_t nmemb, void* userp)
{
size_t realsize = size * nmemb;
@@ -1166,7 +1172,7 @@ static size_t writeMemoryCallback(void* contents, size_t size, size_t nmemb, voi
return realsize;
}

void web_get(char* targetUrl)
char* web_get(char* targetUrl, bool debug)
{
CURL* curl;
CURLcode res;
@@ -1206,13 +1212,16 @@ void web_get(char* targetUrl)
// check for errors */
if (res != CURLE_OK) {
conoutf(CON_ERROR, "curl_easy_perform() failed: %s", curl_easy_strerror(res));
return "";
}
else {
// we now have the data, do stuff with it
conoutf(CON_INFO, "%lu bytes retrieved", (unsigned long)chunk.size);
conoutf(CON_INFO, "%d response, %s url", response_code, url);
if (debug) {
conoutf(CON_INFO, "%lu bytes retrieved", (unsigned long)chunk.size);
conoutf(CON_INFO, "%d response, %s url", response_code, url);
}

conoutf(CON_ECHO, chunk.memory);
return chunk.memory;
}

/* cleanup curl stuff */
@@ -1222,12 +1231,68 @@ void web_get(char* targetUrl)
}

void testcurl_(char* targetUrl) {
web_get(targetUrl);
char* thing = web_get(targetUrl, true);
conoutf(CON_ECHO, thing);
}

COMMANDN(testcurl, testcurl_, "s");

void getuserinfo_(bool debug) {
if (debug) conoutf(CON_DEBUG, __gametoken);
oldstring apiurl;
formatstring(apiurl, "%s/game/get/userinfo.php?id=1&token=%s", HNAPI, __gametoken);
char* thing = web_get(apiurl, debug);
if (debug) conoutf(CON_DEBUG, thing);
cJSON *json = cJSON_Parse(thing);

// error handling
const cJSON* status = cJSON_GetObjectItemCaseSensitive(json, "status");
const cJSON* message = cJSON_GetObjectItemCaseSensitive(json, "message");
if (cJSON_IsNumber(status) && cJSON_IsString(message)) {
if (status->valueint > 0) {
conoutf(CON_ERROR, "web error! status: %s, \"%s\"", status->valueint, message->valuestring);
}
else {
// actual parse
const cJSON* name = NULL;
name = cJSON_GetObjectItemCaseSensitive(json, "username");
if (cJSON_IsString(name) && (name->valuestring != NULL))
{
if (debug) conoutf(CON_DEBUG, "username is \"%s\"", name->valuestring);
game::switchname(name->valuestring);
}
}
}
else {
conoutf(CON_ERROR, "malformed JSON recieved from server");
}
}

COMMANDN(getuserinfo, getuserinfo_, "i");

#endif

void setgametoken(const char* token) {
filtertext(__gametoken, token, false, false, MAXTOKENLEN);
/*if (!__gametoken[0]) {
copystring(__gametoken, token, strlen(token));
}
conoutf("length: %s", strlen(__gametoken));*/
#ifdef CURLENABLED
getuserinfo_(false);
#endif
}

ICOMMAND(gametoken, "sN", (char* s, int* numargs),
{
if (*numargs > 0) setgametoken(s);
else if (!*numargs) return;
else result(__gametoken);
});

ICOMMAND(getgametoken, "", (), result(__gametoken));


int globalgamestate = -1;

int main(int argc, char **argv)
@@ -1265,7 +1330,6 @@ int main(int argc, char **argv)
// reordered alpha to make it easier to see what's being used already. -Y 03/14/19
case 'a': fsaa = atoi(&argv[i][2]); break;
case 'b': /* compat, ignore */ break;
case 'c':
case 'd': dedicated = atoi(&argv[i][2]); if (dedicated <= 0) dedicated = 2; break;
case 'f': /* compat, ignore */ break;
case 'g': break;
@@ -1298,7 +1362,7 @@ int main(int argc, char **argv)
}
initing = NOT_INITING;

numcpus = clamp(SDL_GetCPUCount(), 1, 16);
numcpus = clamp(SDL_GetCPUCount(), 1, 64); // i wonder if this will break anything -Y 09/13/19

if(dedicated <= 1)
{
@@ -1376,6 +1440,10 @@ int main(int argc, char **argv)

initing = NOT_INITING;

#ifdef CURLENABLED
if (strcmp(__gametoken,"")) { getuserinfo_(false); }
#endif

logoutf("init: render");
restoregamma();
restorevsync();
@@ -1426,6 +1494,8 @@ int main(int argc, char **argv)
totalmillis = millis;
updatetime();

//SDL_SetWindowTitle(screen, SDL_GetWindowTitle(screen));

checkinput();
menuprocess();
tryedit();
@@ -2148,6 +2148,7 @@ ICOMMAND(jump, "D", (int *down), {
}
});
ICOMMAND(attack, "D", (int *down), { game::doattack(*down!=0); });
ICOMMAND(secattack, "D", (int* down), { game::dosecattack(*down != 0); });

bool entinmap(dynent *d, bool avoidplayers) // brute force but effective way to find a free spawn spot in the map
{
@@ -1055,6 +1055,7 @@ namespace ai
if(canshoot(d, e) && hastarget(d, b, e, yaw, pitch, dp.squaredist(ep)))
{
d->attacking = true;
d->secattacking = true;
d->ai->lastaction = lastmillis;
result = 3;
}
@@ -1228,7 +1229,7 @@ namespace ai
if(allowmove)
{
if(!request(d, b)) target(d, b, d->gunselect == GUN_FIST ? 1 : 0, b.idle ? true : false);
shoot(d, d->ai->target);
shoot(d, d->ai->target, false);
}
if(!intermission)
{
@@ -1249,7 +1250,7 @@ namespace ai
moveplayer(d, 10, false);
}
}
d->attacking = d->jumping = false;
d->attacking = d->secattacking = d->jumping = false;
}

void avoid()
@@ -135,11 +135,11 @@ namespace game
{
conoutf("your name is: %s", colorname(player1));
}
ICOMMAND(name, "sN", (char *s, int *numargs),
ICOMMAND(name, "", ()/*"sN", (char *s, int *numargs)*/,
{
if(*numargs > 0) switchname(s);
/*if(*numargs > 0) switchname(s);
else if(!*numargs) printname();
else result(colorname(player1));
else */result(colorname(player1));
});
ICOMMAND(getname, "", (), result(player1->name));

@@ -1304,6 +1304,7 @@ namespace game
{
gamepaused = val;
player1->attacking = false;
player1->secattacking = false;
}
if(a) conoutf("%s %s the game", colorname(a), val ? "paused" : "resumed");
else conoutf("game is %s", val ? "paused" : "resumed");

0 comments on commit 3f1abde

Please sign in to comment.
You can’t perform that action at this time.