Subscribe to me on YouTube

Lanbox LCX Cue List Move Utility

April 20th, 2014 by Cody

So one of my lighting buddies works with the Lanbox LCX and asked me to do a little app to make his life easier for moving a range of cues and addresses around. I’m not familiar with Lanbox LCX so not sure how he interfaces with it. Basically he some how exports the data into a bunch of text files, and then would manually go through and update everything. So I created a little command line utility to make the process easier. It’s pretty simple little app, nothing special, but wanted to throw it on interwebs in case anyone else could make use of it. He was also a n00b when it came to using terminal on Mac, so I scratched up a quick walkthrough which is included as well. And cause I’m lazy, I used obj-c so it will only run on Mac. You can find link below. Enjoy!

LanboxLCXCueListMove_20140420_1111.zip

Update 4/25/2014
Built a quick and dirty GUI front end for anyone that feels the command line is too much typing and not enough clicky ^_^.

LanboxLCXCueListMoveGui_20140425_2200.zip

cocos2d-x 3.0 alpha 0 chipmunk debug draw

November 26th, 2013 by Cody

Was wanting to get a quick demo up with cocos2d-x and chipmunk to play around with chipmunk physics and had a bit of train wreck trying to get a debug node to work properly. It’s really not complicated, but hopefully this will keep someone else from stumbling through it like I did. I should’ve kept link to the person that inspired this. It wasn’t completely my idea.

ChipmunkDebugNode.h

//
// desc: ChipmunkDebugNode.h
//

#ifndef _CHIPMUNKDEBUGNODE_H_
#define _CHIPMUNKDEBUGNODE_H_

//
// includes
//
#include "cocos2d.h"
#include "chipmunk.h"

//
// struct ChipmunkDebugNode
//
struct ChipmunkDebugNode : cocos2d::Node
{
    //
    // static methods
    //
    static ChipmunkDebugNode *create(cpSpace *space);
    static void DrawShape(cpShape *shape, void *data);
    
    //
    // init
    //
    virtual bool init(cpSpace *space);
    
    //
    // overload draw
    //
    virtual void draw();
    
    //
    // variables
    //
    cpSpace *_space;
};

#endif // #ifndef _CHIPMUNKDEBUGNODE_H_

ChipmunkDebugNode.cpp

//
// desc: ChipmunkDebugNode.cpp
//

//
// includes
//
#include "ChipmunkDebugNode.h"

// cocos2d namespace
USING_NS_CC;

ChipmunkDebugNode *ChipmunkDebugNode::create(cpSpace *space)
{
    ChipmunkDebugNode *chipmunkDebugNode = new ChipmunkDebugNode();
    if (chipmunkDebugNode && chipmunkDebugNode->init(space)) {
        chipmunkDebugNode->autorelease();
        return chipmunkDebugNode;
    }
    
    // else cleanup
    delete chipmunkDebugNode;
    return NULL;
}

void ChipmunkDebugNode::DrawShape(cpShape* shape, void *data)
{
    if (!shape) {
        return;
    }
    
    glLineWidth(5.0f);
    DrawPrimitives::setDrawColor4F(0.5f, 0.5f, 0.5f, 1.0f);
    
    if (shape->klass_private->type == CP_CIRCLE_SHAPE) {
        cpCircleShape *circle = (cpCircleShape *)shape;
        cpVect center = cpvadd(shape->body->p, cpvrotate(circle->c, shape->body->rot));
        DrawPrimitives::drawCircle(Point(center.x, center.y), circle->r, shape->body->a, 20, true);
        return;
    }
    
    if (shape->klass_private->type == CP_POLY_SHAPE) {
        cpPolyShape *poly = (cpPolyShape *)shape;
        
        // convert chipmunk points to coco points
        Point *pointArray = new Point[poly->numVerts];
        for (int i=0; i < poly->numVerts; i++) {
            pointArray[i] = Point(poly->tVerts[i].x, poly->tVerts[i].y);
        }
        
        DrawPrimitives::drawPoly(pointArray, poly->numVerts, true);
        delete pointArray;
        return;
    }
    
    if (shape->klass_private->type == CP_SEGMENT_SHAPE) {
        cpSegmentShape* segment = (cpSegmentShape*)shape;
        DrawPrimitives::drawLine(Point(segment->ta.x, segment->ta.y),
                                 Point(segment->tb.x, segment->tb.y));
        return;
    }
    
    cpSegmentShape *segment = (cpSegmentShape *)shape;
    DrawPrimitives::drawLine(Point(segment->ta.x, segment->ta.y),
                             Point(segment->tb.x, segment->tb.y));
}

//
// descP init
//
bool ChipmunkDebugNode::init(cpSpace *space)
{
    if (!Node::init()) {
        return false;
    }
    
    // init variables
    _space = space;
    
    return true;
}

//
// desc: override draw
//
void ChipmunkDebugNode::draw()
{
    cpSpaceEachShape(_space, &DrawShape, this);
}

And for completeness, here is example of using it inside my root layer. Should all be pretty straight forward once you see it.

// setup chimpunk stuff
cpSpace *space = cpSpaceNew();
cpSpaceSetGravity(space, cpv(0.0f, -1.0f));

cpBody *body = cpBodyNew(100.0f, INFINITY);
cpShape *shape = cpCircleShapeNew(body, 30.0f, cpvzero);

body->p = cpv(visibleSize.width / 2.0f, visibleSize.height / 2.0f);

cpSpaceAddBody(space, body);
cpSpaceAddShape(space, shape);

// create and add chipmunk debug node
this->addChild(ChipmunkDebugNode::create(space));

S BAT 2 is now Open Source!

November 4th, 2013 by Cody

It only took me forever to finally get this all posted. Since S BAT 2 had total of around 200 downloads over a year, I decided to cancel my developers license. I quickly realized I am too introverted to learn how to sell myself and my game to others. It’s either the introversion, or the lack of self confidence, or both, or that I’m not cut out for game dev, or that was my first game and you can’t expect your first to be great, or however else you want to frame it. So, for that year and a half of work doesn’t go to complete waste. I decided to release the code on github (https://github.com/PingPongRhino/sbat2) as open source under the MIT license in hopes it might help someone else. I mainly hope someone will improve upon how I did my beizer lasers. Heck, I’d be super excited if someone just steals the logic outright. As long as there are more awesome 2D bendy lasers in games, then I will feel I’ve had some small impact on the world. I do still have it running on my phone and I do hope to show it at the next Juegos Rancheros to get some word out about the code being available on github. I haven’t gotten in touch with anyone yet, so I will let you know.

And also, for those who thought you couldn’t beat the game. Chris and Brian helped me make a full playthrough video along with commentary track. Since it’s hard to record iOS high quality video, we cloned it on the apple tv and captured it, which meant the video FPS and resolution isn’t the best. It does run at a full 60fps on the 4S. Well, that was back on iOS 6, so maybe things have changed with iOS 7. Note, there is some explicit language in the commentary. You can find video here. I recommend downloading it as it’s kind of large and streaming doesn’t work so well. I will wait for site5 to get mad at me for uploading such a large video…

Big thanks to Chris Pellett, Brian Langevin, and Brian Stark for all the help on the game and a huge thanks for anyone who actually played the game! This pretty much brings S BAT 2 to a close finally!

Coptic Stitch Book Binding

February 8th, 2013 by Cody

Check it out! I totally just bound my first book using coptic stitch method. I followed SeaLemonDIY Coptic Stitch tutorials on youtube. I realized after I finished that I did the edge stitching wrong when looping to the next page. You are suppose to loop two signatures down on the edges (at least I think that’s the idea). Also pulled a little too hard on the stitching a couple of times and ripped some pages a little. All in all, feels pretty solid even with my mistakes. The cover I got from digging through books at Half-Price Books and then gutted it. Inspired by the Sketchbook Project, this will be a collaborative sketchbook. So my first contribution was inspired by Magic Game Time, although mine has nothing to do with games. Also I’m not an artist. Wishing I had Zac Gorman skillz. I keep saying inspired, but really, I just steal cool ideas from a bunch of random people and slop them together and pretend I’m a super hipster/creative… <_<







Scanned the image in instead of just taking a picture so it’s more visible.

Lookup IP Address by User Defined Ethernet Name on Mac OS X

December 19th, 2012 by Cody

This proved to be far more tricky than I thought it would. The documentation not being clear to me and lack of example code made things convoluted. So this involved a lot of trial and error with the SCNetworkConfiguration APIs and reading the System Configuration Schema. I had found examples in our code base on how to look up the BSD name based on the user defined name by iterating through the kSCPrefNetworkServices in SCNetworkSetRef returned from SCNetworkSetCopyCurrent(). Once you have the BSD name, it’s pretty simple to lookup the IP address and subnet mask from it.

The problem I ran into is if the user has two network services configured on the same ethernet device. So say the user has two network services, Ethernet 1 and Ethernet 2, both configured on en0. I want the IP address for Ethernet 2 network service. So I fetch it’s BSD name which is en0, and then see en0 has two IP Addresses with no way to link back which IP address belongs to which network service. My first attempt was to go through SCNetworkProtocolGetConfiguration(). Which sort of worked, however quickly realized that if the ConfigMethod was set to DHCP, I couldn’t get any IPv4 info from the protocol configuration dictionary.

Finally realized the trick was to use the System Configuration Schema. The solution is to look up the NetworkServiceRef using the user defined name. Then access the dynamic store information for the network service using SCDynamicStoreKeyCreateNetworkServiceEntity() and SCDynamicStoreCopyValue(). The information is stored down in State:/Network/Service/ServiceID/IPv4.

I’m worried that I might be shaving a yak here. The whole reason I’m doing this is because I need to be able to broadcast messages on the ethernet device that the user specifies. The solution I came up with was to calculate the broadcast address based on the selected device, and use sendto() to broadcast to that destination. This will fall through the routing table and out the proper device. If I was on Linux, I could just SO_BINDTODEVICE, but Mac will be having none of that SO_BINDTODEVICE hooligans. If you know of a better solution for Mac to broadcast on a specific device or get the broadcast address, please let me know.

Enough talk, here is the code I use to fetch the IP address and broadcast address. Note that CopyIPv4NetworkProtocolWithUserDefinedName() isn’t actually used or needed for this solution. I created it when trying to solve this another way and thought it would prove useful to leave in. Enjoy!

Update (04/25/2013): Fixed an issue where the System Configuration could end up with zombie network services. So if you had named a service the same name as one of the zombie services, then there was a good chance it would attempt to pull IP info from that zombie service which has no IP info. Also fixed some memory leaks.

//
// includes
//
#import <SystemConfiguration/SystemConfiguration.h>
#import <CoreFoundation/CoreFoundation.h>
#import <arpa/inet.h>
#import <string>

//
// desc: convert IPv4 address from binary format to numbers-and-dots notation in a string
//
// params: networkAddress[in] - IPv4 address in binary format to be converted to string
//
// returns: returns networkAddress in nubers-and-dots notation
//
std::string ConvertNetworkAddressToString(int networkAddress)
{
   // convert to string and return it
   struct in_addr address_struct;
   memset(&address_struct, 0, sizeof(address_struct));
   address_struct.s_addr = htonl(networkAddress);
   return std::string(inet_ntoa(address_struct));
}

//
// desc: fetch IPv4 address for network service, aka network interface,
//       with the user defined name.
//
// params: userDefinedName[in] - user defined name of network service to get IPv4 address for.
//                               this is whats displayed under System Preferences->Network, for
//                               example, "Ethernet 1", "WiFi", etc...
//
// returns: returns IPv4 address in numbers-and-dots notation if successful
//          returns 0.0.0.0 if failed (logs errors as debug messages to VLog)
//
std::string IPAddressForEthernetInterfaceWithUserDefinedName(const char *userDefinedName)
{
   // validate params
   if (!userDefinedName) {
      return std::string("0.0.0.0");
   }
   
   // first check if they want to go to localhost
   if (strcmp(userDefinedName, "localhost") == 0) {
      return std::string("127.0.0.1"); // just return localhost as destination, and we are done
   }
   
   // get network service
   SCNetworkServiceRef networkServiceRef = CopyNetworkServiceRefWithUserDefinedName(userDefinedName);
   if (!networkServiceRef) {
      return std::string("0.0.0.0");
   }
   
   // get ip address from network service
   CFStringRef address = CopyIPAddressFromNetworkService(networkServiceRef);
   if (!address) {
      CFRelease(networkServiceRef);
      return std::string("0.0.0.0");
   }
   
   // validate string
   if (CFStringGetLength(address) <= 0) {
      CFRelease(address);
      CFRelease(networkServiceRef);
      return std::string("0.0.0.0");
   }
   
   // convert to std::string
   NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   std::string returnAddress = std::string([(NSString *)address UTF8String]);
   [pool drain];
   
   // cleanup
   CFRelease(address);
   CFRelease(networkServiceRef);
   
   // return ip address
   return returnAddress;
}

//
// desc: fetch IPv4 broadcast address for network service, aka network interface, with the user
//       defined name.
//
// params: userDefinedName[in] - user defined name of network service to get IPv4 broadcast address for.
//                               this is whats displayed under System Preferences->Network, for
//                               example, "Ethernet 1", "WiFi", etc...
//
// returns: returns IPv4 broadcast address in numbers-and-dots notation if successful
//          returns 0.0.0.0 if failed (logs errors as debug messages to VLog)
//
std::string BroadcastAddressForEthernetInterfaceWithUserDefinedName(const char *userDefinedName)
{
   // validate params
   if (!userDefinedName) {
      return std::string("0.0.0.0");
   }
   
   // first check if they want to go to localhost
   if (strcmp(userDefinedName, "localhost") == 0) {
      return std::string("127.0.0.1"); // just return localhost as destination, and we are done
   }
   
   // get network service
   SCNetworkServiceRef networkServiceRef = CopyNetworkServiceRefWithUserDefinedName(userDefinedName);
   if (!networkServiceRef) {
      return std::string("0.0.0.0");
   }
   
   // get ip address from network service
   CFStringRef addressString = CopyIPAddressFromNetworkService(networkServiceRef);
   if (!addressString) {
      CFRelease(networkServiceRef);
      return std::string("0.0.0.0");
   }
   
   // get subnet mask from network service
   CFStringRef subnetMaskString = CopySubnetMaskFromNetworkService(networkServiceRef);
   if (!subnetMaskString) {
      CFRelease(addressString);
      CFRelease(networkServiceRef);
      return std::string("0.0.0.0");
   }
   
   // validate strings
   if (CFStringGetLength(addressString) <= 0 || CFStringGetLength(subnetMaskString) <= 0) {
      CFRelease(addressString);
      CFRelease(subnetMaskString);
      CFRelease(networkServiceRef);
      return std::string("0.0.0.0");
   }
   
   // generate broadcast address
   NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   in_addr_t address = htonl(inet_addr([(NSString *)addressString UTF8String]));
   in_addr_t subnetMask = htonl(inet_addr([(NSString *)subnetMaskString UTF8String]));
   [pool drain];
   
   int broadcastAddresss = address | ~subnetMask;
   
   // cleanup
   CFRelease(addressString);
   CFRelease(subnetMaskString);
   CFRelease(networkServiceRef);
   
   // return ip address
   return ConvertNetworkAddressToString(broadcastAddresss);
}

//
// desc: copies the first IPv4 address associated with the network service.
//
// params: networkServiceRef[in] - network service to get IPv4 address for
//
// returns: returns first IPv4 address associated with the network service if successful
//          returns NULL if failed (logs errors as debug messages to VLog)
//
CFStringRef CopyIPAddressFromNetworkService(SCNetworkServiceRef networkServiceRef) {
   return CopyIPv4PropertyFromNetworkService(kSCPropNetIPv4Addresses, networkServiceRef);
}

//
// desc: copies the first IPv4 subnet mask associated with the network service.
//
// params: networkServiceRef[in] - network service to get IPv4 subnet mask for
//
// returns: returns first IPv4 subnet mask associated with the network service if successful
//          returns NULL if failed (logs errors as debug messages to VLog)
//
CFStringRef CopySubnetMaskFromNetworkService(SCNetworkServiceRef networkServiceRef) {
   return CopyIPv4PropertyFromNetworkService(kSCPropNetIPv4SubnetMasks, networkServiceRef);
}

//
// desc: copies requested property from network service. this assumes the property your are
//       fetching from the network service is an array of strings.  it will return the first
//       string in the array.  done for convience reasons since we generally want one ip address, subnet mask, etc...
//       for network service.  for example, kSCPropNetIPv4Addresses will return an array of
//       all addresses for this network service, but typically we want just the top one in the list.
//
// params: property[in] - property you want from the network service, kSCPropNetIPv4Addresses, kSCPropNetIPv4SubnetMasks, etc...
//         networkServiceRef[in] - network service to get property from
//
// returns: returns copy of property value if successful
//          returns NULL if failed to retrieve property (logs errors as debug messages to VLog)
//
CFStringRef CopyIPv4PropertyFromNetworkService(CFStringRef property, SCNetworkServiceRef networkServiceRef)
{
   // validate parameter
   if (!networkServiceRef) {
      return NULL;
   }
   
   CFDictionaryRef dictionary = CopyDynamicStoreDictionaryForNetworkService(networkServiceRef, kSCEntNetIPv4);
   if (!dictionary) {
      return NULL;
   }
   
   CFStringRef string = GetFirstStringInArrayWithKeyInDictionary(property, dictionary);
   if (!string) {
      CFRelease(dictionary);
      return NULL;
   }
   
   // retain the ip address cause we will blitz the dictionary in a sec
   CFStringRef stringCopy = CFStringCreateCopy(NULL, string);
   
   // cleanup
   CFRelease(dictionary);
   
   return stringCopy;
}

//
// desc: copies the property list for a specific network service
//
// params: dynamicStoreRef[in] - dynamic store used to copy value from, user should create this using SCDynamicStoreCreate()
//         networkServiceRef[in] - network service to get property list for
//         domain[in] - domain to get property list for (kSCDynamicStoreDomainState, kSCDynamicStoreDomainSetup, etc...)
//         key[in] - key to get property list for (kSCEntNetIPv4, kSCEntNetIPv6, etc...)
//
// returns: returns CFPropertListRef contain property list of requested key if successful
//                  caller must release returned CFPropertyListRef using CFRelease
//          returns NULL if failed, check logs for more info
//
CFPropertyListRef CopyDynamicStorePropertyListForNetworkService(SCDynamicStoreRef dynamicStoreRef, SCNetworkServiceRef networkServiceRef, CFStringRef domain, CFStringRef key)
{
   // create the key we want
   CFStringRef dynamicStoreKey = SCDynamicStoreKeyCreateNetworkServiceEntity(NULL, domain, SCNetworkServiceGetServiceID(networkServiceRef), key);
   if (!dynamicStoreKey) {
      return NULL;
   }
   
   // get property list for key
   CFPropertyListRef propertyList = SCDynamicStoreCopyValue(dynamicStoreRef, dynamicStoreKey);
   if (!propertyList) {
      CFRelease(dynamicStoreKey);
      return NULL;
   }
   
   CFRelease(dynamicStoreKey);
   return propertyList;
}

//
// desc: copies the dynamic store (persistent store) dictionary for the network service.
//       if you don't know what i'm talking about, (cause i sure as hell didn't when i
//       started trying to figure this stuff out) go here
//       ( https://developer.apple.com/library/mac/#documentation/Networking/Conceptual/SystemConfigFrameworks/SC_UnderstandSchema/SC_UnderstandSchema.html#//apple_ref/doc/uid/TP40001065-CH203-CHDIHDCG ).
//
// params: networkServiceRef[in] - network service to get dynamic store dictionary for
//
// returns: returns dictionary if succesfully fetchs property list for network service
//          returns NULL if failed (logs errors as debug messages to VLog)
//
CFDictionaryRef CopyDynamicStoreDictionaryForNetworkService(SCNetworkServiceRef networkServiceRef, CFStringRef key)
{
   // validate params
   if (!networkServiceRef || !key) {
      return NULL;
   }
   
   // create dynamic store
   SCDynamicStoreRef dynamicStoreRef = SCDynamicStoreCreate(NULL, CFSTR("CopyDynamicStoreDictionaryForNetworkService"), NULL, NULL);
   if (!dynamicStoreRef) {
      return NULL;
   }
   
   // try to get it from domain state first
   CFPropertyListRef propertyList = CopyDynamicStorePropertyListForNetworkService(dynamicStoreRef, networkServiceRef, kSCDynamicStoreDomainState, key);
   if (!propertyList) {
      
      // since that failed, lets try domain setup
      propertyList = CopyDynamicStorePropertyListForNetworkService(dynamicStoreRef, networkServiceRef, kSCDynamicStoreDomainSetup, key);
      if (!propertyList) {
         CFRelease(dynamicStoreRef);
         return NULL;
      }
   }
   
   // make sure this is dictionary type
   if (CFGetTypeID(propertyList) != CFDictionaryGetTypeID()) {
      CFRelease(propertyList);
      CFRelease(dynamicStoreRef);
      return NULL;
   }
   
   // cleanup
   CFRelease(dynamicStoreRef);
   
   // return dictionary
   return (CFDictionaryRef)propertyList;
}

//
// desc: copy network service with user defined name.
//
// params: userDefinedName[in] - user defined name of network service to get IPv4 broadcast address for.
//                               this is whats displayed under System Preferences->Network, for
//                               example, "Ethernet 1", "WiFi", etc...
//
// returns: returns SCNetworkServiceRef to network service with user defined name is successful
//          returns NULL if failed (logs errors as debug messages to VLog)
//
SCNetworkServiceRef CopyNetworkServiceRefWithUserDefinedName(const char *userDefinedName)
{
   // validate params
   if (!userDefinedName) {
      return NULL;
   }
   
   // create preferences
   SCPreferencesRef preferences = SCPreferencesCreate(kCFAllocatorDefault, CFSTR("PRG"), NULL);
   if (!preferences) {
      return NULL;
   }
   
   // get list of all interface devices
   CFArrayRef serviceArray = SCNetworkServiceCopyAll(preferences);
   if (!serviceArray) {
      CFRelease(preferences);
      return NULL;
   }
   
   // get array of valid service id's
   CFArrayRef validServiceIds = CreateArrayOfValidNetworkServiceIds();
   
   // look for out guy
   SCNetworkServiceRef returnNetworkServiceRef = NULL;
   for (int i=0; i < CFArrayGetCount(serviceArray); i++) {
      SCNetworkServiceRef networkServiceRef = (SCNetworkServiceRef)CFArrayGetValueAtIndex(serviceArray, i);
      
      // if not valid service id, then skip
      CFStringRef serviceId = SCNetworkServiceGetServiceID(networkServiceRef);
      if (!CFArrayContainsValue(validServiceIds, CFRangeMake(0, CFArrayGetCount(validServiceIds)), serviceId)) {
         continue;
      }
      
      // if we got a match on service name
      NSString *serviceName = (NSString *)SCNetworkServiceGetName(networkServiceRef);
      if (strcmp([serviceName UTF8String], userDefinedName) == 0) {
         returnNetworkServiceRef = networkServiceRef; // save off our interface so we can return it
         CFRetain(returnNetworkServiceRef);           // retain object so we don't lose it, up to caller to release
         break;
      }
   }
   
   CFRelease(preferences);
   CFRelease(serviceArray);
   CFRelease(validServiceIds);
   return returnNetworkServiceRef;
}

//
// desc: copy IPv4 protocol with user defined name.
//
// params: userDefinedName[in] - user defined name of network service to get IPv4 broadcast address for.
//                               this is whats displayed under System Preferences->Network, for
//                               example, "Ethernet 1", "WiFi", etc...
//
// returns: returns SCNetworkProtocolRef to network service IPv4 protocol with user defined name is successful
//          returns NULL if failed (logs errors as debug messages to VLog)
//
SCNetworkProtocolRef CopyIPv4NetworkProtocolWithUserDefinedName(const char *userDefinedName)
{
   // validate params
   if (!userDefinedName) {
      return NULL;
   }
   
   SCNetworkServiceRef networkServiceRef = CopyNetworkServiceRefWithUserDefinedName(userDefinedName);
   if (!networkServiceRef) {
      return NULL;
   }
   
   // get ipv4 protocol from service
   SCNetworkProtocolRef protocol = SCNetworkServiceCopyProtocol(networkServiceRef, kSCEntNetIPv4);
   if (!protocol) {
      CFRelease(networkServiceRef);
      return NULL;
   }
   
   // cleanup
   CFRelease(networkServiceRef);
   return protocol;
}

//
// desc: convience function for fecthing the first string object in an array of string objects
//       that is stored in a |dictionary| with |key| value.
//
// params: key[in] - dictionary key, object for key is expected to be an array of CFStringRef objects
//         dictionary[in] - dictionary to look the key up in
//
// returns: returns string of first object in the array with |key| in the |dictionary|
//          returns NULL if failed (logs errors as debug messages to VLog)
//
CFStringRef GetFirstStringInArrayWithKeyInDictionary(CFStringRef key, CFDictionaryRef dictionary)
{
   // validate params
   if (!key || !dictionary) {
      return NULL;
   }
   
   // fetch value
   CFTypeRef object = CFDictionaryGetValue(dictionary, key);
   if (!object) {
      return NULL;
   }
   
   // if this isn't an array, then bail
   if (CFGetTypeID(object) != CFArrayGetTypeID()) {
      return NULL;
   }
   
   // make sure we have items in the array
   CFArrayRef array = (CFArrayRef)object;
   if (CFArrayGetCount(array) <= 0) {
      return NULL;
   }
   
   // get first object in list
   object = CFArrayGetValueAtIndex(array, 0);
   if (!object) {
      return NULL;
   }
   
   // make sure it's a string
   if (CFGetTypeID(object) != CFStringGetTypeID()) {
      return NULL;
   }
   
   return (CFStringRef)object;
}

//
// desc: create a list of valid network service ids.  this are all the network service
//       id's listed in the Setup: domain.
//
// returns: returns array of valid network service id's if successful
//                  it is up to the caller to release this using CFRelease()
//          returns NULL if failed to create list of valid network service id's, check logs for more info
//
CFArrayRef CreateArrayOfValidNetworkServiceIds()
{
   @autoreleasepool {
      
      CFStringRef pattern = CFSTR("Setup:/Network/Service/[^/]+");
      
      // create dynamic store
      SCDynamicStoreRef dynamicStoreRef = SCDynamicStoreCreate(NULL, CFSTR("CreateListOfActiveIPv4NetworkServiceIds"), NULL, NULL);
      if (!dynamicStoreRef) {
         return NULL;
      }
      
      // get property list for key
      CFArrayRef keyList = SCDynamicStoreCopyKeyList(dynamicStoreRef, pattern);
      if (!keyList) {
         CFRelease(dynamicStoreRef);
         return NULL;
      }
      
      CFRelease(dynamicStoreRef);
      
      // strip prefix "Setup:/Network/Service/" so we have just the service id
      NSMutableArray *serviceIdList = [[NSMutableArray alloc] initWithCapacity:CFArrayGetCount(keyList)];
      if (!serviceIdList) {
         CFRelease(keyList);
         return NULL;
      }
      
      for (NSString *key in (NSArray *)keyList) {
         NSString *serviceId = [key substringFromIndex:[key length] - 36]; // service id should be at end and is 36 characters long, so get that substring from end
         [serviceIdList addObject:serviceId];
      }
      
      CFRelease(keyList);
      return (CFArrayRef)serviceIdList;
   }
}

//
// desc: return if a network service id is valid or not.  checks
//       to see if network service id exist in the Setup: domain to
//       detemine if it is valid or not.
//
// params: networkServiceId[in] - network service id, for example "91B9C4B4-BB98-445D-BFDB-2D92DADE3B6B"
//
// returns: returns true if network service id exist in the Setup: domain
//          returns false if network service id does NOT exist in the Setup: domain
//
bool IsValidNetworkServiceId(CFStringRef networkServiceId)
{
   CFArrayRef validServiceIds = CreateArrayOfValidNetworkServiceIds();
   if (!validServiceIds) {
      return false;
   }
   
   if (CFArrayContainsValue(validServiceIds, CFRangeMake(0, CFArrayGetCount(validServiceIds)), networkServiceId)) {
      CFRelease(validServiceIds);
      return true;
   }
   
   CFRelease(validServiceIds);
   return false;
}

First attempt at marketing!

October 23rd, 2012 by Cody

Finally starting to work on some marketing material. Hopefully this will end up on a postcard style flyer on the desk of Zeus Comics. First draft, so still needs some tweaking.

Realizations as an iOS hobbyist

October 6th, 2012 by Cody

Read this article, Some Depressing Thoughts On The App Store, this morning and had some thoughts I needed to get out there. I’ve always thought of the app store being more of a marketing tool for Apple, but I think someone validating the claim really makes it hit home. I know I haven’t done my part to market my game and I created S BAT 2 to complete a life goal, not to supplement my income. I was not expecting to become a millionaire or even hundred-aire based on one silly idea for a game. It would be nice to get reimbursed the fees for the dev license, but even then, I considered it the cost of a hobby. Between seeing articles like this, XCode and LLDB making my job a complete nightmare this week, and the fact that when I let my dev license expire I’ll never be able to play my game again (well I could do some jailbreaking), I honestly don’t know why any hobbyist would want to develop on iOS. Outside of Objective-C, which is amazing, Apple development is pretty painful process in my book. If I do tackle another game project, it’ll be on Windows or Linux. At least there I won’t have to pay just to be able to develop and play my own game. Also the indie game community is way more supportive in the Windows and Linux world. End rant.

S BAT 2 GXO: The OS HD Now Available!

September 22nd, 2012 by Cody

Finally got HD version for iPad released on the App Store. I apologize that the framerate isn’t as good as I had hoped for. If I find time, I will try to correct that. Also just submitted v1.1 for iPhone which contains various fixes.

S BAT 2 GXO: The OS version 1.1 fixes

  • fix, now decrypts and plays background track on a low priority background thread, this is to fix a performance hiccup that occurs when it is decrypting the track
  • fixed some typos in tutorial menus
  • added pause bar to tutorial mode so players can back out of it
  • fixed the repeater beams from popping from their old location when being reinitialized
  • fix where first wave stage would sometimes continue spawning off the play field

Now I just need to make a sad attempt at marketing this guy :D.

Getting back to it

July 20th, 2012 by Cody

After a long hiatus which included beating Bastion, VVVVV, and Botanicula, I’m finally getting back into some S BAT 2 development. Got a little bit of feedback, but not much. Which is what I expected since I’m virtually unknown to anyone and it’s just a few friends that mention it every once in a while. Goal is to try to get iPad paid version out sometime in August. I will also make some sad attempt at marketing, and if I don’t see any interest after that, then I will probably drop the project. Anywho, here is what I got done today.

- Move decryption and loading of background files to low priority background thread so it will no longer interrupt gameplay with the performance hit
- Added pause terminal to top of the tutorial mode so you can back out and adjust options when in the tutorial
- Fixed typos in tutorial terminal text

S BAT 2 GXO: The OS is now available!

June 6th, 2012 by Cody

And even better, it’s free! Download it here! Starting to get some feedback from people so starting a list of fixes and changes for the next update. I plan to take a break for the next couple of weeks and play through Bastion (I’m sooo far behind on gamming) and then I’ll start on small update for iPhone followed by working on hi res iPad version. And somewhere in there, I plan to start scripting the story mode. So after I take a short hiatus, here is the list of stuff I want to tackle. Thanks for playing and please feel free to give me feedback.

S BAT 2 GXO: The OS v2

  • Fix bug where game pauses when loading next background track, this hiccup sometimes causes the mobile towers to move outside of the play field
  • Add terminal to top of tutorial mode so user can exit tutorial mode at any point and adjust options without having to complete the tutorial
  • Track down bug when emulating on iPad where sometimes the emissions will reach their target, but disappear preventing the next wave from spawning
  • Fix typos in the tutorial menu text (I’m sure Marc is laughing it up on this one…)