rm comma operator;

everyone is making fun of me haha
This commit is contained in:
bjorn 2019-07-10 18:45:36 -07:00
parent f5633f4248
commit 4372eb293e
10 changed files with 59 additions and 38 deletions

View File

@ -35,7 +35,8 @@ static const int lovrMathTypeComponents[] = {
static float* luax_tolightmathtype(lua_State* L, int index, MathType* type) {
uintptr_t p = (uintptr_t) lua_touserdata(L, index), aligned = ALIGN(p, POOL_ALIGN);
return *type = p - aligned, p ? (float*) aligned : NULL;
*type = p - aligned;
return p ? (float*) aligned : NULL;
}
void luax_pushlightmathtype(lua_State* L, float* p, MathType type) {

View File

@ -5,5 +5,6 @@
void* _lovrAlloc(size_t size) {
Ref* ref = calloc(1, sizeof(Ref) + size);
lovrAssert(ref, "Out of memory");
return *ref = 1, ref + 1;
*ref = 1;
return ref + 1;
}

View File

@ -307,5 +307,6 @@ size_t lovrFilesystemWrite(const char* path, const char* content, size_t size, b
}
size_t bytesWritten = lovrFileWrite(&file, (void*) content, size);
return lovrFileDestroy(&file), bytesWritten;
lovrFileDestroy(&file);
return bytesWritten;
}

View File

@ -58,7 +58,8 @@ static void desktop_getDisplayDimensions(uint32_t* width, uint32_t* height) {
}
static const float* desktop_getDisplayMask(uint32_t* count) {
return *count = 0, NULL;
*count = 0;
return NULL;
}
static void desktop_getClipDistance(float* clipNear, float* clipFar) {

View File

@ -50,7 +50,8 @@ static bool leap_init(float offset, uint32_t msaa) {
}
}
return leap_destroy(), false;
leap_destroy();
return false;
}
static void leap_destroy(void) {
@ -186,8 +187,8 @@ static bool leap_getAxis(Device device, DeviceAxis axis, float* value) {
}
switch (axis) {
case AXIS_PINCH: return *value = hand->pinch_strength, true;
case AXIS_GRIP: return *value = hand->grab_strength, true;
case AXIS_PINCH: *value = hand->pinch_strength; return true;
case AXIS_GRIP: *value = hand->grab_strength; return true;
default: return false;
}
}

View File

@ -136,7 +136,8 @@ static void oculus_getDisplayDimensions(uint32_t* width, uint32_t* height) {
}
static const float* oculus_getDisplayMask(uint32_t* count) {
return *count = 0, NULL;
*count = 0;
return NULL;
}
static double oculus_getDisplayTime(void) {
@ -222,15 +223,15 @@ static bool oculus_isDown(Device device, DeviceButton button, bool* down) {
uint32_t buttons = is->Buttons & (device == DEVICE_HAND_LEFT ? ovrButton_LMask : ovrButton_RMask);
switch (button) {
case BUTTON_A: return *down = (buttons & ovrButton_A), true;
case BUTTON_B: return *down = (buttons & ovrButton_B), true;
case BUTTON_X: return *down = (buttons & ovrButton_X), true;
case BUTTON_Y: return *down = (buttons & ovrButton_Y), true;
case BUTTON_MENU: return *down = (buttons & ovrButton_Enter), true;
case BUTTON_A: *down = (buttons & ovrButton_A); return true;
case BUTTON_B: *down = (buttons & ovrButton_B); return true;
case BUTTON_X: *down = (buttons & ovrButton_X); return true;
case BUTTON_Y: *down = (buttons & ovrButton_Y); return true;
case BUTTON_MENU: *down = (buttons & ovrButton_Enter); return true;
case BUTTON_PRIMARY:
case BUTTON_TRIGGER: return *down = (is->IndexTriggerNoDeadzone[hand] > .5f), true;
case BUTTON_THUMBSTICK: return *down = (buttons & (ovrButton_LThumb | ovrButton_RThumb)), true;
case BUTTON_GRIP: return *down = (is->HandTrigger[hand] > .9f), true;
case BUTTON_TRIGGER: *down = (is->IndexTriggerNoDeadzone[hand] > .5f); return true;
case BUTTON_THUMBSTICK: *down = (buttons & (ovrButton_LThumb | ovrButton_RThumb)); return true;
case BUTTON_GRIP: *down = (is->HandTrigger[hand] > .9f); return true;
default: return false;
}
}
@ -244,13 +245,13 @@ static bool oculus_isTouched(Device device, DeviceButton button, bool* touched)
uint32_t touches = is->Touches & (device == DEVICE_HAND_LEFT ? ovrTouch_LButtonMask : ovrTouch_RButtonMask);
switch (button) {
case BUTTON_A: return *touched = (touches & ovrTouch_A), true;
case BUTTON_B: return *touched = (touches & ovrTouch_B), true;
case BUTTON_X: return *touched = (touches & ovrTouch_X), true;
case BUTTON_Y: return *touched = (touches & ovrTouch_Y), true;
case BUTTON_A: *touched = (touches & ovrTouch_A); return true;
case BUTTON_B: *touched = (touches & ovrTouch_B); return true;
case BUTTON_X: *touched = (touches & ovrTouch_X); return true;
case BUTTON_Y: *touched = (touches & ovrTouch_Y); return true;
case BUTTON_PRIMARY:
case BUTTON_TRIGGER: return *touched = (touches & (ovrTouch_LIndexTrigger | ovrTouch_RIndexTrigger)), true;
case BUTTON_THUMBSTICK: return *touched = (touches & (ovrTouch_LThumb | ovrTouch_RThumb)), true;
case BUTTON_TRIGGER: *touched = (touches & (ovrTouch_LIndexTrigger | ovrTouch_RIndexTrigger)); return true;
case BUTTON_THUMBSTICK: *touched = (touches & (ovrTouch_LThumb | ovrTouch_RThumb)); return true;
default: return false;
}
}
@ -264,8 +265,8 @@ static bool oculus_getAxis(Device device, DeviceAxis axis, vec3 value) {
ovrHandType hand = device == DEVICE_HAND_LEFT ? ovrHand_Left : ovrHand_Right;
switch (axis) {
case AXIS_GRIP: return *value = is->HandTriggerNoDeadzone[hand], true;
case AXIS_TRIGGER: return *value = is->IndexTriggerNoDeadzone[hand], true;
case AXIS_GRIP: *value = is->HandTriggerNoDeadzone[hand]; return true;
case AXIS_TRIGGER: *value = is->IndexTriggerNoDeadzone[hand]; return true;
case AXIS_PRIMARY:
case AXIS_THUMBSTICK:
value[0] = is->ThumbstickNoDeadzone[hand].x;

View File

@ -63,7 +63,8 @@ static void vrapi_getDisplayDimensions(uint32_t* width, uint32_t* height) {
}
static const float* vrapi_getDisplayMask(uint32_t* count) {
return *count = 0, NULL;
*count = 0;
return NULL;
}
static void vrapi_getClipDistance(float* clipNear, float* clipFar) {

View File

@ -130,10 +130,15 @@ static bool openvr_init(float offset, uint32_t msaa) {
// Find the location of the action manifest, create it if it doesn't exist or isn't in the save directory
const char* actionManifestLocation = lovrFilesystemGetRealDirectory("actions.json");
if (!actionManifestLocation || strcmp(actionManifestLocation, lovrFilesystemGetSaveDirectory())) {
if (lovrFilesystemWrite("actions.json", (const char*) actions_json, actions_json_len, false) != actions_json_len) { return VR_ShutdownInternal(), false; }
if (lovrFilesystemWrite("bindings_vive.json", (const char*) bindings_vive_json, bindings_vive_json_len, false) != bindings_vive_json_len) { return VR_ShutdownInternal(), false; }
if (lovrFilesystemWrite("bindings_knuckles.json", (const char*) bindings_knuckles_json, bindings_knuckles_json_len, false) != bindings_knuckles_json_len) { return VR_ShutdownInternal(), false; }
if (lovrFilesystemWrite("bindings_touch.json", (const char*) bindings_touch_json, bindings_touch_json_len, false) != bindings_touch_json_len) { return VR_ShutdownInternal(), false; }
if (
lovrFilesystemWrite("actions.json", (const char*) actions_json, actions_json_len, false) != actions_json_len ||
lovrFilesystemWrite("bindings_vive.json", (const char*) bindings_vive_json, bindings_vive_json_len, false) != bindings_vive_json_len ||
lovrFilesystemWrite("bindings_knuckles.json", (const char*) bindings_knuckles_json, bindings_knuckles_json_len, false) != bindings_knuckles_json_len ||
lovrFilesystemWrite("bindings_touch.json", (const char*) bindings_touch_json, bindings_touch_json_len, false) != bindings_touch_json_len
) {
VR_ShutdownInternal();
return false;
}
}
char path[LOVR_PATH_MAX];
@ -248,7 +253,8 @@ static const float* openvr_getDisplayMask(uint32_t* count) {
struct HiddenAreaMesh_t hiddenAreaMesh = state.system->GetHiddenAreaMesh(EVREye_Eye_Left, EHiddenAreaMeshType_k_eHiddenAreaMesh_Standard);
if (hiddenAreaMesh.unTriangleCount == 0) {
return *count = 0, NULL;
*count = 0;
return NULL;
}
state.mask = realloc(state.mask, hiddenAreaMesh.unTriangleCount * 3 * 2 * sizeof(float));
@ -259,7 +265,8 @@ static const float* openvr_getDisplayMask(uint32_t* count) {
state.mask[2 * i + 1] = hiddenAreaMesh.pVertexData[i].v[1];
}
return *count = hiddenAreaMesh.unTriangleCount * 3 * 2, state.mask;
*count = hiddenAreaMesh.unTriangleCount * 3 * 2;
return state.mask;
}
static double openvr_getDisplayTime(void) {
@ -296,7 +303,8 @@ static const float* openvr_getBoundsGeometry(uint32_t* count) {
state.boundsGeometry[4 * i + 2] = quad.vCorners[i].v[2];
}
return *count = 16, state.boundsGeometry;
*count = 16;
return state.boundsGeometry;
}
return NULL;
@ -406,7 +414,8 @@ static bool getButtonState(Device device, DeviceButton button, VRActionHandle_t
InputDigitalActionData_t actionData;
state.input->GetDigitalActionData(actions[device - DEVICE_HAND_LEFT][button], &actionData, sizeof(actionData), 0);
return *value = actionData.bState, actionData.bActive;
*value = actionData.bState;
return actionData.bActive;
}
static bool openvr_isDown(Device device, DeviceButton button, bool* down) {
@ -424,7 +433,8 @@ static bool openvr_getAxis(Device device, DeviceAxis axis, vec3 value) {
InputAnalogActionData_t actionData;
state.input->GetAnalogActionData(state.axisActions[device - DEVICE_HAND_LEFT][axis], &actionData, sizeof(actionData), 0);
return vec3_set(value, actionData.x, actionData.y, actionData.z), actionData.bActive;
vec3_set(value, actionData.x, actionData.y, actionData.z);
return actionData.bActive;
}
static bool openvr_vibrate(Device device, float strength, float duration, float frequency) {

View File

@ -219,7 +219,8 @@ static bool openxr_init(float offset, uint32_t msaa) {
views[0].recommendedImageRectWidth != views[1].recommendedImageRectWidth ||
views[0].recommendedImageRectHeight != views[1].recommendedImageRectHeight
) {
return destroy(), false;
destroy();
return false;
}
state.msaa = views[0].recommendedSwapchainSampleCount;
@ -390,7 +391,8 @@ static void openxr_getDisplayDimensions(uint32_t* width, uint32_t* height) {
}
static const float* openxr_getDisplayMask(uint32_t* count) {
return *count = 0, NULL;
*count = 0;
return NULL;
}
static double openxr_getDisplayTime(void) {

View File

@ -367,7 +367,8 @@ Shape** lovrColliderGetShapes(Collider* collider, size_t* count) {
arr_push(&collider->shapes, shape);
}
}
return *count = collider->shapes.length, collider->shapes.data;
*count = collider->shapes.length;
return collider->shapes.data;
}
Joint** lovrColliderGetJoints(Collider* collider, size_t* count) {
@ -379,7 +380,8 @@ Joint** lovrColliderGetJoints(Collider* collider, size_t* count) {
arr_push(&collider->joints, joint);
}
}
return *count = collider->joints.length, collider->joints.data;
*count = collider->joints.length;
return collider->joints.data;
}
void* lovrColliderGetUserData(Collider* collider) {